Skip to content

Commit

Permalink
add multi-platform container image build for arm64
Browse files Browse the repository at this point in the history
Signed-off-by: nscuro <[email protected]>
  • Loading branch information
nscuro committed Oct 23, 2021
1 parent 79ce2f3 commit 99f0f89
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Docker login
uses: docker/login-action@v1
with:
Expand Down
46 changes: 40 additions & 6 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ project_name: cyclonedx-gomod

before:
hooks:
# https://goreleaser.com/customization/build/#go-modules
- go mod tidy
# Prebuild a binary that'll be used to generate SBOMs later
- sh -c "VERSION={{ .Version }} make build"

gomod:
proxy: true

builds:
- env:
- CGO_ENABLED=0
Expand Down Expand Up @@ -35,19 +37,51 @@ dockers:
- goos: linux
goarch: amd64
dockerfile: Dockerfile.goreleaser
use: buildx
image_templates:
- "cyclonedx/{{ .ProjectName }}:{{ .Tag }}-amd64"
build_flag_templates:
- "--platform=linux/amd64"
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.version={{ .Tag }}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.vendor=CycloneDX"
- "--label=org.opencontainers.image.url=https://cyclonedx.org"
- "--label=org.opencontainers.image.source={{ .GitURL }}"
- goos: linux
goarch: arm64
dockerfile: Dockerfile.goreleaser
use: buildx
image_templates:
- "cyclonedx/cyclonedx-gomod:latest"
- "cyclonedx/cyclonedx-gomod:{{ .Tag }}"
- "cyclonedx/cyclonedx-gomod:v{{ .Major }}"
- "cyclonedx/cyclonedx-gomod:v{{ .Major }}.{{ .Minor }}"
- "cyclonedx/{{ .ProjectName }}:{{ .Tag }}-arm64"
build_flag_templates:
- "--platform=linux/arm64"
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.version={{ .Tag }}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.vendor=CycloneDX"
- "--label=org.opencontainers.image.url=https://cyclonedx.org"
- "--label=org.opencontainers.image.source=https:/CycloneDX/cyclonedx-gomod"
- "--label=org.opencontainers.image.source={{ .GitURL }}"

docker_manifests:
- name_template: "cyclonedx/{{ .ProjectName }}:latest"
image_templates:
- "cyclonedx/{{ .ProjectName }}:{{ .Tag }}-amd64"
- "cyclonedx/{{ .ProjectName }}:{{ .Tag }}-arm64"
- name_template: "cyclonedx/{{ .ProjectName }}:{{ .Tag }}"
image_templates:
- "cyclonedx/{{ .ProjectName }}:{{ .Tag }}-amd64"
- "cyclonedx/{{ .ProjectName }}:{{ .Tag }}-arm64"
- name_template: "cyclonedx/{{ .ProjectName }}:v{{ .Major }}"
image_templates:
- "cyclonedx/{{ .ProjectName }}:{{ .Tag }}-amd64"
- "cyclonedx/{{ .ProjectName }}:{{ .Tag }}-arm64"
- name_template: "cyclonedx/{{ .ProjectName }}:v{{ .Major }}.{{ .Minor }}"
image_templates:
- "cyclonedx/{{ .ProjectName }}:{{ .Tag }}-amd64"
- "cyclonedx/{{ .ProjectName }}:{{ .Tag }}-arm64"

archives:
- format_overrides:
Expand Down

0 comments on commit 99f0f89

Please sign in to comment.