Skip to content

Commit

Permalink
Add support for multi-arch Docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvargo committed Aug 11, 2022
1 parent 4f23705 commit 428d197
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
release:
runs-on: 'ubuntu-latest'
steps:
- uses: 'docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8' # ratchet:docker/setup-qemu-action@v2

- uses: 'actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b' # ratchet:actions/checkout@v3
with:
fetch-depth: 0
Expand Down
65 changes: 54 additions & 11 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ builds:
- 'GOPROXY=https://proxy.golang.org,direct'
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- '-a'
- '-trimpath'
ldflags:
- '-s'
Expand All @@ -19,30 +20,72 @@ builds:
- '-X=github.com/sethvargo/ratchet/internal/version.Version={{ .Version }}'
- '-X=github.com/sethvargo/ratchet/internal/version.Commit={{ .Commit }}'
- '-extldflags=-static'
targets:
- 'darwin_amd64'
- 'darwin_arm64'
- 'linux_amd64'
- 'linux_arm64'
- 'windows_amd64'
- 'windows_arm64'
goos:
- 'darwin'
- 'linux'
- 'windows'
goarch:
- 'amd64'
- 'arm64'
binary: '{{ .ProjectName }}'

dockers:
-
use: 'buildx'
image_templates:
- 'ghcr.io/sethvargo/{{ .ProjectName }}:{{ .Major }}'
- 'ghcr.io/sethvargo/{{ .ProjectName }}:{{ .Major }}.{{ .Minor }}'
- 'ghcr.io/sethvargo/{{ .ProjectName }}:{{ .Major }}.{{ .Minor }}.{{ .Patch }}'
- 'ghcr.io/sethvargo/{{ .ProjectName }}:latest'
- 'ghcr.io/sethvargo/{{ .ProjectName }}:{{ .Major }}-amd64'
- 'ghcr.io/sethvargo/{{ .ProjectName }}:{{ .Major }}.{{ .Minor }}-amd64'
- 'ghcr.io/sethvargo/{{ .ProjectName }}:{{ .Major }}.{{ .Minor }}.{{ .Patch }}-amd64'
- 'ghcr.io/sethvargo/{{ .ProjectName }}:latest-amd64'
build_flag_templates:
- '--platform=linux/amd64'
- '--pull'
- '--label=org.opencontainers.image.created={{ .CommitTimestamp }}'
- '--label=org.opencontainers.image.description=Ratchet is a tool for improving the security of CI/CD workflows by automating the process of pinning and unpinning upstream versions.'
- '--label=org.opencontainers.image.licenses=Apache-2.0'
- '--label=org.opencontainers.image.revision={{ .FullCommit }}'
- '--label=org.opencontainers.image.source=https://github.com/sethvargo/ratchet'
- '--label=org.opencontainers.image.title={{ .ProjectName }}'
- '--label=org.opencontainers.image.version={{ .Version }}'
-
use: 'buildx'
image_templates:
- 'ghcr.io/sethvargo/{{ .ProjectName }}:{{ .Major }}-arm64'
- 'ghcr.io/sethvargo/{{ .ProjectName }}:{{ .Major }}.{{ .Minor }}-arm64'
- 'ghcr.io/sethvargo/{{ .ProjectName }}:{{ .Major }}.{{ .Minor }}.{{ .Patch }}-arm64'
- 'ghcr.io/sethvargo/{{ .ProjectName }}:latest-arm64'
build_flag_templates:
- '--platform=linux/arm64'
- '--pull'
- '--label=org.opencontainers.image.created={{ .CommitTimestamp }}'
- '--label=org.opencontainers.image.description=Ratchet is a tool for improving the security of CI/CD workflows by automating the process of pinning and unpinning upstream versions.'
- '--label=org.opencontainers.image.licenses=Apache-2.0'
- '--label=org.opencontainers.image.revision={{ .FullCommit }}'
- '--label=org.opencontainers.image.source=https://github.com/sethvargo/ratchet'
- '--label=org.opencontainers.image.title={{ .ProjectName }}'
- '--label=org.opencontainers.image.version={{ .Version }}'

docker_manifests:
-
name_template: 'ghcr.io/sethvargo/{{ .ProjectName }}:{{ .Major }}'
image_templates:
- 'ghcr.io/sethvargo/{{ .ProjectName }}:{{ .Major }}-amd64'
- 'ghcr.io/sethvargo/{{ .ProjectName }}:{{ .Major }}-arm64'
-
name_template: 'ghcr.io/sethvargo/{{ .ProjectName }}:{{ .Major }}.{{ .Minor }}'
image_templates:
- 'ghcr.io/sethvargo/{{ .ProjectName }}:{{ .Major }}.{{ .Minor }}-amd64'
- 'ghcr.io/sethvargo/{{ .ProjectName }}:{{ .Major }}.{{ .Minor }}-arm64'
-
name_template: 'ghcr.io/sethvargo/{{ .ProjectName }}:{{ .Major }}.{{ .Minor }}.{{ .Patch }}'
image_templates:
- 'ghcr.io/sethvargo/{{ .ProjectName }}:{{ .Major }}.{{ .Minor }}.{{ .Patch }}-amd64'
- 'ghcr.io/sethvargo/{{ .ProjectName }}:{{ .Major }}.{{ .Minor }}.{{ .Patch }}-arm64'
-
name_template: 'ghcr.io/sethvargo/{{ .ProjectName }}:latest'
image_templates:
- 'ghcr.io/sethvargo/{{ .ProjectName }}:latest-amd64'
- 'ghcr.io/sethvargo/{{ .ProjectName }}:latest-arm64'

archives:
- format: 'tar.gz'
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine AS builder
FROM --platform=$BUILDPLATFORM alpine AS builder

FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
Expand Down

0 comments on commit 428d197

Please sign in to comment.