#!/usr/bin/bash # Extracts the handful of static files (changes.txt, resources.json, # dummy-captcha.png, robots.txt) that live in the `server` repo's own # `public/` directory out of the currently-pulled `server` image, into # ./data/public-static, which caddy serves as its fallback root. # # This is the single source of truth for these files: they're edited as # normal server-repo changes and simply ride along with the next deploy of # that image -- nothing in this repo should ever hand-edit them again. # # Run by deploy.sh between `docker compose pull` and `docker compose up`. # Safe to re-run standalone at any time (e.g. to recover a host where # ./data/public-static is missing/empty without doing a full deploy). set -euo pipefail cd "$(dirname "$0")" STATIC_FILES=(changes.txt resources.json dummy-captcha.png robots.txt) DEST=./data/public-static # Note - we need to update this if the server's image name ever changes image="atcr.io/tlecommunity.com/server:latest" echo "==> Extracting static files from ${image}" mkdir -p "$DEST" container_id="$(sudo docker create "$image")" trap 'sudo docker rm -f "$container_id" >/dev/null' EXIT for file in "${STATIC_FILES[@]}"; do sudo docker cp "$container_id:/home/lacuna/server/public/$file" "$DEST/$file" done echo "==> Refreshed $DEST: ${STATIC_FILES[*]}"