Files
werkrevisor/tools/build-rootfs
mhoennigandClaude Opus 5.5 e86c88f588 werkrevisor 0.4.0: operator config from the environment, no code or data from HOME
WERKREVISOR_CONFIG_TOML carries the operator TOML in the host's machine config,
so the operator can switch model and limits without a new image;
it wins over the config file, and the usage line names the source.
werkdock on mih09 binds a home that PR builds can write, so werkrevisor
starts with python -s and PYTHONNOUSERSITE=1, refuses user site-packages and
sys.path entries under HOME, drops the working directory from sys.path,
and points HOME, XDG and litellm to private or offline settings before PR-Agent loads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 07:21:54 +02:00

27 lines
1012 B
Bash
Executable File

#!/usr/bin/env bash
# Usage: tools/build-rootfs [-h]
#
# Builds the werkrevisor image and exports its file system
# as werkrevisor-rootfs-<version>.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"