mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-08 03:38:23 +00:00
Replace 8 bash env modules with a single Python generator
(cli.meta.env) that materialises env/static.env + runtime context
into a gitignored .env. Each variable lives in its own handler
under utils/env/handlers/; defaults carry inline one-line `# ...`
comments.
Rename to the INFINITO_* schema:
- workflow inputs: APPS, SERVICES_DISABLED, CMD, DEBUG, WHITELIST,
BUNDLES, FULL_CYCLE, VARIANT, RUN_FLAGS, LIMIT_HOST, PARALLEL
- inventory: INVENTORY_DIR / INVENTORY_FILE / HOST_VARS_FILE,
PW_FILE -> INVENTORY_PASSWORD_FILE
- venv: VENV_BASE / VENV_FALLBACK / VENV_NAME
- new SPOT defaults: COMPILE_SILENCE, CONTAINER_NO_CA,
WAIT_HEALTH_TIMEOUT_S, PACKAGE_CACHE_FRONTEND_INIT_IMAGE,
promoted IMAGE_TAG from GHA-only to general passthrough
compose.yml hardening:
- inline \${VAR:-default} removed; strict \${VAR:?...} everywhere
- new integration lint blocks regressions
Tooling:
- scripts/install/all.sh owns the stamp-file install logic
(Makefile target delegates)
- scripts/meta/env/load.sh is the single shell entry point;
8 bash modules deleted
- new shell lint: no INFINITO_* defaults outside env/static.env
Tests:
- 93 new unit tests for utils/env/{builder,parser,runtime,writer}
- restructure tests/lint into repository/ (file-content rules) vs
filesystem/{shell,python,env}/ (filesystem-shape rules)
- drift + smoke integration tests against the generator
Docs:
- variables.md is now a pointer; per-variable docs live next to
the key in env/static.env / env/ci.env
- compose.yml.md drops the Default column
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
82 lines
2.9 KiB
Bash
Executable File
82 lines
2.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Wrapper to run a one-off `docker run` INSIDE the infinito host container
|
|
# (which already provides nested Docker-in-Docker). Used for inner-loop
|
|
# debugging where you need to spin up a sidecar image (e.g. the Playwright
|
|
# runner) against the same docker daemon the deployed stack lives on,
|
|
# without re-running an Ansible playbook.
|
|
#
|
|
# Required env:
|
|
# IMAGE Image reference passed to `docker run` (e.g. alpine,
|
|
# mcr.microsoft.com/playwright:v1.59.1-noble)
|
|
#
|
|
# Optional env:
|
|
# INFINITO_CMD Command to execute inside the sidecar container.
|
|
# When omitted, the image's default entrypoint runs.
|
|
# INFINITO_RUN_FLAGS Extra flags forwarded verbatim to `docker run`
|
|
# (e.g. "--env-file /tmp/x.env -v /tmp/y:/y -w /e2e").
|
|
# INFINITO_DISTRO arch|debian|ubuntu|fedora|centos — selects which
|
|
# infinito host container we exec into.
|
|
# INFINITO_CONTAINER Optional explicit override of the host container name.
|
|
#
|
|
# Examples:
|
|
# IMAGE=alpine make run
|
|
# IMAGE=alpine INFINITO_CMD='env | grep PATH' make run
|
|
# IMAGE=mcr.microsoft.com/playwright:v1.59.1-noble \
|
|
# INFINITO_RUN_FLAGS='--env-file /tmp/test-e2e-playwright/web-app-friendica/.env \
|
|
# -v /tmp/test-e2e-playwright/web-app-friendica:/e2e -w /e2e' \
|
|
# INFINITO_CMD='npx playwright test --grep dashboard' \
|
|
# make run
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../../../../" && pwd)"
|
|
|
|
usage() {
|
|
cat <<EOF
|
|
Usage:
|
|
IMAGE=<ref> [INFINITO_CMD='<shell>'] [INFINITO_RUN_FLAGS='<flags>'] ${0}
|
|
|
|
Examples:
|
|
IMAGE=alpine ${0}
|
|
IMAGE=alpine INFINITO_CMD='env' ${0}
|
|
IMAGE=mcr.microsoft.com/playwright:v1.59.1-noble \\
|
|
INFINITO_RUN_FLAGS='--env-file /tmp/.env -v /tmp/proj:/e2e -w /e2e' \\
|
|
INFINITO_CMD='npx playwright test' \\
|
|
${0}
|
|
EOF
|
|
}
|
|
|
|
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
|
|
usage
|
|
exit 0
|
|
fi
|
|
|
|
: "${IMAGE:?IMAGE must be set (e.g. IMAGE=alpine)}"
|
|
|
|
cd "${REPO_ROOT}"
|
|
# shellcheck source=scripts/meta/env/load.sh
|
|
source "scripts/meta/env/load.sh"
|
|
: "${INFINITO_CONTAINER:?INFINITO_CONTAINER not set after sourcing scripts/meta/env/load.sh}"
|
|
|
|
# Build the nested `docker run` argv. Splitting INFINITO_RUN_FLAGS on whitespace is
|
|
# intentional — same UX as INFINITO_RUN_FLAGS in any other Make wrapper. Callers that
|
|
# need single args containing spaces should pass them via the image entry-
|
|
# point (-e VAR='spaced value' arrives intact because docker parses -e).
|
|
docker_run_argv=(docker run --rm)
|
|
if [[ -n "${INFINITO_RUN_FLAGS:-}" ]]; then
|
|
# shellcheck disable=SC2206
|
|
docker_run_argv+=(${INFINITO_RUN_FLAGS})
|
|
fi
|
|
docker_run_argv+=("${IMAGE}")
|
|
if [[ -n "${INFINITO_CMD:-}" ]]; then
|
|
docker_run_argv+=(sh -lc "${INFINITO_CMD}")
|
|
fi
|
|
|
|
exec_flags=(-i)
|
|
if [[ -t 0 && -t 1 ]]; then
|
|
exec_flags=(-it)
|
|
fi
|
|
|
|
exec docker exec "${exec_flags[@]}" "${INFINITO_CONTAINER}" "${docker_run_argv[@]}"
|