From 2397e7c6c2a74896f2536eb1dbc732caac63572d Mon Sep 17 00:00:00 2001 From: Ryan Eschinger Date: Tue, 28 Dec 2021 22:39:45 -0500 Subject: [PATCH] multi-platform image build (#22) --- .github/workflows/release.yaml | 14 ++++++---- .goreleaser.yml | 49 +++++++++++++++++++++++++++------- 2 files changed, 49 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c789b58..2574f14 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -6,18 +6,22 @@ on: jobs: goreleaser: runs-on: ubuntu-latest + env: + DOCKER_CLI_EXPERIMENTAL: "enabled" steps: - name: Checkout uses: actions/checkout@v2 - - name: Setup Go - uses: actions/setup-go@v2 - with: - go-version: 1.17 - - name: Login to Docker Hub + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Docker Login uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: 1.17 - name: GoReleaser uses: goreleaser/goreleaser-action@v2 with: diff --git a/.goreleaser.yml b/.goreleaser.yml index 184207e..f124e8e 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -9,6 +9,9 @@ builds: - windows - linux - darwin + goarch: + - amd64 + - arm64 # Default is `-s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} -X main.builtBy=goreleaser`. ldflags: - -s -w -X github.com/ryane/kfilt/cmd.Version={{.Version}} -X github.com/ryane/kfilt/cmd.GitCommit={{.ShortCommit}} @@ -29,15 +32,43 @@ changelog: - Merge pull request - Merge branch dockers: -- goos: linux - goarch: amd64 - goarm: '' - image_templates: - - "ryane/{{.ProjectName}}:latest" - - "ryane/{{.ProjectName}}:{{ .Tag }}" +- image_templates: + - "ryane/{{.ProjectName}}:{{ .Tag }}-amd64" + skip_push: false + dockerfile: Dockerfile + use: buildx + build_flag_templates: + - --platform=linux/amd64 + - --label=org.opencontainers.image.title={{ .ProjectName }} + - --label=org.opencontainers.image.description={{ .ProjectName }} + - --label=org.opencontainers.image.url=https://github.com/ryane/{{ .ProjectName }} + - --label=org.opencontainers.image.source=https://github.com/ryane/{{ .ProjectName }} + - --label=org.opencontainers.image.version={{ .Version }} + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} + - --label=org.opencontainers.image.licenses=Apache-2.0 +- image_templates: + - "ryane/{{.ProjectName}}:{{ .Tag }}-arm64v8" + goarch: arm64 skip_push: false dockerfile: Dockerfile + use: buildx build_flag_templates: - - "--label=org.label-schema.schema-version=1.0" - - "--label=org.label-schema.version={{.Version}}" - - "--label=org.label-schema.name={{.ProjectName}}" + - --platform=linux/arm64/v8 + - --label=org.opencontainers.image.title={{ .ProjectName }} + - --label=org.opencontainers.image.description={{ .ProjectName }} + - --label=org.opencontainers.image.url=https://github.com/ryane/{{ .ProjectName }} + - --label=org.opencontainers.image.source=https://github.com/ryane/{{ .ProjectName }} + - --label=org.opencontainers.image.version={{ .Version }} + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} + - --label=org.opencontainers.image.licenses=Apache-2.0 +docker_manifests: +- name_template: "ryane/{{ .ProjectName }}:{{ .Tag }}" + image_templates: + - "ryane/{{ .ProjectName }}:{{ .Tag }}-amd64" + - "ryane/{{ .ProjectName }}:{{ .Tag }}-arm64v8" +- name_template: "ryane/{{ .ProjectName }}:latest" + image_templates: + - "ryane/{{ .ProjectName }}:{{ .Tag }}-amd64" + - "ryane/{{ .ProjectName }}:{{ .Tag }}-arm64v8"