Skip to content

Commit

Permalink
build: Build multi-arch (linux/amd64, linux/arm64) image using buildx
Browse files Browse the repository at this point in the history
  • Loading branch information
dlipovetsky authored and kaiwalyajoshi committed Feb 29, 2024
1 parent 05d9036 commit 3eee897
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
16 changes: 5 additions & 11 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
release:
name: Release
runs-on:
# For a list of pre-installed software, see https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md
- ubuntu-22.04
steps:
- uses: actions/checkout@v3
Expand All @@ -31,29 +32,22 @@ jobs:
registry: ${{ env.registry }}
username: ${{ env.registry_username }}
password: ${{ env.registry_password }}
- name: Generate container image
- name: Build multi-arch container image, and push to container registry
# Note: We set make variables using positional arguments (to the right of the make command), not environment
# variables (to the left of the make command). While make converts environment variables to make variables, the
# conversion is not straightforward. For example, conditional assignments are not overriden by environment
# variables.
run: |
make generate-capvcd-image \
REGISTRY=${{ env.registry }} \
CAPVCD_IMG=${{ env.repository }} \
VERSION=${{ env.version }}
- name: Push container image to container registry
# See note on make variables, above.
run: |
make push-capvcd-image \
--makefile d2iq.Makefile \
REGISTRY=${{ env.registry }} \
CAPVCD_IMG=${{ env.repository }} \
VERSION=${{ env.version }}
- name: Generate GitHub release artifacts
# See note on make variables, above.
#
# We use our own Makefile to allow us to change the image in the manifest.
run: |
make -f d2iq.Makefile release-manifests \
make release-manifests \
--makefile d2iq.Makefile
REGISTRY=${{ env.registry }} \
CAPVCD_IMG=${{ env.repository }} \
VERSION=${{ env.version }}
Expand Down
20 changes: 20 additions & 0 deletions d2iq.Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
include Makefile

PLATFORMS := "linux/amd64,linux/arm64"

# The multi-platform build must push its output to a registry, because the Docker Engine image store does not support
# multi-platform images. This will be addressed when Docker Engine supports the containerd image store. See
# https://docs.docker.com/storage/containerd.
.PHONY: push-capvcd-image
push-capvcd-image: docker-buildx-builder generate fmt vet vendor
docker buildx build \
--builder capvcd \
--platform $(PLATFORMS) \
--output=type=registry \
--build-arg VERSION=$(VERSION) \
--tag $(REGISTRY)/$(CAPVCD_IMG):$(VERSION) \
--file Dockerfile \
.

.PHONY: docker-buildx-builder
docker-buildx-builder:
docker buildx inspect --bootstrap capvcd &>/dev/null || docker buildx create --name capvcd

# The upstream 'release-manifests' target does not correctly override the image.
# We work around this by using `kustomize edit set image`.
release-manifests: kustomize
Expand Down

0 comments on commit 3eee897

Please sign in to comment.