Files
computer-playbook/Dockerfile
T
kevinveenbirkenbachandClaude Opus 4.7 b278cd8ccd refactor(entry.sh): switch INFINITO_COMPILE{,_SILENCE} env-vars to flags
scripts/docker/entry.sh's two compile-control reads (INFINITO_COMPILE
and INFINITO_COMPILE_SILENCE) crashed during Dockerfile RUN because
that context has no env-pipeline: env/default.env exists in the repo
but no make/BASH_ENV/load.sh chain materialises it into the running
shell. The bare reads under `set -u` triggered unbound-variable exit
even though the keys were registered in default.env + passthrough.

Move build/silence control from env to script flags so entry.sh is
self-contained at bootstrap time. Each flag now triggers its action
directly inside the parse loop -- no COMPILE/SILENCE state vars:

    --compile         -> run_local_build (streaming)
    --compile-silent  -> run_local_build >/dev/null 2>&1
    --                -> end flag parsing, rest is the exec target

Drop INFINITO_COMPILE + INFINITO_COMPILE_SILENCE from the whole
registry surface: env/default.env, passthrough.STATIC_KEYS, the
infinito_compile handler (gone entirely), compose.yml's env
injection block, the dotenv-generator baseline test, the
build_env unit-test fixture, and the now-no-op `-e INFINITO_COMPILE=0`
in test-install-{make,pkgmgr} workflows.

Dockerfile RUN switches to `entry.sh --compile -- true`; runtime
ENTRYPOINT receives no flags so the default (no-compile) holds and
exec hands off to systemd via the CMD.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 23:25:39 +02:00

90 lines
3.3 KiB
Docker

# syntax=docker/dockerfile:1
# Base image (pkgmgr) selector
# Example:
# PKGMGR_IMAGE=ghcr.io/kevinveenbirkenbach/pkgmgr-arch:stable
# PKGMGR_IMAGE=ghcr.io/kevinveenbirkenbach/pkgmgr-arch-slim:stable
ARG PKGMGR_IMAGE=ghcr.io/kevinveenbirkenbach/pkgmgr-arch:stable
FROM ${PKGMGR_IMAGE} AS full
# Hadolint DL4006: ensure pipefail is set for RUN instructions that use pipes
SHELL ["/bin/bash", "-o", "pipefail", "-lc"]
# Forwardable build-time Nix settings (e.g., GitHub access tokens to avoid rate limits)
ARG NIX_CONFIG
ENV INFINITO_SRC_DIR="/opt/src/infinito"
ENV PYTHON="/opt/venvs/infinito/bin/python"
ENV PIP="/opt/venvs/infinito/bin/python -m pip"
ENV PATH="/opt/venvs/infinito/bin:${PATH}"
# Make Nix non-interactive for flake config (CI-friendly)
RUN set -euo pipefail; \
cat /etc/os-release || true; \
if [ -f /etc/nix/nix.conf ]; then \
grep -q '^accept-flake-config *= *true' /etc/nix/nix.conf || \
echo 'accept-flake-config = true' >> /etc/nix/nix.conf; \
fi
# ------------------------------------------------------------
# Infinito.Nexus source in
# ------------------------------------------------------------
COPY . ${INFINITO_SRC_DIR}
# ------------------------------------------------------------
# Install Python 3.11+, Docker CLI, and distro package dependencies
# ------------------------------------------------------------
# hadolint ignore=DL3008,DL3033,DL3041
RUN set -euo pipefail; \
/bin/bash ${INFINITO_SRC_DIR}/roles/dev-python/files/install.sh; \
/bin/bash ${INFINITO_SRC_DIR}/roles/sys-svc-container/files/install-cli.sh; \
/bin/bash ${INFINITO_SRC_DIR}/scripts/install/package.sh
# ------------------------------------------------------------
# Disable interactive first-boot units (CI / container safe)
# ------------------------------------------------------------
RUN set -euo pipefail; \
systemctl mask systemd-firstboot.service first-boot-complete.target || true; \
systemd-machine-id-setup || true
# systemd-in-container conventions
ENV container=docker
STOPSIGNAL SIGRTMIN+3
# ------------------------------------------------------------
# Install infinito via pkgmgr (shallow) and override it with local source
# ------------------------------------------------------------
RUN set -euo pipefail; \
export NIX_CONFIG="${NIX_CONFIG:-}"; \
echo "[docker-infinito] Install Infinito.Nexus via pkgmgr"; \
pkgmgr install infinito --clone-mode shallow; \
echo "[docker-infinito] Installed Infinito.Nexus Version:"; \
pkgmgr version infinito; \
/opt/src/infinito/scripts/docker/entry.sh --compile -- true
# Set workdir to / to avoid ambiguous commands
WORKDIR /
COPY scripts/docker/healthcheck.sh /usr/local/bin/healthcheck.sh
RUN chmod +x /usr/local/bin/healthcheck.sh
# Allow 20s because `infinito --help` can exceed 5s on fresh CI runners.
HEALTHCHECK --interval=5s --timeout=20s --start-period=30s --retries=20 \
CMD /usr/local/bin/healthcheck.sh
ENTRYPOINT ["/opt/src/infinito/scripts/docker/entry.sh"]
# IMPORTANT: default to systemd as PID 1
CMD ["/sbin/init"]
# ============================================================
# Target: slim
# - based on full, runs slim.sh
# ============================================================
FROM full AS slim
# Image cleanup (reduce final size)
RUN set -eu; \
test -x /usr/local/bin/slim.sh || { echo "slim.sh missing in base image" >&2; exit 1; }; \
/usr/local/bin/slim.sh