-
Notifications
You must be signed in to change notification settings - Fork 99
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
2fb3e93
35127f2
74c44a0
50943f5
bb43a91
bff393b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 \ | ||
|
@@ -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. | ||
.PHONY: buildx | ||
buildx: | ||
@if [ -z "$$VERSION" ]; then \ | ||
echo "VERSION is required"; \ | ||
exit 1; \ | ||
fi | ||
docker buildx build --platform linux/amd64,linux/arm64 --push . | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these the only two platforms we want to support initially? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
Bwvolleyball marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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 oldbuild
andpush
tasks can be used for testing / development things.