From 2d0568d9c269de5d4a2c9efcad321a5dadfc5ec5 Mon Sep 17 00:00:00 2001 From: Phil Date: Sat, 31 Oct 2026 11:53:59 -0600 Subject: [PATCH] Build the container image with the server's rootless BuildKit The runner no longer has a Docker daemon (it gave every workflow root on the server), and this workflow never worked anyway: it logged in to gitea:3000, which the daemon couldn't resolve. Log in to git.thesatelliteoflove.com and build through the BuildKit socket instead. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/build-container.yml | 65 ++++++++++------------------ 1 file changed, 23 insertions(+), 42 deletions(-) diff --git a/.gitea/workflows/build-container.yml b/.gitea/workflows/build-container.yml index fe5af0d..a07f091 100644 --- a/.gitea/workflows/build-container.yml +++ b/.gitea/workflows/build-container.yml @@ -1,58 +1,39 @@ # Gitea Actions workflow for StarPunk -# Builds and pushes container images on version tags - +# Builds and pushes container images on version tags. +# +# The runner has no Docker daemon (that would give workflows root on the +# server). Images are built by the rootless BuildKit container next to it, +# reached through its socket. name: Build Container - on: - # Trigger on version tags push: tags: - 'v[0-9]+.[0-9]+.[0-9]+' - # Allow manual trigger from Gitea UI workflow_dispatch: +env: + REGISTRY: git.thesatelliteoflove.com + BUILDKIT: unix:///run/buildkit/buildkit/buildkitd.sock + jobs: build: runs-on: docker steps: - name: Install dependencies - run: | - if command -v apk > /dev/null; then - apk add --no-cache nodejs npm docker git - elif command -v apt-get > /dev/null; then - apt-get update && apt-get install -y nodejs npm docker.io git - elif command -v yum > /dev/null; then - yum install -y nodejs npm docker git - fi - + run: apk add --no-cache nodejs git docker-cli docker-cli-buildx - name: Checkout uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Extract registry URL - id: registry - run: | - # Extract hostname from server URL (remove protocol) - REGISTRY_URL=$(echo "${{ github.server_url }}" | sed 's|https://||' | sed 's|http://||') - echo "url=${REGISTRY_URL}" >> $GITHUB_OUTPUT - - - name: Login to Gitea Container Registry - uses: docker/login-action@v3 - with: - registry: ${{ steps.registry.outputs.url }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - + - name: Log in to the Gitea registry + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login "$REGISTRY" -u "${{ github.actor }}" --password-stdin + - name: Use the BuildKit socket + run: docker buildx create --name ci --driver remote "$BUILDKIT" --use - name: Build and push - uses: docker/build-push-action@v5 - with: - context: . - file: ./Containerfile - push: true - tags: | - ${{ steps.registry.outputs.url }}/${{ github.repository }}:${{ github.ref_name }} - ${{ steps.registry.outputs.url }}/${{ github.repository }}:latest - cache-from: type=gha - cache-to: type=gha,mode=max + run: | + image="$REGISTRY/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" + docker buildx build --push -f Containerfile \ + -t "$image:${{ github.ref_name }}" -t "$image:latest" . + - name: Clean up + if: always() + run: | + docker buildx rm ci || true + docker logout "$REGISTRY" || true