From 27186662f94deec3bb349e4765b5f01acb8f2cb5 Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Thu, 1 Oct 2026 22:11:03 -0600 Subject: [PATCH] fix: deploy demos with immutable image tag --- apps/demos-static/web-app.yaml | 4 ++-- bootstrap/apps/main.tf | 5 +++++ bootstrap/apps/variables.tf | 5 +++++ lib/jeannie/pipeline.sh | 21 +++++++++++++++++++-- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/apps/demos-static/web-app.yaml b/apps/demos-static/web-app.yaml index 241a4a1..71dffb6 100644 --- a/apps/demos-static/web-app.yaml +++ b/apps/demos-static/web-app.yaml @@ -23,8 +23,8 @@ spec: fsGroupChangePolicy: OnRootMismatch containers: - name: demos-static - image: 192.168.100.73:30500/demos-static:latest - imagePullPolicy: Always + image: 192.168.100.73:30500/demos-static:bootstrap + imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true diff --git a/bootstrap/apps/main.tf b/bootstrap/apps/main.tf index b760c8e..c986c5f 100644 --- a/bootstrap/apps/main.tf +++ b/bootstrap/apps/main.tf @@ -24,6 +24,11 @@ locals { kustomize = { images = ["php-website=${var.website_image_ref}"] } + } : {}, + name == "demos-static" && var.demos_image_ref != "" ? { + kustomize = { + images = ["demos-static=${var.demos_image_ref}"] + } } : {} ) } diff --git a/bootstrap/apps/variables.tf b/bootstrap/apps/variables.tf index c2f2c3d..52ec7d9 100644 --- a/bootstrap/apps/variables.tf +++ b/bootstrap/apps/variables.tf @@ -18,6 +18,11 @@ variable "website_image_ref" { default = "" } +variable "demos_image_ref" { + type = string + default = "" +} + variable "applications" { type = map(object({ project = string diff --git a/lib/jeannie/pipeline.sh b/lib/jeannie/pipeline.sh index dc1ab3f..cafee6e 100644 --- a/lib/jeannie/pipeline.sh +++ b/lib/jeannie/pipeline.sh @@ -3821,6 +3821,12 @@ website_image_tag() { printf 'src-%s\n' "${source_hash:0:12}" } +demos_image_tag() { + local source_hash="$1" + + printf 'src-%s\n' "${source_hash:0:12}" +} + apps_registry_endpoint() { if [[ -n "${TF_VAR_registry_endpoint:-}" ]]; then printf '%s\n' "${TF_VAR_registry_endpoint}" @@ -3929,6 +3935,7 @@ demos_image_is_current() { local platforms="$3" local image_ref="$4" local registry_endpoint="$5" + local image_tag local saved_hash local saved_platforms local saved_image @@ -3943,7 +3950,8 @@ demos_image_is_current() { [[ "${saved_platforms}" == "${platforms}" ]] || return 1 [[ "${saved_image}" == "${image_ref}" ]] || return 1 - registry_image_exists "${registry_endpoint}" demos-static latest + image_tag="$(image_ref_tag "${image_ref}")" + registry_image_exists "${registry_endpoint}" demos-static "${image_tag}" } write_website_image_state() { @@ -6333,16 +6341,17 @@ apps() { registry_endpoint="$(apps_registry_endpoint)" demos_registry_endpoint="$(demos_registry_endpoint)" - demos_image_ref="${registry_endpoint}/demos-static:latest" demos_image_state_file="${REPO_ROOT}/.lab/demos-static-image.state" demos_platforms="${DEMOS_IMAGE_PLATFORMS:-linux/amd64,linux/arm64}" demos_source_hash="$(demos_source_hash)" + demos_image_ref="${registry_endpoint}/demos-static:${DEMOS_IMAGE_TAG:-$(demos_image_tag "${demos_source_hash}")}" website_image_state_file="${REPO_ROOT}/.lab/php-website-image.state" website_platforms="${WEBSITE_IMAGE_PLATFORMS:-linux/amd64,linux/arm64}" website_source_hash="$(website_source_hash)" website_image_ref="${registry_endpoint}/php-website:${WEBSITE_IMAGE_TAG:-$(website_image_tag "${website_source_hash}")}" export TF_VAR_registry_endpoint="${TF_VAR_registry_endpoint:-${registry_endpoint}}" export TF_VAR_website_image_ref="${TF_VAR_website_image_ref:-${website_image_ref}}" + export TF_VAR_demos_image_ref="${TF_VAR_demos_image_ref:-${demos_image_ref}}" export TF_VAR_kubeconfig_path="${TF_VAR_kubeconfig_path:-${KUBECONFIG_PATH}}" export KUBECONFIG_PATH="${TF_VAR_kubeconfig_path}" @@ -6364,6 +6373,10 @@ apps() { echo "TF_VAR_website_image_ref must match the buildx website image ref (${website_image_ref})" >&2 exit 1 fi + if [[ "${TF_VAR_demos_image_ref}" != "${demos_image_ref}" ]]; then + echo "TF_VAR_demos_image_ref must match the buildx demos image ref (${demos_image_ref})" >&2 + exit 1 + fi if [[ "${demos_registry_endpoint}" != "${registry_endpoint}" ]]; then echo "apps/demos-static/web-app.yaml registry endpoint (${demos_registry_endpoint}) must match app registry endpoint (${registry_endpoint})" >&2 @@ -6374,6 +6387,10 @@ apps() { echo "apps/website/web-app.yaml must use an immutable php-website image tag, not latest." >&2 exit 1 fi + if [[ "$(image_ref_tag "${demos_image_ref}")" == "latest" ]]; then + echo "apps/demos-static/web-app.yaml must use an immutable demos-static image tag, not latest." >&2 + exit 1 + fi ensure_website_image_tag_not_reused "${website_image_state_file}" "${website_source_hash}" "${website_image_ref}" echo "Deploying homelab applications..."