Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup multi-architecture docker containers in goreleaser #229

Merged
merged 2 commits into from
May 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 123 additions & 6 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ builds:
# don't include any paths to source files in the resulting binary
- -trimpath

mod_timestamp: '{{ .CommitTimestamp }}'

ldflags:
# set the version variable in the main package
- "-s -w -X main.version={{ .Version }}"
Expand Down Expand Up @@ -66,11 +68,23 @@ archives:
# package a directory which contains the source file
wrap_in_directory: true

builds_info: &archive_file_info
owner: root
group: root
mtime: '{{ .CommitDate }}'
mode: 0644

# add these files to all archives
files:
- LICENSE
- README.md
- CHANGELOG.md
- src: LICENSE
dst: .
info: *archive_file_info
- src: README.md
dst: .
info: *archive_file_info
- src: CHANGELOG.md
dst: .
info: *archive_file_info

# also build an archive of the source code
source:
Expand Down Expand Up @@ -98,12 +112,115 @@ changelog:
# configure building the rest-server docker image
dockers:
- image_templates:
- restic/rest-server:latest
- restic/rest-server:{{ .Version }}
- restic/rest-server:{{ .Version }}-amd64
build_flag_templates:
- "--platform=linux/amd64"
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.source=https://github.com/restic/{{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.licenses=BSD-2-Clause"
use: buildx
dockerfile: "Dockerfile.goreleaser"
extra_files:
extra_files: &extra_files
- docker/create_user
- docker/delete_user
- docker/entrypoint.sh
- image_templates:
- restic/rest-server:{{ .Version }}-i386
goarch: 386
build_flag_templates:
- "--platform=linux/386"
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.source=https://github.com/restic/{{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.licenses=BSD-2-Clause"
use: buildx
dockerfile: "Dockerfile.goreleaser"
extra_files: *extra_files
- image_templates:
- restic/rest-server:{{ .Version }}-arm32v6
goarch: arm
goarm: 6
build_flag_templates:
- "--platform=linux/arm/v6"
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.source=https://github.com/restic/{{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.licenses=BSD-2-Clause"
use: buildx
dockerfile: "Dockerfile.goreleaser"
extra_files: *extra_files
- image_templates:
- restic/rest-server:{{ .Version }}-arm32v7
goarch: arm
goarm: 7
build_flag_templates:
- "--platform=linux/arm/v7"
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.source=https://github.com/restic/{{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.licenses=BSD-2-Clause"
use: buildx
dockerfile: "Dockerfile.goreleaser"
extra_files: *extra_files
- image_templates:
- restic/rest-server:{{ .Version }}-arm64v8
goarch: arm64
build_flag_templates:
- "--platform=linux/arm64/v8"
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.source=https://github.com/restic/{{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.licenses=BSD-2-Clause"
use: buildx
dockerfile: "Dockerfile.goreleaser"
extra_files: *extra_files
- image_templates:
- restic/rest-server:{{ .Version }}-ppc64le
goarch: ppc64le
build_flag_templates:
- "--platform=linux/ppc64le"
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.source=https://github.com/restic/{{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.licenses=BSD-2-Clause"
use: buildx
dockerfile: "Dockerfile.goreleaser"
extra_files: *extra_files


docker_manifests:
- name_template: "restic/rest-server:{{ .Version }}"
image_templates:
- "restic/rest-server:{{ .Version }}-amd64"
- "restic/rest-server:{{ .Version }}-i386"
- "restic/rest-server:{{ .Version }}-arm32v6"
- "restic/rest-server:{{ .Version }}-arm32v7"
- "restic/rest-server:{{ .Version }}-arm64v8"
- "restic/rest-server:{{ .Version }}-ppc64le"
- name_template: "restic/rest-server:latest"
image_templates:
- "restic/rest-server:{{ .Version }}-amd64"
- "restic/rest-server:{{ .Version }}-i386"
- "restic/rest-server:{{ .Version }}-arm32v6"
- "restic/rest-server:{{ .Version }}-arm32v7"
- "restic/rest-server:{{ .Version }}-arm64v8"
- "restic/rest-server:{{ .Version }}-ppc64le"