Reorganised deployment scripts and added rollback functionality. Updated documentation and workflow for container image builds.
Test and publish container images / test (push) Successful in 2m50s
Test and publish container images / publish (push) Failing after 54s

This commit is contained in:
BuTzZ
2026-07-25 12:36:35 +02:00
parent 12eee8d211
commit c9a20aacd7
17 changed files with 642 additions and 73 deletions
+100
View File
@@ -5,6 +5,7 @@ set -Eeuo pipefail
WM_DEPLOY_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
WM_ROOT_DIR="$(cd "$WM_DEPLOY_DIR/.." && pwd)"
WM_ENV_FILE="${WATERMAPS_ENV_FILE:-$WM_DEPLOY_DIR/.env.production}"
WM_IMAGES_ENV_FILE="${WATERMAPS_IMAGES_ENV_FILE:-$WM_DEPLOY_DIR/.env.images}"
WM_COMPOSE_FILE="$WM_DEPLOY_DIR/compose.production.yml"
wm_die() {
@@ -47,13 +48,112 @@ wm_assert_data_mount() {
}
wm_compose() {
wm_validate_images_env "$WM_IMAGES_ENV_FILE"
docker compose \
--project-directory "$WM_ROOT_DIR" \
--env-file "$WM_ENV_FILE" \
--env-file "$WM_IMAGES_ENV_FILE" \
--file "$WM_COMPOSE_FILE" \
"$@"
}
wm_use_images_env() {
local images_env_file="$1"
wm_validate_images_env "$images_env_file"
WM_IMAGES_ENV_FILE="$images_env_file"
export WATERMAPS_IMAGES_ENV_FILE="$images_env_file"
}
wm_validate_images_env() {
local images_env_file="$1"
local revision app_image route_data_image
[[ -f "$images_env_file" ]] ||
wm_die "Image-Konfiguration fehlt: $images_env_file"
revision="$(wm_env_value "$images_env_file" WATERMAPS_DEPLOY_REVISION)"
app_image="$(wm_env_value "$images_env_file" WATERMAPS_APP_IMAGE)"
route_data_image="$(wm_env_value "$images_env_file" WATERMAPS_ROUTE_DATA_IMAGE)"
[[ "$revision" =~ ^[0-9a-f]{40}$ ]] ||
wm_die "WATERMAPS_DEPLOY_REVISION muss eine vollständige Git-Commit-SHA sein."
wm_validate_image_reference "$app_image" WATERMAPS_APP_IMAGE
wm_validate_image_reference "$route_data_image" WATERMAPS_ROUTE_DATA_IMAGE
wm_validate_release_image "$app_image" "$revision" WATERMAPS_APP_IMAGE
wm_validate_release_image \
"$route_data_image" \
"$revision" \
WATERMAPS_ROUTE_DATA_IMAGE
}
wm_env_value() {
local env_file="$1"
local requested_key="$2"
local value
value="$(
awk -F= -v requested_key="$requested_key" '
$1 == requested_key {
print substr($0, length($1) + 2)
matches += 1
}
END {
if (matches != 1) {
exit 1
}
}
' "$env_file"
)" || wm_die "$requested_key fehlt oder ist mehrfach in $env_file vorhanden."
printf '%s\n' "$value"
}
wm_validate_image_reference() {
local image_reference="$1"
local variable_name="$2"
[[ -n "$image_reference" &&
"$image_reference" != *[[:space:]]* &&
"$image_reference" == */* &&
"$image_reference" != *REPLACE* ]] ||
wm_die "$variable_name enthält keine gültige Registry-Image-Referenz."
}
wm_validate_release_image() {
local image_reference="$1"
local revision="$2"
local variable_name="$3"
[[ "$image_reference" == *":$revision" ||
"$image_reference" =~ @sha256:[0-9a-f]{64}$ ]] ||
wm_die "$variable_name muss auf den Commit-Tag $revision oder einen SHA256-Digest zeigen."
}
wm_resolve_image_digest() {
local image_reference="$1"
local requested_repository last_component resolved_reference
requested_repository="${image_reference%%@*}"
last_component="${requested_repository##*/}"
if [[ "$last_component" == *:* ]]; then
requested_repository="${requested_repository%:*}"
fi
resolved_reference="$(
docker image inspect \
--format '{{range .RepoDigests}}{{println .}}{{end}}' \
"$image_reference" |
awk -v requested_repository="$requested_repository" '
index($0, requested_repository "@sha256:") == 1 {
print
exit
}
'
)"
[[ "$resolved_reference" =~ @sha256:[0-9a-f]{64}$ ]] ||
wm_die "Für $image_reference konnte kein lokaler Registry-Digest ermittelt werden."
printf '%s\n' "$resolved_reference"
}
wm_route_file() {
printf '%s/local/germany-netherlands-fairways.json\n' "$WATERMAPS_DATA_DIR"
}