#!/usr/bin/env bash # Usage: tools/build-rootfs [-h] # # Builds the werkrevisor image and exports its file system # as werkrevisor-rootfs-.tar.zst for hosts without Docker (werkdock). # Run it from the repository root. # The archive does not keep image metadata; run it with # PATH=/app/.venv/bin:/usr/local/bin:/usr/bin:/bin PYTHONPATH=/werkrevisor:/app PYTHONNOUSERSITE=1 python -s -m werkrevisor set -euo pipefail if [[ "${1:-}" =~ ^(-h|-\?|--help)$ ]]; then awk 'NR > 1 && /^#/ { sub(/^# ?/, ""); print; next } NR > 1 { exit }' "$0" exit 0 fi version=$(sed -n 's/^__version__ = "\(.*\)"$/\1/p' werkrevisor/__init__.py) image="werkrevisor:${version}" archive="werkrevisor-rootfs-${version}.tar.zst" docker build --pull=false -t "$image" . container=$(docker create "$image") trap 'docker rm -f "$container" >/dev/null' EXIT docker export "$container" | zstd -q -T0 -10 -f -o "$archive" echo "image: $image" echo "archive: $archive ($(du -h "$archive" | cut -f1))" sha256sum "$archive"