#!/bin/sh set -e # --- Configuration --- IMAGE_NAME="godot-builder-base" # We hash the Dockerfile to create a unique cache key FILE_HASH=$(sha256sum Dockerfile.base | cut -c 1-8) FULL_TAG="$REGISTRY/$USERNAME/$IMAGE_NAME:$FILE_HASH" LATEST_TAG="$REGISTRY/$USERNAME/$IMAGE_NAME:latest" echo "Logging in..." buildah login -u "$USERNAME" -p "$PASSWORD" --tls-verify=false "$REGISTRY" echo "Checking if base image $FULL_TAG exists..." # If we can pull it, we don't need to build it! if buildah pull --tls-verify=false "$FULL_TAG"; then echo "✅ Cache Hit! Base image exists. Skipping build." # Just re-tag 'latest' to point to this valid existing image buildah tag "$FULL_TAG" "$LATEST_TAG" buildah push --tls-verify=false "$LATEST_TAG" exit 0 fi echo "⚠️ Cache Miss. Building new base image..." buildah build \ --tls-verify=false \ -f Dockerfile.base \ -t "$FULL_TAG" \ -t "$LATEST_TAG" \ . echo "Pushing base image..." buildah push --tls-verify=false "$FULL_TAG" buildah push --tls-verify=false "$LATEST_TAG"