mirror of
https://github.com/containers/ramalama.git
synced 2026-02-05 06:46:39 +01:00
add support for running bats in a container
Add a new "bats" container which is configured to run the bats tests. The container supports running the standard bats test suite (container-in-container) as well as the "--nocontainer" tests. Add two new Makefile targets for running the bats container via podman. Signed-off-by: Mike Bonnet <mikeb@redhat.com>
This commit is contained in:
25
Makefile
25
Makefile
@@ -10,6 +10,7 @@ PATH := $(PATH):$(HOME)/.local/bin
|
||||
IMAGE ?= ramalama
|
||||
PYTHON_FILES := $(shell find . -path "./.venv" -prune -o -name "*.py" -print) $(shell find . -name ".venv" -prune -o -type f -perm +111 -exec grep -l "^\#!/usr/bin/env python3" {} \; 2>/dev/null || true)
|
||||
PYTEST_COMMON_CMD ?= PYTHONPATH=. pytest test/unit/ -vv
|
||||
BATS_IMAGE ?= localhost/bats:latest
|
||||
|
||||
default: help
|
||||
|
||||
@@ -161,6 +162,30 @@ bats-nocontainer:
|
||||
bats-docker:
|
||||
_RAMALAMA_TEST_OPTS=--engine=docker RAMALAMA=$(CURDIR)/bin/ramalama bats -T test/system/
|
||||
|
||||
.PHONY: bats-image
|
||||
bats-image:
|
||||
podman inspect $(BATS_IMAGE) &> /dev/null || \
|
||||
podman build -t $(BATS_IMAGE) -f container-images/bats/Containerfile .
|
||||
|
||||
.PHONY: bats-in-container
|
||||
bats-in-container: bats-image
|
||||
podman run -it --rm \
|
||||
--userns=keep-id:size=200000 \
|
||||
--security-opt unmask=/proc/* \
|
||||
--security-opt label=disable \
|
||||
--security-opt=mask=/sys/bus/pci/drivers/i915 \
|
||||
--device /dev/net/tun \
|
||||
-v $(CURDIR):/src \
|
||||
$(BATS_IMAGE) make bats
|
||||
|
||||
.PHONY: bats-nocontainer-in-container
|
||||
bats-nocontainer-in-container: bats-image
|
||||
podman run -it --rm \
|
||||
--userns=keep-id:size=200000 \
|
||||
--security-opt=mask=/sys/bus/pci/drivers/i915 \
|
||||
-v $(CURDIR):/src \
|
||||
$(BATS_IMAGE) make bats-nocontainer
|
||||
|
||||
.PHONY: ci
|
||||
ci:
|
||||
test/ci.sh
|
||||
|
||||
24
container-images/bats/Containerfile
Normal file
24
container-images/bats/Containerfile
Normal file
@@ -0,0 +1,24 @@
|
||||
FROM quay.io/fedora/fedora:42
|
||||
|
||||
ENV HOME=/tmp \
|
||||
XDG_RUNTIME_DIR=/tmp \
|
||||
STORAGE_DRIVER=vfs
|
||||
WORKDIR /src
|
||||
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
|
||||
|
||||
RUN dnf -y install make bats jq iproute podman openssl httpd-tools \
|
||||
ollama python3-huggingface-hub \
|
||||
# for building llama-bench
|
||||
git-core cmake gcc-c++ curl-devel && \
|
||||
dnf -y clean all
|
||||
RUN rpm --restore shadow-utils
|
||||
RUN git clone --depth=1 https://github.com/ggml-org/llama.cpp && \
|
||||
pushd llama.cpp && \
|
||||
cmake -B build -DGGML_NATIVE=OFF -DGGML_RPC=ON -DGGML_CCACHE=OFF -DGGML_CMAKE_BUILD_TYPE=Release -DLLAMA_CURL=ON -DCMAKE_INSTALL_PREFIX=/usr && \
|
||||
cmake --build build --config Release --parallel $(nproc) && \
|
||||
cmake --install build && \
|
||||
popd && rm -rf llama.cpp
|
||||
|
||||
COPY container-images/bats/entrypoint.sh /usr/bin
|
||||
COPY container-images/bats/containers.conf /etc/containers
|
||||
RUN chmod a+rw /etc/subuid /etc/subgid
|
||||
8
container-images/bats/containers.conf
Normal file
8
container-images/bats/containers.conf
Normal file
@@ -0,0 +1,8 @@
|
||||
[containers]
|
||||
utsns="host"
|
||||
cgroups="disabled"
|
||||
log_driver="k8s-file"
|
||||
|
||||
[engine]
|
||||
events_logger="file"
|
||||
infra_image="quay.io/libpod/k8s-pause:3.5"
|
||||
10
container-images/bats/entrypoint.sh
Executable file
10
container-images/bats/entrypoint.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "$(id -u):10000:100000" > /etc/subuid
|
||||
echo "$(id -g):10000:100000" > /etc/subgid
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
exec "$@"
|
||||
else
|
||||
exec /bin/bash
|
||||
fi
|
||||
@@ -116,7 +116,7 @@ build() {
|
||||
echo "${conman_show_size[@]}"
|
||||
"${conman_show_size[@]}"
|
||||
case ${target} in
|
||||
ramalama-cli | llama-stack | openvino)
|
||||
ramalama-cli | llama-stack | openvino | bats)
|
||||
;;
|
||||
*)
|
||||
add_entrypoints "${conman[@]}" "${REGISTRY_PATH}"/"${target}" "${version}"
|
||||
|
||||
Reference in New Issue
Block a user