feat(deploy): pin the demo seed in release manifests and restore the demo stand from them

This commit is contained in:
shira committed 2026-10-09 14:59:06 +03:00
1 parent e1df4ff77c
commit b768f7e53f
14 files changed
+789 -147

No files matched your search

+36 -3
View File
@@ -25,12 +25,17 @@
# DEMO_PUBLIC_URL public origin of the demo stand
# DEMO_SUBNET, DEMO_FRONTEND_IP pinned network of the demo project
# DEMO_ACTOR operator:<handle> that the seed records
# DEMO_RELEASE_MANIFEST optional repository-relative release manifest; seed
# and reset then start and seed the stand from the exact
# image IDs and digests it records, without building or
# pulling, and check the running images against it
# DOCKER docker CLI
set -euo pipefail
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)
compose_file="$root/deploy/docker/docker-compose.yml"
demo_file="$root/deploy/docker/docker-compose.demo.yml"
release_script="$root/deploy/scripts/release_manifest.py"
docker_cli="${DOCKER:-docker}"
demo_label='org.lincodex.demo-mode'
ready_attempts=120
@@ -72,6 +77,11 @@ port="${DEMO_HTTP_PORT:-8090}"
public_url="${DEMO_PUBLIC_URL:-http://localhost:$port}"
subnet="${DEMO_SUBNET:-172.29.84.0/24}"
frontend_ip="${DEMO_FRONTEND_IP:-172.29.84.10}"
release_manifest="${DEMO_RELEASE_MANIFEST:-}"
compose_files=(-f "$compose_file" -f "$demo_file")
# From the current sources by default; pinned by the release override below.
up_args=(--build)
run_args=(--build)
# The shell values override the env files, so the root .env cannot point the
# demo project at the ordinary project's names, network, or port.
@@ -80,7 +90,7 @@ compose() {
APP_HTTP_PORT="$port" APP_SUBNET="$subnet" APP_FRONTEND_IP="$frontend_ip" APP_PUBLIC_URL="$public_url" \
DEMO_MODE=isolated "$docker_cli" compose \
--env-file "$env_file" --env-file "$demo_env_file" \
-p "$project" -f "$compose_file" -f "$demo_file" "$@"
-p "$project" "${compose_files[@]}" "$@"
}
volume_exists() {
@@ -101,12 +111,32 @@ check_volumes() {
done
}
# The release script pins every service of the stand, the seed included, to
# the image IDs and digests of the manifest after checking that the Compose
# files and data artifacts still match it. The override lives in a private
# temporary directory for this run only.
pin_release_images() {
override_dir=$(mktemp -d)
trap 'rm -rf "$override_dir"' EXIT
DOCKER="$docker_cli" PYTHONDONTWRITEBYTECODE=1 python3 "$release_script" demo-override \
--manifest "$release_manifest" --output-dir "$override_dir" ||
fail "refusing to $action: the release manifest $release_manifest cannot be restored on the demo stand"
compose_files+=(-f "$override_dir/release-restore.yml")
up_args=(--no-build --pull never)
run_args=()
}
start_stand() {
compose up -d --build --wait --wait-timeout 300
compose up -d "${up_args[@]}" --wait --wait-timeout 300
local attempt response
for ((attempt = 1; attempt <= ready_attempts; attempt++)); do
response=$(compose exec -T frontend wget -q -O - http://backend:8080/readyz 2>/dev/null || true)
if [[ "$response" == '{"status":"ready"}' ]]; then
if [[ -n "$release_manifest" ]]; then
DOCKER="$docker_cli" PYTHONDONTWRITEBYTECODE=1 python3 "$release_script" verify \
--project "$project" --manifest "$release_manifest" ||
fail "the running images of $project differ from $release_manifest"
fi
return 0
fi
sleep 1
@@ -115,7 +145,7 @@ start_stand() {
}
run_command() {
compose --profile demo-seed run --rm --build demo-seed "$@"
compose --profile demo-seed run --rm ${run_args[@]+"${run_args[@]}"} demo-seed "$@"
}
# The inventory after the seed lets two runs be compared line by line.
@@ -128,6 +158,9 @@ seed() {
}
check_volumes
if [[ -n "$release_manifest" && "$action" != down ]]; then
pin_release_images
fi
case "$action" in
seed)
seed