Files
godot-builder-image/build-base.sh
Olof Pettersson 3b60d38e42
Some checks failed
Publish Builder Images / build-base (push) Successful in 31s
Publish Builder Images / build-windows (push) Failing after 3m29s
Use host network
2025-12-02 10:30:07 +01:00

38 lines
1.3 KiB
Bash

#!/bin/sh
set -e
# --- Configuration ---
IMAGE_NAME="godot-builder-base"
# Calculate a short hash based purely on the file content
# If you don't change the file, this hash stays the same!
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 --storage-driver=vfs "$REGISTRY"
echo "Checking if base image $FULL_TAG exists..."
# Try to pull the specific hash. If it works, we are done!
if buildah pull --tls-verify=false --storage-driver=vfs "$FULL_TAG"; then
echo "✅ Cache Hit! Image already exists. Skipping build."
# Retag it as 'latest' just to be safe for other jobs
buildah tag --storage-driver=vfs "$FULL_TAG" "$LATEST_TAG"
buildah push --tls-verify=false --storage-driver=vfs "$LATEST_TAG"
exit 0
fi
echo "⚠️ Cache Miss. Building new base image..."
buildah build \
--tls-verify=false \
--storage-driver=vfs \
--network=host \
-f Dockerfile.base \
-t "$FULL_TAG" \
-t "$LATEST_TAG" \
.
echo "Pushing new base image..."
buildah push --tls-verify=false --storage-driver=vfs "$FULL_TAG"
buildah push --tls-verify=false --storage-driver=vfs "$LATEST_TAG"