From 1256eea88d5b65b5491f81020a4eac9963fc182b Mon Sep 17 00:00:00 2001 From: Morgan Patterson <31448722+vmorganp@users.noreply.github.com> Date: Thu, 1 Sep 2022 00:55:06 -0700 Subject: [PATCH] Multiplatform Image --- .github/workflows/docker-publish.yml | 24 +++++++++++++++++------- Dockerfile | 3 ++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 59ab970..ba62db1 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,4 +1,4 @@ -name: Docker +name: Docker Build and Publish # This workflow uses actions that are not certified by GitHub. # They are provided by a third-party and are governed by @@ -22,21 +22,25 @@ env: jobs: build: - runs-on: ubuntu-latest permissions: contents: read packages: write - steps: - name: Checkout repository uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + # Login against a Docker registry except on PR # https://github.com/docker/login-action - name: Log into registry ${{ env.REGISTRY }} if: github.event_name != 'pull_request' - uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + uses: docker/login-action@v2 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -46,16 +50,22 @@ jobs: # https://github.com/docker/metadata-action - name: Extract Docker metadata id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + uses: docker/metadata-action@v4 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=sha # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action - name: Build and push Docker image - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + uses: docker/build-push-action@v3 with: context: . - push: ${{ github.event_name != 'pull_request' }} + platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + push: ${{ github.event_name != 'pull_request' }} diff --git a/Dockerfile b/Dockerfile index 4ffd6bb..4cffec0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -from golang:alpine3.15 +FROM golang:alpine3.15 + WORKDIR /root/ COPY ./go.mod ./go.sum ./ RUN go mod download