diff --git a/.gitea/workflows/build-docker-image.yml b/.gitea/workflows/build-docker-image.yml index 7f13405..43849b6 100644 --- a/.gitea/workflows/build-docker-image.yml +++ b/.gitea/workflows/build-docker-image.yml @@ -8,19 +8,16 @@ on: jobs: build-server: runs-on: ubuntu-24.04 - services: - docker: - image: docker:dind - options: --privileged --security-opt seccomp=unconfined steps: - # 1. Check out the repo - uses: actions/checkout@v4 - # 2. Set up Docker Buildx (recommended for advanced caching) - - name: Set up Docker Buildx + - name: Set up Docker Buildx (ephemeral) uses: docker/setup-buildx-action@v3 + with: + install: true + driver-opts: network=host + buildkitd-flags: --debug - # 3. Log in to your container registry - name: Log in to registry uses: docker/login-action@v2 with: @@ -28,22 +25,22 @@ jobs: username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_PASSWORD }} - # 4. Lowercase the repository name - name: Set lowercase repo name run: echo "REPO_NAME_LOWER=$(echo '${{ github.event.repository.name }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV - # 5. Build & push the server image, using remote cache - - name: Build and push server image - uses: docker/build-push-action@v4 - with: - context: VirtualDDNSRouter.Server - file: VirtualDDNSRouter.Server/Dockerfile - push: true - tags: ${{ secrets.REGISTRY_URL }}/${{ github.repository_owner }}/${{ env.REPO_NAME_LOWER }}:latest-server - cache-from: type=registry,ref=${{ secrets.REGISTRY_URL }}/${{ github.repository_owner }}/${{ env.REPO_NAME_LOWER }}:buildcache - cache-to: type=registry,ref=${{ secrets.REGISTRY_URL }}/${{ github.repository_owner }}/${{ env.REPO_NAME_LOWER }}:buildcache,mode=max - - - name: Clean up Docker in dind - run: docker builder prune -af + - name: Build and push (no local cache) + run: | + docker buildx build \ + --pull \ + --no-cache \ + --file VirtualDDNSRouter.Server/Dockerfile \ + --tag ${{ secrets.REGISTRY_URL }}/${{ github.repository_owner }}/${{ env.REPO_NAME_LOWER }}:latest-server \ + --cache-from type=registry,ref=${{ secrets.REGISTRY_URL }}/${{ github.repository_owner }}/${{ env.REPO_NAME_LOWER }}:buildcache \ + --cache-to type=registry,ref=${{ secrets.REGISTRY_URL }}/${{ github.repository_owner }}/${{ env.REPO_NAME_LOWER }}:buildcache,mode=max \ + --push \ + VirtualDDNSRouter.Server - \ No newline at end of file + - name: Remove builder to delete all cache + run: | + BUILDER=$(docker buildx ls | awk '/\*/ {print $1}') + docker buildx rm "$BUILDER" || true