diff --git a/Dockerfile b/Dockerfile index 780b236c..626066a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,60 +1,132 @@ -FROM archlinux:latest +# ------------------------------------------------------------ +# Infinito dev container (multi-distro) +# ------------------------------------------------------------ +ARG BASE_IMAGE=archlinux:latest +FROM ${BASE_IMAGE} -# 1) Pakete inkl. docker (damit docker CLI im Container vorhanden ist) -RUN pacman -Syu --noconfirm \ - base-devel \ - git \ - python \ - python-pip \ - python-setuptools \ - alsa-lib \ - go \ - rsync \ - docker \ - && pacman -Scc --noconfirm +# ------------------------------------------------------------ +# Base dependencies per distro +# - git, python, venv tooling +# - docker CLI (best-effort) +# - rsync, build tools, CA certificates +# ------------------------------------------------------------ +RUN set -e; \ + if [ -f /etc/os-release ]; then \ + . /etc/os-release; \ + else \ + echo "ERROR: /etc/os-release not found, cannot detect distro."; \ + exit 1; \ + fi; \ + echo "[infinito] Detected base distro: ${ID:-unknown}"; \ + case "${ID}" in \ + arch) \ + pacman -Syu --noconfirm \ + base-devel \ + git \ + python \ + python-pip \ + python-setuptools \ + rsync \ + alsa-lib \ + go \ + docker \ + curl \ + ca-certificates; \ + pacman -Scc --noconfirm; \ + # Ensure python3 exists (Arch only ships 'python' by default) \ + if [ ! -x /usr/bin/python3 ]; then \ + ln -sf /usr/bin/python /usr/bin/python3; \ + fi; \ + # Stub systemctl and yay to avoid side effects in containers \ + printf '#!/bin/sh\nexit 0\n' > /usr/bin/systemctl; \ + chmod +x /usr/bin/systemctl; \ + printf '#!/bin/sh\nexit 0\n' > /usr/bin/yay; \ + chmod +x /usr/bin/yay; \ + ;; \ + debian|ubuntu) \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + build-essential \ + git \ + python3 \ + python3-venv \ + python3-pip \ + python3-setuptools \ + rsync \ + libasound2 \ + docker.io \ + curl \ + ca-certificates; \ + rm -rf /var/lib/apt/lists/*; \ + ;; \ + fedora|rhel|centos) \ + dnf -y update; \ + dnf -y install \ + git \ + python3 \ + python3-pip \ + python3-setuptools \ + make \ + gcc \ + rsync \ + alsa-lib \ + docker \ + curl \ + ca-certificates \ + xz; \ + dnf clean all; \ + ;; \ + *) \ + echo "ERROR: Unsupported base distro '${ID}'."; \ + exit 1; \ + ;; \ + esac -# 2) systemctl & yay stubben -RUN printf '#!/bin/sh\nexit 0\n' > /usr/bin/systemctl \ - && chmod +x /usr/bin/systemctl \ - && printf '#!/bin/sh\nexit 0\n' > /usr/bin/yay \ - && chmod +x /usr/bin/yay - -# 3) python-simpleaudio aus AUR -RUN useradd -m aur_builder \ - && su aur_builder -c "git clone https://aur.archlinux.org/python-simpleaudio.git /home/aur_builder/psa && \ - cd /home/aur_builder/psa && \ - makepkg --noconfirm --skippgpcheck" \ - && pacman -U --noconfirm /home/aur_builder/psa/*.pkg.tar.zst \ - && rm -rf /home/aur_builder/psa - -# 4) pkgmgr + venv +# ------------------------------------------------------------ +# pkgmgr via Python venv (distro-agnostic) +# ------------------------------------------------------------ ENV PKGMGR_REPO=/opt/package-manager \ PKGMGR_VENV=/root/.venvs/pkgmgr -RUN git clone https://github.com/kevinveenbirkenbach/package-manager.git $PKGMGR_REPO \ - && python -m venv $PKGMGR_VENV \ - && $PKGMGR_VENV/bin/pip install --upgrade pip \ - && $PKGMGR_VENV/bin/pip install --no-cache-dir -r $PKGMGR_REPO/requirements.txt ansible \ +RUN git clone https://github.com/kevinveenbirkenbach/package-manager.git "$PKGMGR_REPO" \ + && python3 -m venv "$PKGMGR_VENV" \ + && "$PKGMGR_VENV/bin/pip" install --upgrade pip \ + && "$PKGMGR_VENV/bin/pip" install --no-cache-dir \ + -r "$PKGMGR_REPO/requirements.txt" \ + ansible \ + simpleaudio \ && printf '#!/bin/sh\n. %s/bin/activate\nexec python %s/main.py "$@"\n' \ "$PKGMGR_VENV" "$PKGMGR_REPO" > /usr/local/bin/pkgmgr \ && chmod +x /usr/local/bin/pkgmgr ENV PATH="$PKGMGR_VENV/bin:/root/.local/bin:${PATH}" -# 6) Infinito.Nexus Quelle rein +# ------------------------------------------------------------ +# Copy local Infinito source into the image +# ------------------------------------------------------------ COPY . /opt/infinito-src -# 7) Infinito via pkgmgr (shallow) +# ------------------------------------------------------------ +# Install Infinito via pkgmgr (shallow clone) +# ------------------------------------------------------------ RUN pkgmgr install infinito --clone-mode shallow -# 8) Override mit lokaler Quelle -RUN INFINITO_PATH=$(pkgmgr path infinito) && \ - rm -rf "$INFINITO_PATH"/* && \ - rsync -a --delete --exclude='.git' /opt/infinito-src/ "$INFINITO_PATH"/ +# ------------------------------------------------------------ +# Override installed Infinito with local source +# (keeps pkgmgr metadata, but code comes from /opt/infinito-src) +# ------------------------------------------------------------ +RUN INFINITO_PATH="$(pkgmgr path infinito)" && \ + rm -rf "${INFINITO_PATH:?}"/* && \ + rsync -a --delete --exclude='.git' /opt/infinito-src/ "${INFINITO_PATH}/" -# 9) Symlink -RUN INFINITO_PATH=$(pkgmgr path infinito) && \ - ln -sf "$INFINITO_PATH"/main.py /usr/local/bin/infinito && \ +# ------------------------------------------------------------ +# Symlink infinito CLI into PATH +# ------------------------------------------------------------ +RUN INFINITO_PATH="$(pkgmgr path infinito)" && \ + ln -sf "${INFINITO_PATH}/main.py" /usr/local/bin/infinito && \ chmod +x /usr/local/bin/infinito +# ------------------------------------------------------------ +# Default command: show help and keep container running +# ------------------------------------------------------------ CMD sh -c "infinito --help && exec tail -f /dev/null" diff --git a/Makefile b/Makefile index 08d576a0..d200c45c 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,24 @@ +# ------------------------------------------------------------ +# Multi-distro Docker build configuration (similar to pkgmgr) +# ------------------------------------------------------------ +DISTROS := arch debian ubuntu fedora centos +BASE_IMAGE_ARCH := archlinux:latest +BASE_IMAGE_DEBIAN := debian:stable-slim +BASE_IMAGE_UBUNTU := ubuntu:latest +BASE_IMAGE_FEDORA := fedora:latest +BASE_IMAGE_CENTOS := quay.io/centos/centos:stream9 + +# Make them available to scripts (if you later add resolve-base-image.sh, etc.) +export DISTROS +export BASE_IMAGE_ARCH +export BASE_IMAGE_DEBIAN +export BASE_IMAGE_UBUNTU +export BASE_IMAGE_FEDORA +export BASE_IMAGE_CENTOS + +# ------------------------------------------------------------ +# Infinito roles/config generation +# ------------------------------------------------------------ ROLES_DIR := ./roles APPLICATIONS_OUT := ./group_vars/all/04_applications.yml APPLICATIONS_SCRIPT := ./cli/build/defaults/applications.py @@ -19,31 +40,36 @@ RESERVED_USERNAMES := $(shell \ | paste -sd, - \ ) -.PHONY: build install test +.PHONY: build install test clean clean-keep-logs list tree mig dockerignore \ + messy-build messy-test \ + docker-build docker-build-no-cache +# ------------------------------------------------------------ +# Core project targets +# ------------------------------------------------------------ clean-keep-logs: @echo "🧹 Cleaning ignored files but keeping logs/…" git clean -fdX -- ':!logs' ':!logs/**' clean: - @echo "Removing ignored git files" + @echo "🧹 Removing ignored git files…" git clean -fdX list: - @echo Generating the roles list + @echo "📦 Generating the roles list…" python3 main.py build roles_list tree: - @echo Generating Tree + @echo "🌳 Generating roles tree…" python3 main.py build tree -D 2 --no-signal mig: list tree - @echo Creating meta data for meta infinity graph + @echo "🔗 Creating meta data for meta infinity graph…" dockerignore: - @echo Create dockerignore + @echo "📝 Creating .dockerignore from .gitignore…" cat .gitignore > .dockerignore - echo ".git" >> .dockerignore + echo ".git" >> .dockerignore messy-build: dockerignore @echo "🔧 Generating users defaults → $(USERS_OUT)…" @@ -69,7 +95,7 @@ messy-build: dockerignore echo " ✅ $$out"; \ ) -messy-test: +messy-test: @echo "🧪 Running Python tests…" PYTHONPATH=. python -m unittest discover -s tests @echo "📑 Checking Ansible syntax…" @@ -79,7 +105,60 @@ install: build @echo "⚙️ Install complete." build: clean messy-build - @echo "Full build with cleanup before was executed." + @echo "✅ Full build (with cleanup) finished." test: build messy-test - @echo "Full test with build before was executed." + @echo "✅ Full test (with build) finished." + +# ------------------------------------------------------------ +# Docker: multi-distro dev containers for Infinito +# Uses the multi-distro Dockerfile with ARG BASE_IMAGE +# ------------------------------------------------------------ + +# Helper to map distro → BASE_IMAGE_* variable +define _infinito_base_image +$(if $(filter $(1),arch),$(BASE_IMAGE_ARCH),\ +$(if $(filter $(1),debian),$(BASE_IMAGE_DEBIAN),\ +$(if $(filter $(1),ubuntu),$(BASE_IMAGE_UBUNTU),\ +$(if $(filter $(1),fedora),$(BASE_IMAGE_FEDORA),\ +$(if $(filter $(1),centos),$(BASE_IMAGE_CENTOS),))))) +endef + +docker-build: + @echo "============================================================" + @echo ">>> Building Infinito dev containers for: $(DISTROS)" + @echo "============================================================" + @for distro in $(DISTROS); do \ + base_image="$(call _infinito_base_image,$$distro)"; \ + image_name="infinito-dev-$$distro"; \ + echo; \ + echo "------------------------------------------------------------"; \ + echo ">>> Building $$image_name (BASE_IMAGE=$$base_image)…"; \ + echo "------------------------------------------------------------"; \ + docker build \ + --build-arg BASE_IMAGE="$$base_image" \ + -t "$$image_name" \ + . || exit $$?; \ + done + @echo + @echo "✅ All Infinito dev images built." + +docker-build-no-cache: + @echo "============================================================" + @echo ">>> Building Infinito dev containers (NO CACHE) for: $(DISTROS)" + @echo "============================================================" + @for distro in $(DISTROS); do \ + base_image="$(call _infinito_base_image,$$distro)"; \ + image_name="infinito-dev-$$distro"; \ + echo; \ + echo "------------------------------------------------------------"; \ + echo ">>> Building $$image_name with NO CACHE (BASE_IMAGE=$$base_image)…"; \ + echo "------------------------------------------------------------"; \ + docker build \ + --no-cache \ + --build-arg BASE_IMAGE="$$base_image" \ + -t "$$image_name" \ + . || exit $$?; \ + done + @echo + @echo "✅ All Infinito dev images built (no cache)."