From 5f34579894634de814014b58e23b348b6764a56b Mon Sep 17 00:00:00 2001 From: boekhorstb1 <91957243+boekhorstb1@users.noreply.github.com> Date: Mon, 29 Apr 2024 15:26:43 +0200 Subject: [PATCH] Add containerization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rafael te Boekhorst Signed-off-by: Tobias Wolf Signed-off-by: Jan-Marten Brüggemann Co-authored-by: Tobias Wolf Co-authored-by: Jan-Marten Brüggemann --- Dockerfile | 37 +++++++++++++++++++++++++++++++++++++ Makefile | 15 +++++++++++---- README.md | 5 ++++- setup.py | 2 +- 4 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5176b89 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +# Builder +FROM python:3.11 as builder + +ARG ROOKIFY_VERSION=0.0.0.dev0 +ENV ROOKIFY_VERSION=$ROOKIFY_VERSION + +WORKDIR /app/rookify + +RUN pip install build +COPY . /app/rookify/ +RUN python -m build /app/rookify/ + + +# Base +FROM ubuntu:24.04 as base + +# Update packages required for Rookify +RUN apt-get update && apt-get install -qy python3-pip-whl python3-rados python3-venv && apt-get clean + +# Generate virtualenv including system packages with simlinks +RUN /usr/bin/python3 -m venv --system-site-packages /app/rookify/.venv + + +# Rookify +FROM base AS rookify +LABEL org.opencontainers.image.source="https://github.com/SovereignCloudStack/rookify" + +ARG ROOKIFY_VERSION=0.0.0.dev0 +ENV ROOKIFY_VERSION=$ROOKIFY_VERSION + +WORKDIR /app/rookify + +COPY --from=builder /app/rookify/dist/Rookify-${ROOKIFY_VERSION}-py3-none-any.whl ./src/ +RUN .venv/bin/pip3 install ./src/Rookify-${ROOKIFY_VERSION}-py3-none-any.whl + +# Set the ENTRYPOINT to activate the venv and then run the 'rookify' command +ENTRYPOINT [".venv/bin/rookify"] diff --git a/Makefile b/Makefile index 7086995..9a80b23 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,13 @@ RADOSLIB_VERSION := 2.0.0 GENERAL_LIB_LOCATION := $(shell pip show rados | grep -oP "(?<=Location: ).*") RADOSLIB_INSTALLED_VERSION := $(shell pip show rados | grep Version | awk '{print $$2}') +## checking if docker, or podman should be used. Podman is preferred. +ifeq ($(shell command -v podman 2> /dev/null),) + CONTAINERCMD=docker +else + CONTAINERCMD=podman +endif + .PHONY: help help: ## Display this help message @echo -e '${COLOUR_RED}Usage: make ${COLOUR_END}' @@ -56,7 +63,7 @@ run-local-rookify: ## Runs rookify in the local development environment (require source ./.venv/bin/activate && \ cd src && python3 -m rookify -download-ceph-folder-from-testbed: - ssh testbed-node-0 'sudo cp -r /etc/ceph ~/ceph_configs && sudo chown -R $$USER:$$USER ~/ceph_configs' - scp -r testbed-node-0:ceph_configs ./.ceph - ssh testbed-node-0 'rm -rf ~/ceph_configs' +.PHONY: build-container +ROOKIFY_VERSION ?= 0.0.0.dev0 +build-container: ## Build container from Dockerfile, add e.g. ROOKIFY_VERSION=0.0.1 to specify the version. Default value is 0.0.0.dev0 + ${CONTAINERCMD} build --build-arg ROOKIFY_VERSION=$(ROOKIFY_VERSION) -t rookify:latest -f Dockerfile . diff --git a/README.md b/README.md index 7c04972..d2499a9 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,10 @@ cd rookify make setup ``` -4. __TODO:__ Install script for container-based setup +4. To install the container-based environment +```base +make build-container +``` ## Usage __TODO__ diff --git a/setup.py b/setup.py index 7896859..c4f7656 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ def get_version() -> str: :since: v0.0.1 """ - return os.environ.get("ROOKIFY_VERSION", "0.0.0-dev") + return os.environ.get("ROOKIFY_VERSION", "0.0.0.dev0") _setup: Dict[str, Any] = {