diff --git a/.gitea/workflows/publish-image.yaml b/.gitea/workflows/publish-image.yaml index 5b42d07..b9e327d 100644 --- a/.gitea/workflows/publish-image.yaml +++ b/.gitea/workflows/publish-image.yaml @@ -1,6 +1,10 @@ -name: Publish Builder Image +name: Publish Builder Images on: push: + paths: + - 'Dockerfile.base' + - 'Dockerfile.windows' + - 'build.sh' jobs: build-and-push: @@ -9,17 +13,21 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Build and Push + - name: Make script executable + run: chmod +x build.sh + + # Optional: Restore DNF Cache (if you are using the cache strategy) + + - name: Run Build Script uses: docker://quay.io/buildah/stable env: - USERNAME: ${{ gitea.actor }} + # Standard Gitea env vars + USERNAME: ${{ gitea.repository_owner }} PASSWORD: ${{ secrets.USER_PACKAGE_PASSWORD }} REGISTRY: gitea.212.63.210.91.nip.io - # Changed to repository_owner to avoid 'owner/repo/image' nesting - IMAGE: ${{ gitea.repository_owner }}/godot-builder + + # We use the short SHA for the tag TAG: ${{ gitea.sha }} with: entrypoint: /bin/sh - # We just tell it to run the script we checked out - args: ./build.sh - + args: ./build.sh \ No newline at end of file diff --git a/Dockerfile.base b/Dockerfile.base new file mode 100644 index 0000000..810b4a1 --- /dev/null +++ b/Dockerfile.base @@ -0,0 +1,13 @@ +FROM fedora:42 + +WORKDIR /root + +ENV DOTNET_NOLOGO=1 +ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 + +RUN dnf -y install --setopt=install_weak_deps=False \ + bash binutils bzip2 curl file findutils gettext git make nano patch pkgconfig python3-pip unzip which xz \ + dotnet-sdk-8.0 && \ + pip install scons==4.9.1 + +CMD /bin/bash \ No newline at end of file diff --git a/Dockerfile.windows b/Dockerfile.windows new file mode 100644 index 0000000..bfdf7ee --- /dev/null +++ b/Dockerfile.windows @@ -0,0 +1,13 @@ +ARG img_version +FROM godot-fedora:${img_version} + +RUN dnf -y install --setopt=install_weak_deps=False \ + mingw32-gcc mingw32-gcc-c++ mingw32-winpthreads-static mingw64-gcc mingw64-gcc-c++ mingw64-winpthreads-static && \ + export LLVM_MINGW_VERSION=20250528 && \ + export LLVM_MINGW_NAME=llvm-mingw-${LLVM_MINGW_VERSION}-ucrt-ubuntu-22.04-x86_64 && \ + curl -LO https://github.com/mstorsjo/llvm-mingw/releases/download/${LLVM_MINGW_VERSION}/${LLVM_MINGW_NAME}.tar.xz && \ + tar xf ${LLVM_MINGW_NAME}.tar.xz && \ + rm -f ${LLVM_MINGW_NAME}.tar.xz && \ + mv -f ${LLVM_MINGW_NAME} /root/llvm-mingw + +CMD /bin/bash \ No newline at end of file diff --git a/build.sh b/build.sh index eaf4af1..c5bcfcb 100644 --- a/build.sh +++ b/build.sh @@ -1,25 +1,69 @@ #!/bin/sh -set -e # Exit immediately if a command fails +set -e # Stop on any error -# 1. Login to Gitea Registry -# We use the environment variables passed from the workflow +# --- Configuration --- +# 1. Image Names for your Registry +BASE_IMAGE_NAME="godot-builder-base" +WIN_IMAGE_NAME="godot-builder-windows" + +# 2. Construct full registry paths +# Uses variables passed from the workflow env: $REGISTRY, $USERNAME, $TAG +FULL_BASE_TAG="$REGISTRY/$USERNAME/$BASE_IMAGE_NAME:$TAG" +LATEST_BASE_TAG="$REGISTRY/$USERNAME/$BASE_IMAGE_NAME:latest" + +FULL_WIN_TAG="$REGISTRY/$USERNAME/$WIN_IMAGE_NAME:$TAG" +LATEST_WIN_TAG="$REGISTRY/$USERNAME/$WIN_IMAGE_NAME:latest" + +# 3. Login echo "Logging in to $REGISTRY..." buildah login -u "$USERNAME" -p "$PASSWORD" --tls-verify=false --storage-driver=vfs "$REGISTRY" -# 2. Build the Image -# We build both the specific SHA tag and the 'latest' tag -echo "Building image $IMAGE..." +# --- STEP 1: Build Base Image --- +echo "---------------------------------------" +echo "Building BASE image (Fedora)..." +echo "---------------------------------------" + +# Build and tag for the registry buildah build \ --tls-verify=false \ --storage-driver=vfs \ - -f Dockerfile \ - -t "$REGISTRY/$IMAGE:$TAG" \ - -t "$REGISTRY/$IMAGE:latest" \ + -f Dockerfile.base \ + -t "$FULL_BASE_TAG" \ + -t "$LATEST_BASE_TAG" \ . -# 3. Push the Images -echo "Pushing images..." -buildah push --tls-verify=false --storage-driver=vfs "$REGISTRY/$IMAGE:$TAG" -buildah push --tls-verify=false --storage-driver=vfs "$REGISTRY/$IMAGE:latest" +# CRITICAL STEP: Create the local alias +# The Windows Dockerfile expects "FROM godot-fedora:custom" +# So we tag our just-built image to match that expectation. +buildah tag "$FULL_BASE_TAG" "godot-fedora:custom" -echo "Done!" \ No newline at end of file +# Push Base to registry (Checkpoint) +echo "Pushing Base image..." +buildah push --tls-verify=false --storage-driver=vfs "$FULL_BASE_TAG" +buildah push --tls-verify=false --storage-driver=vfs "$LATEST_BASE_TAG" + +# --- STEP 2: Build Windows Image --- +echo "---------------------------------------" +echo "Building WINDOWS image..." +echo "---------------------------------------" + +# We pass 'img_version=custom' to match the tag we just created. +buildah build \ + --tls-verify=false \ + --storage-driver=vfs \ + --build-arg img_version=custom \ + -f Dockerfile.windows \ + -t "$FULL_WIN_TAG" \ + -t "$LATEST_WIN_TAG" \ + . + +# Push Windows Image +echo "Pushing Windows image..." +buildah push --tls-verify=false --storage-driver=vfs "$FULL_WIN_TAG" +buildah push --tls-verify=false --storage-driver=vfs "$LATEST_WIN_TAG" + +echo "---------------------------------------" +echo "SUCCESS!" +echo "Base Image: $FULL_BASE_TAG" +echo "Windows Image: $FULL_WIN_TAG" +echo "---------------------------------------" \ No newline at end of file