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

Add a makefile command to assist with multi-arch builds #68

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
IMAGE_REPO=ghcr.io/trstringer/manual-approval

# Great for building a single architecture's image
.PHONY: build
build:
@if [ -z "$$VERSION" ]; then \
Expand All @@ -23,3 +24,14 @@ test:
.PHONY: lint
lint:
docker run --rm -v $$(pwd):/app -w /app golangci/golangci-lint:v1.46.2 golangci-lint run -v

# Builds multiple architectures at once.
# Requires docker buildx and QEMU to be configured.
# Because of how docker buildx works, in that it _must_ push when it builds, push is the default of this task.
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure I understand why a push is required. Why do we want our build command to automatically push the image?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a nuance of how buildx works. It doesn't allow for building first, then pushing later, so, if you want to push the image that is produced by the multi-arch build, it has to be done at build time with this flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ultimately, this buildx tasks should be what is used for CI/CD to build and push multi-arch images, and the old build and push tasks can be used for testing / development things.

.PHONY: buildx
buildx:
@if [ -z "$$VERSION" ]; then \
echo "VERSION is required"; \
exit 1; \
fi
docker buildx build --platform linux/amd64,linux/arm64 --push .
Copy link
Owner

Choose a reason for hiding this comment

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

Are these the only two platforms we want to support initially?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

these 2 platforms are the easiest to support out of the gate, I figured more could be added later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, oops, just realized that I forgot the tags, I think we need to add this to the command: -t $(IMAGE_REPO):$$VERSION

Bwvolleyball marked this conversation as resolved.
Show resolved Hide resolved