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
[WIP] Multi-architecture container images #2397
Changes from all commits
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 |
---|---|---|
|
@@ -144,9 +144,25 @@ run: | |
.PHONY: docker-component # Not intended to be used directly | ||
docker-component: check-component | ||
GOOS=linux GOARCH=amd64 $(MAKE) $(COMPONENT) | ||
cp ./bin/$(COMPONENT)_linux_amd64 ./cmd/$(COMPONENT)/$(COMPONENT) | ||
docker build -t $(COMPONENT) ./cmd/$(COMPONENT)/ | ||
rm ./cmd/$(COMPONENT)/$(COMPONENT) | ||
cp ./bin/$(COMPONENT)_linux_amd64 ./cmd/$(COMPONENT) | ||
docker build -t $(COMPONENT) ./cmd/$(COMPONENT)/ --build-arg=TARGETOS=linux --build-arg=TARGETARCH=amd64 | ||
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. Is it simpler to use buildx for this too so we don't need to define the args? 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. My opinion at this time is to make the multi-architecture build additive and not require buildx for all contributors. Since 'make docker-otelcontribcol' is pre-existing, I believe it should continue to work without contributors updating their tooling. If contributors want to build multi-arch images, then they'll need to install buildx (doesn't seem common at this time). Maybe after we have buildx working as expected in the CI/CD pipeline and are okay with requiring contributors to install an experimental tool, then we can fully migrate to buildx. I'm hoping that buildx will be fully baked into Docker this year, so it will become a natural progression. |
||
rm ./cmd/$(COMPONENT)/$(COMPONENT)_linux_amd64 | ||
|
||
# Requires Docker buildx = v0.5.1 https://github.com/docker/buildx | ||
export DOCKER_BUILDX_PLATFORMS ?= linux/amd64,linux/arm64 | ||
.PHONY: docker-cross-build-component # Not intended to be used directly | ||
docker-cross-build-component: check-component | ||
PLATFORMS='$(shell echo ${DOCKER_BUILDX_PLATFORMS} | sed "s/,/ /g")'; \ | ||
for platform in $${PLATFORMS}; do \ | ||
IFS='/' osAndArch=($$platform); \ | ||
GOOS=$${osAndArch[0]}; \ | ||
GOARCH=$${osAndArch[1]}; \ | ||
GOOS=$${osAndArch[0]} GOARCH=$${osAndArch[1]} $(MAKE) $(COMPONENT); \ | ||
cp ./bin/$(COMPONENT)_$${GOOS}_$${GOARCH} ./cmd/$(COMPONENT)/; \ | ||
done | ||
docker buildx rm $(COMPONENT) | ||
docker buildx create --use --name $(COMPONENT) | ||
docker buildx build --platform ${DOCKER_BUILDX_PLATFORMS} -t $(COMPONENT) ./cmd/$(COMPONENT) | ||
|
||
.PHONY: check-component | ||
check-component: | ||
|
@@ -158,6 +174,10 @@ endif | |
docker-otelcontribcol: | ||
COMPONENT=otelcontribcol $(MAKE) docker-component | ||
|
||
.PHONY: docker-cross-build-otelcontribcol | ||
docker-cross-build-otelcontribcol: | ||
COMPONENT=otelcontribcol $(MAKE) docker-cross-build-component | ||
|
||
.PHONY: generate | ||
generate: | ||
$(MAKE) for-all CMD="go generate ./..." | ||
|
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.
Oh forgot this was still circleci, doh!