Isolate clean deployment drill images

This commit is contained in:
SimpleTest 2026-07-23 22:56:41 +03:00
parent 6030c75288
commit 71510a2ab4
3 changed files with 71 additions and 11 deletions

View File

@ -1,4 +1,13 @@
services:
docker-api-proxy:
image: ${PORTABILITY_SOCKET_PROXY_IMAGE:?Set PORTABILITY_SOCKET_PROXY_IMAGE for the isolated portability drill}
proxy:
image: ${PORTABILITY_TRAEFIK_IMAGE:?Set PORTABILITY_TRAEFIK_IMAGE for the isolated portability drill}
db:
image: ${PORTABILITY_POSTGIS_IMAGE:?Set PORTABILITY_POSTGIS_IMAGE for the isolated portability drill}
migrate:
image: ${PORTABILITY_IMAGE:?Set PORTABILITY_IMAGE for the isolated portability drill}
pull_policy: never

View File

@ -16,12 +16,16 @@ run_id="$(date -u +%Y%m%d%H%M%S)-$$-$(openssl rand -hex 3)"
compact_id=${run_id//-/}
project="wnh_portability_$compact_id"
image="who-need-help:portability-$run_id"
socket_proxy_image="who-need-help:socket-proxy-portability-$run_id"
postgis_image="who-need-help:postgis-portability-$run_id"
traefik_image="who-need-help:traefik-portability-$run_id"
output_dir="$ROOT/output/portability/$run_id"
workspace=$(mktemp -d "${TMPDIR:-/tmp}/wnh-portability.$run_id.XXXXXX")
env_file="$workspace/.env"
config_valid=false
case "$project:$image:$workspace" in
wnh_portability_*:who-need-help:portability-*:"${TMPDIR:-/tmp}"/wnh-portability.*) ;;
case "$project:$image:$socket_proxy_image:$postgis_image:$traefik_image:$workspace" in
wnh_portability_*:who-need-help:portability-*:who-need-help:socket-proxy-portability-*:who-need-help:postgis-portability-*:who-need-help:traefik-portability-*:"${TMPDIR:-/tmp}"/wnh-portability.*) ;;
*)
echo "Refusing unexpected portability-drill identifiers." >&2
exit 1
@ -46,7 +50,7 @@ cleanup() {
trap - EXIT HUP INT TERM
if [[ -f "$env_file" ]]; then
if [[ -f "$env_file" && "$config_valid" == true ]]; then
if [[ "$status" -ne 0 ]]; then
"${compose[@]}" ps --all >"$output_dir/compose-ps-on-failure.txt" 2>&1 || true
"${compose[@]}" logs --no-color >"$output_dir/logs-on-failure.txt" 2>&1 || true
@ -58,12 +62,18 @@ cleanup() {
fi
fi
if docker image inspect "$image" >/dev/null 2>&1; then
if ! docker image rm "$image" >/dev/null 2>&1; then
echo "Could not remove the isolated portability image." >&2
for run_image in \
"$image" \
"$socket_proxy_image" \
"$postgis_image" \
"$traefik_image"; do
if docker image inspect "$run_image" >/dev/null 2>&1; then
if ! docker image rm "$run_image" >/dev/null 2>&1; then
echo "Could not remove the isolated portability image: $run_image" >&2
cleanup_status=1
fi
fi
done
remaining_containers=$(
docker ps --all --quiet \
@ -90,8 +100,23 @@ cleanup() {
cleanup_status=1
fi
images_remaining=false
for run_image in \
"$image" \
"$socket_proxy_image" \
"$postgis_image" \
"$traefik_image"; do
if docker image inspect "$run_image" >/dev/null 2>&1; then
images_remaining=true
fi
done
if [[ "$images_remaining" == true ]]; then
echo "One or more isolated portability images remain after cleanup." >&2
cleanup_status=1
fi
if [[ "$cleanup_status" -eq 0 ]]; then
printf 'project_resources=absent\nimage=absent\nworkspace=absent\n' \
printf 'project_resources=absent\nimages=absent\nworkspace=absent\n' \
>"$output_dir/cleanup.txt"
fi
@ -114,12 +139,22 @@ if [[ -n "$(
[[ -n "$(
docker network ls --quiet \
--filter "label=com.docker.compose.project=$project"
)" ]] ||
docker image inspect "$image" >/dev/null 2>&1; then
)" ]]; then
echo "The generated portability identifiers already exist." >&2
exit 1
fi
for run_image in \
"$image" \
"$socket_proxy_image" \
"$postgis_image" \
"$traefik_image"; do
if docker image inspect "$run_image" >/dev/null 2>&1; then
echo "The generated portability image already exists: $run_image" >&2
exit 1
fi
done
source_commit=$(git rev-parse --verify HEAD)
git archive --format=tar "$source_commit" | tar -xf - -C "$workspace"
@ -189,7 +224,13 @@ EMAIL_FROM_NAME="Who Need Help portability drill"
EMAIL_FROM_ADDRESS=portability@example.invalid
CODEX_SESSION_ID=local-portability-$run_id
RATE_LIMIT_POLICIES_JSON={}
APP_IMAGE=$image
SOCKET_PROXY_IMAGE=$socket_proxy_image
POSTGIS_IMAGE=$postgis_image
PORTABILITY_IMAGE=$image
PORTABILITY_SOCKET_PROXY_IMAGE=$socket_proxy_image
PORTABILITY_POSTGIS_IMAGE=$postgis_image
PORTABILITY_TRAEFIK_IMAGE=$traefik_image
EOF
chmod 600 "$env_file"
unset postgres_password secret_key_base handover_secret release_cookie metrics_token
@ -198,12 +239,16 @@ unset postgres_password secret_key_base handover_secret release_cookie metrics_t
printf 'source_commit=%s\n' "$source_commit"
printf 'project=%s\n' "$project"
printf 'image=%s\n' "$image"
printf 'socket_proxy_image=%s\n' "$socket_proxy_image"
printf 'postgis_image=%s\n' "$postgis_image"
printf 'traefik_image=%s\n' "$traefik_image"
docker version --format \
'docker_server={{.Server.Version}} docker_client={{.Client.Version}}'
docker compose version
} >"$output_dir/environment.txt"
"${compose[@]}" config --quiet
config_valid=true
printf 'tracked_archive_config=valid\n' >"$output_dir/config.txt"
"${compose[@]}" up --detach --wait --build

View File

@ -629,7 +629,13 @@ CPU_REPLAY_WEB_SCHEDULERS=1 \
CPU_REPLAY_WORKER_SCHEDULERS=1 \
docker compose --env-file .env.example \
-f compose.yaml -f compose.cpu-replay.yaml config --quiet
APP_IMAGE=who-need-help:portability-render \
SOCKET_PROXY_IMAGE=who-need-help:socket-proxy-portability-render \
POSTGIS_IMAGE=who-need-help:postgis-portability-render \
PORTABILITY_IMAGE=who-need-help:portability-render \
PORTABILITY_SOCKET_PROXY_IMAGE=who-need-help:socket-proxy-portability-render \
PORTABILITY_POSTGIS_IMAGE=who-need-help:postgis-portability-render \
PORTABILITY_TRAEFIK_IMAGE=who-need-help:traefik-portability-render \
docker compose --env-file .env.example \
-f compose.yaml -f compose.portability.yaml config --quiet
mkdir -p "$scan_dir/e2e-output"