From bd61a64c70a157a4708ae516f145225be8b5f0a5 Mon Sep 17 00:00:00 2001 From: fabi Date: Sun, 31 May 2026 19:40:12 +0200 Subject: [PATCH] ci: build via host docker socket (plain build); fix missing daemon socket build-and-push failed at docker/setup-buildx-action: the job had no /var/run/docker.sock, so buildx's docker-container driver couldn't reach the daemon. Mount the host socket into build-and-push and deploy, and replace setup-buildx + build-push-action (+ the unsupported gha cache) with a plain docker build/push against the host daemon (DooD), reusing the host's layer cache. Co-Authored-By: Claude Opus 4.8 (1M context) --- .gitea/workflows/deploy.yml | 69 +++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index b0aba2a..7cd3f7b 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -72,9 +72,17 @@ jobs: runs-on: ubuntu-latest needs: [test-backend, test-frontend] # PRs only run the test jobs; build + deploy are reserved for - # post-merge pushes to main. Without this gate every PR would push - # a tagged image to the registry and SSH-deploy to prod. + # post-merge pushes to main. if: github.event_name != 'pull_request' + # Build on the host docker daemon directly (docker-outside-of-docker): + # the runner shares the deploy host's daemon, so a plain `docker build` + # reuses the host's layer cache and avoids buildx's docker-container + # driver + the gha cache exporter — neither works against this single-host + # act_runner, and there is no in-job daemon socket unless we mount it. + container: + image: docker.gitea.com/runner-images:ubuntu-latest + volumes: + - /var/run/docker.sock:/var/run/docker.sock outputs: image_tag: ${{ steps.meta.outputs.image_tag }} version: ${{ steps.meta.outputs.version }} @@ -93,48 +101,32 @@ jobs: echo "image_tag=${GITHUB_SHA}" >> "$GITHUB_OUTPUT" echo "version=${version}" >> "$GITHUB_OUTPUT" - - uses: docker/setup-buildx-action@v3 - - - name: docker login - uses: docker/login-action@v3 - with: - registry: ${{ secrets.REGISTRY_URL }} - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_PASSWORD }} - - - name: Build & push backend - uses: docker/build-push-action@v5 - with: - context: ./backend - push: true - tags: | - ${{ secrets.REGISTRY_URL }}/mangalord-backend:latest - ${{ secrets.REGISTRY_URL }}/mangalord-backend:${{ steps.meta.outputs.image_tag }} - ${{ secrets.REGISTRY_URL }}/mangalord-backend:${{ steps.meta.outputs.version }} - cache-from: type=gha,scope=backend - cache-to: type=gha,mode=max,scope=backend - - - name: Build & push frontend - uses: docker/build-push-action@v5 - with: - context: ./frontend - push: true - tags: | - ${{ secrets.REGISTRY_URL }}/mangalord-frontend:latest - ${{ secrets.REGISTRY_URL }}/mangalord-frontend:${{ steps.meta.outputs.image_tag }} - ${{ secrets.REGISTRY_URL }}/mangalord-frontend:${{ steps.meta.outputs.version }} - cache-from: type=gha,scope=frontend - cache-to: type=gha,mode=max,scope=frontend + - name: Build & push backend + frontend + env: + REGISTRY_URL: ${{ secrets.REGISTRY_URL }} + REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }} + REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} + IMAGE_TAG: ${{ steps.meta.outputs.image_tag }} + VERSION: ${{ steps.meta.outputs.version }} + run: | + set -eu + echo "$REGISTRY_PASSWORD" | docker login "$REGISTRY_URL" -u "$REGISTRY_USERNAME" --password-stdin + for svc in backend frontend; do + img="$REGISTRY_URL/mangalord-$svc" + docker build -t "$img:$IMAGE_TAG" -t "$img:latest" -t "$img:$VERSION" "./$svc" + for tag in "$IMAGE_TAG" latest "$VERSION"; do docker push "$img:$tag"; done + done + docker logout "$REGISTRY_URL" deploy: runs-on: ubuntu-latest needs: build-and-push if: github.event_name != 'pull_request' # Single-host deploy: the runner lives on the same box as the stack, so we - # drive the host docker daemon directly (act_runner shares its socket via - # `docker_host: "-"`) instead of SSHing out. The compose dir is bind-mounted - # at its REAL host path so compose's relative bind-mounts (./mangalord/..., - # ./Caddyfile) resolve; this requires `/mnt/ssd/docker-data` in the runner's + # drive the host docker daemon directly (the job mounts the host docker + # socket) instead of SSHing out. The compose dir is bind-mounted at its + # REAL host path so compose's relative bind-mounts (./mangalord/..., + # ./Caddyfile) resolve; both paths must be in the runner's # container.valid_volumes. The central compose references the images as # registry.mc02.dev/mangalord-*:${MANGALORD_TAG:-latest}, so we only pull # and recreate the two mangalord services at the freshly built SHA. @@ -142,6 +134,7 @@ jobs: image: docker:cli volumes: - /mnt/ssd/docker-data:/mnt/ssd/docker-data + - /var/run/docker.sock:/var/run/docker.sock steps: - name: Deploy to the local stack working-directory: /mnt/ssd/docker-data -- 2.49.1