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

feat: Build multiarch images #1257

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .github/workflows/build_and_package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ jobs:
with:
go-version: "1.22.5"

# install qemu binaries for multiarch builds (needed by goreleaser/buildx)
- name: Setup qemu
id: qemu
uses: docker/setup-qemu-action@v3

- name: Run GoReleaser
id: release
uses: goreleaser/goreleaser-action@b508e2e3ef3b19d4e4146d4f8fb3ba9db644a757 # v3.2.0
Expand Down
117 changes: 108 additions & 9 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,35 +85,134 @@ docker_signs:
args: ["sign", "--key=env://COSIGN_KEY", "--yes", "${artifact}"]
artifacts: all

# Build multiplatform images https://goreleaser.com/cookbooks/multi-platform-docker-images/
dockers:
# control-plane
- dockerfile: app/controlplane/Dockerfile.goreleaser
ids:
- control-plane
- chainloop-plugin-discord-webhook
- chainloop-plugin-smtp
- chainloop-plugin-dependency-track
image_templates:
- "ghcr.io/chainloop-dev/chainloop/control-plane:{{ .Tag }}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this potentially break the images in the charts? Because of the change in the tag basically

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that in the section below we are pushing this tag again, but as multiarch image instead. So basically nothing has changed.

- "ghcr.io/chainloop-dev/chainloop/control-plane:latest"
# Container image meant to perform migrations on the database at deployment time
- "ghcr.io/chainloop-dev/chainloop/control-plane:{{ .Tag }}-amd64"
use: buildx
build_flag_templates:
- "--pull"
- "--platform=linux/amd64"
- dockerfile: app/controlplane/Dockerfile.goreleaser
ids:
- control-plane
- chainloop-plugin-discord-webhook
- chainloop-plugin-smtp
- chainloop-plugin-dependency-track
image_templates:
- "ghcr.io/chainloop-dev/chainloop/control-plane:{{ .Tag }}-arm64"
use: buildx
build_flag_templates:
- "--pull"
- "--platform=linux/arm64"

# migrations: Container image meant to perform migrations on the database at deployment time
- dockerfile: app/controlplane/Dockerfile.migrations
extra_files:
- app/controlplane/pkg/data/ent/migrate/migrations
image_templates:
- "ghcr.io/chainloop-dev/chainloop/control-plane-migrations:{{ .Tag }}"
- "ghcr.io/chainloop-dev/chainloop/control-plane-migrations:latest"
- "ghcr.io/chainloop-dev/chainloop/control-plane-migrations:{{ .Tag }}-amd64"
use: buildx
build_flag_templates:
- "--pull"
- "--platform=linux/amd64"
- dockerfile: app/controlplane/Dockerfile.migrations
extra_files:
- app/controlplane/pkg/data/ent/migrate/migrations
image_templates:
- "ghcr.io/chainloop-dev/chainloop/control-plane-migrations:{{ .Tag }}-arm64"
use: buildx
build_flag_templates:
- "--pull"
- "--platform=linux/arm64"

# cas
- dockerfile: app/artifact-cas/Dockerfile.goreleaser
ids:
- artifact-cas
image_templates:
- "ghcr.io/chainloop-dev/chainloop/artifact-cas:{{ .Tag }}-amd64"
use: buildx
build_flag_templates:
- "--pull"
- "--platform=linux/amd64"
- dockerfile: app/artifact-cas/Dockerfile.goreleaser
ids:
- artifact-cas
image_templates:
- "ghcr.io/chainloop-dev/chainloop/artifact-cas:{{ .Tag }}"
- "ghcr.io/chainloop-dev/chainloop/artifact-cas:latest"
- "ghcr.io/chainloop-dev/chainloop/artifact-cas:{{ .Tag }}-arm64"
use: buildx
build_flag_templates:
- "--pull"
- "--platform=linux/arm64"

# CLI
- dockerfile: app/cli/Dockerfile.goreleaser
ids:
- cli
image_templates:
- "ghcr.io/chainloop-dev/chainloop/cli:{{ .Tag }}-amd64"
use: buildx
build_flag_templates:
- "--pull"
- "--platform=linux/amd64"
- dockerfile: app/cli/Dockerfile.goreleaser
ids:
- cli
image_templates:
- "ghcr.io/chainloop-dev/chainloop/cli:{{ .Tag }}"
- "ghcr.io/chainloop-dev/chainloop/cli:latest"
- "ghcr.io/chainloop-dev/chainloop/cli:{{ .Tag }}-arm64"
use: buildx
build_flag_templates:
- "--pull"
- "--platform=linux/arm64"

docker_manifests:
# control-plane
- name_template: "ghcr.io/chainloop-dev/chainloop/control-plane:{{ .Tag }}"
image_templates:
- "ghcr.io/chainloop-dev/chainloop/control-plane:{{ .Tag }}-amd64"
- "ghcr.io/chainloop-dev/chainloop/control-plane:{{ .Tag }}-arm64"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure we are tagging with

"ghcr.io/chainloop-dev/chainloop/control-plane:{{ .Tag }}"?

also, do we need to have a different tag? I thought that it was in the same tag?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tagging is done in docker_manifests section. Now {{ .Tag }} and latest are index manifests.

- name_template: "ghcr.io/chainloop-dev/chainloop/control-plane:latest"
image_templates:
- "ghcr.io/chainloop-dev/chainloop/control-plane:{{ .Tag }}-amd64"
- "ghcr.io/chainloop-dev/chainloop/control-plane:{{ .Tag }}-arm64"

# artifact-cas
- name_template: "ghcr.io/chainloop-dev/chainloop/artifact-cas:{{ .Tag }}"
image_templates:
- "ghcr.io/chainloop-dev/chainloop/artifact-cas:{{ .Tag }}-amd64"
- "ghcr.io/chainloop-dev/chainloop/artifact-cas:{{ .Tag }}-arm64"
- name_template: "ghcr.io/chainloop-dev/chainloop/artifact-cas:latest"
image_templates:
- "ghcr.io/chainloop-dev/chainloop/artifact-cas:{{ .Tag }}-amd64"
- "ghcr.io/chainloop-dev/chainloop/artifact-cas:{{ .Tag }}-arm64"

# control-plane-migrations
- name_template: "ghcr.io/chainloop-dev/chainloop/control-plane-migrations:{{ .Tag }}"
image_templates:
- "ghcr.io/chainloop-dev/chainloop/control-plane-migrations:{{ .Tag }}-amd64"
- "ghcr.io/chainloop-dev/chainloop/control-plane-migrations:{{ .Tag }}-arm64"
- name_template: "ghcr.io/chainloop-dev/chainloop/control-plane-migrations:latest"
image_templates:
- "ghcr.io/chainloop-dev/chainloop/control-plane-migrations:{{ .Tag }}-amd64"
- "ghcr.io/chainloop-dev/chainloop/control-plane-migrations:{{ .Tag }}-arm64"

# cli
- name_template: "ghcr.io/chainloop-dev/chainloop/cli:{{ .Tag }}"
image_templates:
- "ghcr.io/chainloop-dev/chainloop/cli:{{ .Tag }}-amd64"
- "ghcr.io/chainloop-dev/chainloop/cli:{{ .Tag }}-arm64"
- name_template: "ghcr.io/chainloop-dev/chainloop/cli:latest"
image_templates:
- "ghcr.io/chainloop-dev/chainloop/cli:{{ .Tag }}-amd64"
- "ghcr.io/chainloop-dev/chainloop/cli:{{ .Tag }}-arm64"

release:
extra_files:
Expand Down
Loading