Skip to content

Commit 44dfb03

Browse files
committed
Clarification: docker build will use system's arch, not always amd64
1 parent b4b4472 commit 44dfb03

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

Makefile

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ help:
4949

5050

5151
build/%: DARGS?=
52-
build/%: ## build the latest image for a stack on amd64 only
53-
@echo "::group::Build $(OWNER)/$(notdir $@) (amd64)"
52+
build/%: ## build the latest image for a stack using the system's architecture
53+
@echo "::group::Build $(OWNER)/$(notdir $@) (system's architecture)"
54+
docker build $(DARGS) --rm --force-rm -t $(OWNER)/$(notdir $@):latest ./$(notdir $@) --build-arg OWNER=$(OWNER)
5455
docker build $(DARGS) --rm --force-rm -t $(OWNER)/$(notdir $@):latest ./$(notdir $@) --build-arg OWNER=$(OWNER)
5556
@echo -n "Built image size: "
5657
@docker images $(OWNER)/$(notdir $@):latest --format "{{.Size}}"
57-
@echo "::endgroup::Build $(OWNER)/$(notdir $@) (amd64)"
58+
@echo "::endgroup::Build $(OWNER)/$(notdir $@) (system's architecture)"
5859
build-all: $(foreach I,$(ALL_IMAGES), build/$(I) ) ## build all stacks
5960

6061
# Limitations on docker buildx build (using docker/buildx 0.5.1):
@@ -70,8 +71,9 @@ build-all: $(foreach I,$(ALL_IMAGES), build/$(I) ) ## build all stacks
7071
#
7172
# Workarounds due to limitations:
7273
#
73-
# 1. We always make a dedicated amd64 build named as OWNER/<stack>-notebook so
74-
# we always can reference that image no matter what.
74+
# 1. We always build a dedicated image using the current system architecture
75+
# named as OWNER/<stack>-notebook so we always can reference that image no
76+
# matter what during tests etc.
7577
#
7678
# 2. We always also build a multi-platform image during build-multi that will be
7779
# inaccessible with `docker tag` and `docker push` etc, but this will help us
@@ -80,7 +82,8 @@ build-all: $(foreach I,$(ALL_IMAGES), build/$(I) ) ## build all stacks
8082
#
8183
# 3. We let push-multi refer to rebuilding a multi image with `--push`.
8284
#
83-
# We now rely on the cached layer.
85+
# We can rely on the cached layer from build-multi now even though we never
86+
# tagged the multi image.
8487
#
8588
# Outcomes of the workaround:
8689
#
@@ -91,13 +94,17 @@ build-all: $(foreach I,$(ALL_IMAGES), build/$(I) ) ## build all stacks
9194
# architectures as well, then we can build and publish such images via the
9295
# `-multi` suffix without needing a local registry.
9396
#
97+
# 3. If we get dedicated arm64 runners, we can test everything separately
98+
# without needing to update this Makefile, and if all tests succeeds we can
99+
# do a publish job that creates a multi-platform image for us.
100+
#
94101
build-multi/%: DARGS?=
95-
build-multi/%: ## build the latest image for a stack on amd64 and arm64
96-
@echo "::group::Build $(OWNER)/$(notdir $@) (amd64)"
97-
docker buildx build $(DARGS) --rm --force-rm -t $(OWNER)$(notdir $@):latest ./$(notdir $@) --build-arg OWNER=$(OWNER) --platform "linux/amd64" --load
102+
build-multi/%: ## build the latest image for a stack on both amd64 and arm64
103+
@echo "::group::Build $(OWNER)/$(notdir $@) (system's architecture)"
104+
docker buildx build $(DARGS) --rm --force-rm -t $(OWNER)/$(notdir $@):latest ./$(notdir $@) --build-arg OWNER=$(OWNER)
98105
@echo -n "Built image size: "
99106
@docker images $(OWNER)/$(notdir $@):latest --format "{{.Size}}"
100-
@echo "::endgroup::Build $(OWNER)/$(notdir $@) (amd64)"
107+
@echo "::endgroup::Build $(OWNER)/$(notdir $@) (system's architecture)"
101108

102109
@echo "::group::Build $(OWNER)/$(notdir $@) (amd64,arm64)"
103110
docker buildx build $(DARGS) --rm --force-rm -t build-multi-tmp-cache/$(notdir $@):latest ./$(notdir $@) --build-arg OWNER=$(OWNER) --platform "linux/amd64,linux/arm64"
@@ -174,9 +181,9 @@ pull-all: $(foreach I,$(ALL_IMAGES),pull/$(I)) ## pull all images
174181

175182
push/%: DARGS?=
176183
push/%: ## push all tags for a jupyter image
177-
@echo "::group::Push $(OWNER)/$(notdir $@) (amd64)"
184+
@echo "::group::Push $(OWNER)/$(notdir $@) (system's architecture)"
178185
docker push --all-tags $(DARGS) $(OWNER)/$(notdir $@)
179-
@echo "::endgroup::Push $(OWNER)/$(notdir $@) (amd64)"
186+
@echo "::endgroup::Push $(OWNER)/$(notdir $@) (system's architecture)"
180187
push-all: $(foreach I,$(ALL_IMAGES),push/$(I) ) ## push all tagged images
181188

182189
push-multi/%: DARGS?=

0 commit comments

Comments
 (0)