diff --git a/stacks.sh b/stacks.sh index f81140f..21e2ef9 100755 --- a/stacks.sh +++ b/stacks.sh @@ -379,6 +379,24 @@ cmd_compose() { # ─── Update Service ─────────────────────────────────────────────────────────── +# Resolve each service's image tag to its current local SHA256 ID. +# Reads from the local image store (updated by 'docker compose pull'), +# NOT from running containers — so the comparison reflects the pulled image. +_stack_image_ids() { + local stack_dir="$1"; shift + local -a env_flag=("$@") + local images + # 'config --images' (compose v2.19+) outputs one image name per line; + # fall back to parsing the resolved config yaml for older versions. + if images=$(cd "$stack_dir" && docker compose "${env_flag[@]}" config --images 2>/dev/null) \ + && [[ -n "$images" ]]; then + echo "$images" + else + cd "$stack_dir" && docker compose "${env_flag[@]}" config 2>/dev/null \ + | awk '/^\s+image:/{print $2}' | sort -u + fi | xargs -r docker image inspect --format '{{.Id}}' 2>/dev/null | sort +} + _update_run() { load_root_env @@ -398,9 +416,9 @@ _update_run() { ((checked++)) || true local before after - before=$(cd "$stack_dir" && docker compose "${env_flag[@]}" images -q 2>/dev/null | sort || true) + before=$(_stack_image_ids "$stack_dir" "${env_flag[@]+"${env_flag[@]}"}") (cd "$stack_dir" && docker compose "${env_flag[@]}" pull 2>&1) || true - after=$(cd "$stack_dir" && docker compose "${env_flag[@]}" images -q 2>/dev/null | sort || true) + after=$(_stack_image_ids "$stack_dir" "${env_flag[@]+"${env_flag[@]}"}") if [[ "$before" != "$after" ]]; then info " Updates found — recreating $stack"