Isolate clean deployment drill images
This commit is contained in:
parent
6030c75288
commit
71510a2ab4
|
|
@ -1,4 +1,13 @@
|
||||||
services:
|
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:
|
migrate:
|
||||||
image: ${PORTABILITY_IMAGE:?Set PORTABILITY_IMAGE for the isolated portability drill}
|
image: ${PORTABILITY_IMAGE:?Set PORTABILITY_IMAGE for the isolated portability drill}
|
||||||
pull_policy: never
|
pull_policy: never
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,16 @@ run_id="$(date -u +%Y%m%d%H%M%S)-$$-$(openssl rand -hex 3)"
|
||||||
compact_id=${run_id//-/}
|
compact_id=${run_id//-/}
|
||||||
project="wnh_portability_$compact_id"
|
project="wnh_portability_$compact_id"
|
||||||
image="who-need-help:portability-$run_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"
|
output_dir="$ROOT/output/portability/$run_id"
|
||||||
workspace=$(mktemp -d "${TMPDIR:-/tmp}/wnh-portability.$run_id.XXXXXX")
|
workspace=$(mktemp -d "${TMPDIR:-/tmp}/wnh-portability.$run_id.XXXXXX")
|
||||||
env_file="$workspace/.env"
|
env_file="$workspace/.env"
|
||||||
|
config_valid=false
|
||||||
|
|
||||||
case "$project:$image:$workspace" in
|
case "$project:$image:$socket_proxy_image:$postgis_image:$traefik_image:$workspace" in
|
||||||
wnh_portability_*:who-need-help:portability-*:"${TMPDIR:-/tmp}"/wnh-portability.*) ;;
|
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
|
echo "Refusing unexpected portability-drill identifiers." >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -46,7 +50,7 @@ cleanup() {
|
||||||
|
|
||||||
trap - EXIT HUP INT TERM
|
trap - EXIT HUP INT TERM
|
||||||
|
|
||||||
if [[ -f "$env_file" ]]; then
|
if [[ -f "$env_file" && "$config_valid" == true ]]; then
|
||||||
if [[ "$status" -ne 0 ]]; then
|
if [[ "$status" -ne 0 ]]; then
|
||||||
"${compose[@]}" ps --all >"$output_dir/compose-ps-on-failure.txt" 2>&1 || true
|
"${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
|
"${compose[@]}" logs --no-color >"$output_dir/logs-on-failure.txt" 2>&1 || true
|
||||||
|
|
@ -58,12 +62,18 @@ cleanup() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if docker image inspect "$image" >/dev/null 2>&1; then
|
for run_image in \
|
||||||
if ! docker image rm "$image" >/dev/null 2>&1; then
|
"$image" \
|
||||||
echo "Could not remove the isolated portability image." >&2
|
"$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
|
cleanup_status=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
remaining_containers=$(
|
remaining_containers=$(
|
||||||
docker ps --all --quiet \
|
docker ps --all --quiet \
|
||||||
|
|
@ -90,8 +100,23 @@ cleanup() {
|
||||||
cleanup_status=1
|
cleanup_status=1
|
||||||
fi
|
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
|
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"
|
>"$output_dir/cleanup.txt"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -114,12 +139,22 @@ if [[ -n "$(
|
||||||
[[ -n "$(
|
[[ -n "$(
|
||||||
docker network ls --quiet \
|
docker network ls --quiet \
|
||||||
--filter "label=com.docker.compose.project=$project"
|
--filter "label=com.docker.compose.project=$project"
|
||||||
)" ]] ||
|
)" ]]; then
|
||||||
docker image inspect "$image" >/dev/null 2>&1; then
|
|
||||||
echo "The generated portability identifiers already exist." >&2
|
echo "The generated portability identifiers already exist." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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)
|
source_commit=$(git rev-parse --verify HEAD)
|
||||||
git archive --format=tar "$source_commit" | tar -xf - -C "$workspace"
|
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
|
EMAIL_FROM_ADDRESS=portability@example.invalid
|
||||||
CODEX_SESSION_ID=local-portability-$run_id
|
CODEX_SESSION_ID=local-portability-$run_id
|
||||||
RATE_LIMIT_POLICIES_JSON={}
|
RATE_LIMIT_POLICIES_JSON={}
|
||||||
|
APP_IMAGE=$image
|
||||||
|
SOCKET_PROXY_IMAGE=$socket_proxy_image
|
||||||
|
POSTGIS_IMAGE=$postgis_image
|
||||||
PORTABILITY_IMAGE=$image
|
PORTABILITY_IMAGE=$image
|
||||||
|
PORTABILITY_SOCKET_PROXY_IMAGE=$socket_proxy_image
|
||||||
|
PORTABILITY_POSTGIS_IMAGE=$postgis_image
|
||||||
|
PORTABILITY_TRAEFIK_IMAGE=$traefik_image
|
||||||
EOF
|
EOF
|
||||||
chmod 600 "$env_file"
|
chmod 600 "$env_file"
|
||||||
unset postgres_password secret_key_base handover_secret release_cookie metrics_token
|
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 'source_commit=%s\n' "$source_commit"
|
||||||
printf 'project=%s\n' "$project"
|
printf 'project=%s\n' "$project"
|
||||||
printf 'image=%s\n' "$image"
|
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 version --format \
|
||||||
'docker_server={{.Server.Version}} docker_client={{.Client.Version}}'
|
'docker_server={{.Server.Version}} docker_client={{.Client.Version}}'
|
||||||
docker compose version
|
docker compose version
|
||||||
} >"$output_dir/environment.txt"
|
} >"$output_dir/environment.txt"
|
||||||
|
|
||||||
"${compose[@]}" config --quiet
|
"${compose[@]}" config --quiet
|
||||||
|
config_valid=true
|
||||||
printf 'tracked_archive_config=valid\n' >"$output_dir/config.txt"
|
printf 'tracked_archive_config=valid\n' >"$output_dir/config.txt"
|
||||||
|
|
||||||
"${compose[@]}" up --detach --wait --build
|
"${compose[@]}" up --detach --wait --build
|
||||||
|
|
|
||||||
|
|
@ -629,7 +629,13 @@ CPU_REPLAY_WEB_SCHEDULERS=1 \
|
||||||
CPU_REPLAY_WORKER_SCHEDULERS=1 \
|
CPU_REPLAY_WORKER_SCHEDULERS=1 \
|
||||||
docker compose --env-file .env.example \
|
docker compose --env-file .env.example \
|
||||||
-f compose.yaml -f compose.cpu-replay.yaml config --quiet
|
-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_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 \
|
docker compose --env-file .env.example \
|
||||||
-f compose.yaml -f compose.portability.yaml config --quiet
|
-f compose.yaml -f compose.portability.yaml config --quiet
|
||||||
mkdir -p "$scan_dir/e2e-output"
|
mkdir -p "$scan_dir/e2e-output"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user