From d4b1ebe8f13b88baef784230ad994d3c3154e81f Mon Sep 17 00:00:00 2001 From: Christian Hoffmeister Date: Mon, 22 Nov 2021 16:04:21 +0100 Subject: [PATCH] build docker image in multiarch --- .github/workflows/release.yml | 4 +++- .goreleaser.yml | 33 ++++++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 943b206..4108987 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,9 +10,11 @@ jobs: - uses: actions/setup-go@v2 with: go-version: 1.17.x + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 - uses: docker/login-action@v1 with: - registry: https://ghcr.io + registry: ghcr.io username: choffmeister password: ${{ secrets.GITHUB_TOKEN }} - uses: actions/checkout@v2 diff --git a/.goreleaser.yml b/.goreleaser.yml index 694cd3a..ec345e1 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -13,17 +13,32 @@ builds: goarch: - amd64 - arm64 -archives: - - replacements: - darwin: Darwin - linux: Linux - windows: Windows - 386: i386 - amd64: x86_64 dockers: - image_templates: - - "ghcr.io/choffmeister/{{ .ProjectName }}:{{ .Tag }}" - - "ghcr.io/choffmeister/{{ .ProjectName }}:latest" + - "ghcr.io/choffmeister/{{ .ProjectName }}:{{ .Version }}-amd64" + - "ghcr.io/choffmeister/{{ .ProjectName }}:latest-amd64" + use: buildx + goarch: amd64 + dockerfile: Dockerfile + build_flag_templates: + - "--platform=linux/amd64" + - image_templates: + - "ghcr.io/choffmeister/{{ .ProjectName }}:{{ .Version }}-arm64v8" + - "ghcr.io/choffmeister/{{ .ProjectName }}:latest-arm64v8" + use: buildx + goarch: arm64 + dockerfile: Dockerfile + build_flag_templates: + - "--platform=linux/arm64/v8" +docker_manifests: + - name_template: ghcr.io/choffmeister/{{ .ProjectName }}:{{ .Version }} + image_templates: + - ghcr.io/choffmeister/{{ .ProjectName }}:{{ .Version }}-amd64 + - ghcr.io/choffmeister/{{ .ProjectName }}:{{ .Version }}-arm64v8 + - name_template: ghcr.io/choffmeister/{{ .ProjectName }}:latest + image_templates: + - ghcr.io/choffmeister/{{ .ProjectName }}:latest-amd64 + - ghcr.io/choffmeister/{{ .ProjectName }}:latest-arm64v8 checksum: name_template: 'checksums.txt' snapshot: