#!/usr/bin/env bash # Clone the tile-cache fixture and emit `synth-age-7mo` + `synth-age-13mo` # Docker volumes (or local directories in ``--local`` mode). # # AC-3: dates shifted by 7 mo / 13 mo ±1 day; tile pixel content # bit-identical to the source. # # Env vars: # TILE_CACHE_VOLUME_NAME Source volume (default: tile-cache-fixture) # AGE_7MO_VOLUME_NAME Output volume for 7mo (default: synth-age-7mo) # AGE_13MO_VOLUME_NAME Output volume for 13mo (default: synth-age-13mo) # # Usage: # inject.sh # Docker mode # inject.sh --local /src /out-7mo /out-13mo # local mode (unit test path) set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SOURCE_VOL="${TILE_CACHE_VOLUME_NAME:-tile-cache-fixture}" OUT_7MO_VOL="${AGE_7MO_VOLUME_NAME:-synth-age-7mo}" OUT_13MO_VOL="${AGE_13MO_VOLUME_NAME:-synth-age-13mo}" if [[ "${1:-}" == "--local" ]]; then if [[ -z "${2:-}" || -z "${3:-}" || -z "${4:-}" ]]; then echo "ERROR: --local requires " >&2 exit 2 fi python3 "${SCRIPT_DIR}/age_injector.py" \ --source-dir "$2" --output-dir "$3" --age-months 7 python3 "${SCRIPT_DIR}/age_injector.py" \ --source-dir "$2" --output-dir "$4" --age-months 13 exit 0 fi # Docker mode: reuse the tile-cache-builder image (it already has # Python + Pillow + numpy; the injector script is mounted in). IMAGE_TAG="azaion-tile-cache-builder:local" for spec in "${OUT_7MO_VOL}:7" "${OUT_13MO_VOL}:13"; do target_vol="${spec%%:*}" months="${spec##*:}" docker volume rm "${target_vol}" >/dev/null 2>&1 || true docker volume create "${target_vol}" >/dev/null docker run --rm \ -v "${SCRIPT_DIR}:/opt/injector:ro" \ -v "${SOURCE_VOL}:/source:ro" \ -v "${target_vol}:/output" \ --entrypoint python3 \ "${IMAGE_TAG}" \ /opt/injector/age_injector.py \ --source-dir /source \ --output-dir /output \ --age-months "${months}" echo "synth-age volume '${target_vol}' built (age=${months}mo)" done