diff --git a/.dockerignore b/.dockerignore index 6c3a7fe..9309195 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,15 @@ +.git +.gitignore +.gitattributes +.github/ +.pre-commit-config.yaml +deny.toml +dist-workspace.toml +docker-compose.yml +Dockerfile +LICENSE +README.md + # Generated by Cargo # will have compiled files and executables /target/ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa8808e..924607c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ env: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04-arm steps: - name: Checkout code diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4cdd53c..55ae834 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -6,16 +6,30 @@ on: tags: - "v*" +env: + GHCR_REPO: ghcr.io/hadeutscher/rustyrail/harail + jobs: build: - runs-on: ubuntu-latest + strategy: + matrix: + platform: + - amd64 + - arm64 + include: + - platform: amd64 + runner: ubuntu-24.04 + - platform: arm64 + runner: ubuntu-24.04-arm + runs-on: ${{ matrix.runner }} steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -24,22 +38,65 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ghcr.io/${{ github.repository }}/harail + images: ${{ env.GHCR_REPO }} - - name: Log in to GitHub Container Registry + - name: Build and push by digest + id: build + uses: docker/build-push-action@v6 + with: + platforms: linux/${{ matrix.platform }} + labels: ${{ steps.meta.outputs.labels }} + outputs: type=image,"name=${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true + cache-from: type=gha,scope=docker-buildx-${{ matrix.platform }} + cache-to: type=gha,mode=max,scope=docker-buildx-${{ matrix.platform }} + + - name: Export digest + run: | + mkdir -p ${{ runner.temp }}/digests + digest="${{ steps.build.outputs.digest }}" + touch "${{ runner.temp }}/digests/${digest#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v4 + with: + name: digests-${{ matrix.platform }} + path: ${{ runner.temp }}/digests/* + if-no-files-found: error + retention-days: 1 + + merge: + runs-on: ubuntu-24.04 + needs: + - build + steps: + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: ${{ runner.temp }}/digests + pattern: digests-* + merge-multiple: true + + - name: Login to GHCR uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push Docker image - uses: docker/build-push-action@v6 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 with: - context: . - push: true - platforms: linux/amd64,linux/arm64 - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max + images: ${{ env.GHCR_REPO }} + + - name: Create manifest list and push + working-directory: ${{ runner.temp }}/digests + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.GHCR_REPO }}@sha256:%s ' *) + + - name: Inspect image + run: docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }}