Files
computer-playbook/scripts/system/cache/clean.sh
T
kevinveenbirkenbachandClaude Opus 4.7 9a578952c3 feat(env): SPOT env-pipeline + INFINITO_* namespace
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>
2026-05-20 20:40:34 +02:00

71 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# shellcheck shell=bash
#
# Wipe the on-disk caches that the `cache` compose profile populates:
# the rpardini/docker-registry-proxy mirror + MITM CA, and the
# Sonatype Nexus 3 OSS data dir. Both live under /var/cache/infinito/
# core/<service>/ by default; the per-cache env scripts under
# scripts/meta/env/cache/ are sourced first so a custom HOST_PATH
# from the developer's environment is honoured.
#
# Removing the directories is enough: docker compose recreates them
# on the next `up` thanks to `bind: { create_host_path: true }`. For
# the Nexus side, the next bootstrap rotates a fresh admin password
# and re-creates blobstore + proxy repos.
#
# Use `make cache-clean` rather than calling this script directly.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../.." && pwd)"
cd "${REPO_ROOT}"
# shellcheck source=scripts/meta/env/load.sh
source "scripts/meta/env/load.sh"
# shellcheck source=scripts/meta/env/load.sh
source "scripts/meta/env/load.sh"
# Stop any running cache containers first so wipe is safe (a running
# Nexus would re-create files mid-rm). `docker compose down` of the
# whole stack would also kill the runner, which is too destructive;
# scope to the two cache services explicitly.
if docker ps --format '{{.Names}}' | grep -qE '^infinito-(registry|package)-cache$'; then
echo "[cache-clean] stopping infinito-registry-cache + infinito-package-cache"
docker stop infinito-registry-cache infinito-package-cache 2>/dev/null || true
docker rm infinito-registry-cache infinito-package-cache 2>/dev/null || true
fi
PATHS=(
"${INFINITO_REGISTRY_CACHE_HOST_PATH}"
"${INFINITO_REGISTRY_CACHE_CA_HOST_PATH}"
"${INFINITO_PACKAGE_CACHE_HOST_PATH}"
)
# Remove each cache path individually (keeps the parent /var/cache/
# infinito/ dir alive so other future cache services can co-locate).
# Use sudo when the path is root-owned (Nexus chowns its data dir to
# uid 200 for the in-container nexus user) so the rm does not silently
# leave half-deleted state behind.
remove_path() {
local p="$1"
[[ -z "${p}" ]] && return 0
if [[ ! -e "${p}" ]]; then
echo "[cache-clean] not present, skipping: ${p}"
return 0
fi
if [[ -w "${p}" ]] || [[ -O "${p}" ]]; then
echo "[cache-clean] removing: ${p}"
rm -rf -- "${p}"
else
echo "[cache-clean] removing (sudo): ${p}"
sudo rm -rf -- "${p}"
fi
}
remove_path "${PATHS[0]}"
remove_path "${PATHS[1]}"
remove_path "${PATHS[2]}"
echo "[cache-clean] done. Re-run 'make up' to recreate empty caches."