Skip to content

Commit 340e082

Browse files
committed
build.make: optional inclusion of Windows in multiarch images
Most repos inherit the default BUILD_PLATFORMS, which includes Windows, but don't have the necessary Dockerfile.Windows yet. To simplify the rollout of multiarch image builds, Windows binary building continues to be tested (i.e. BUILD_PLATFORMS remains unchanged), but push-multiarch skips Windows if the Dockerfile.Windows is missing.
1 parent 5231f05 commit 340e082

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

build.make

+7
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ DOCKER_BUILDX_CREATE_ARGS ?=
117117
# Docker Buildx is included in Docker 19.03.
118118
#
119119
# ./cmd/<command>/Dockerfile[.Windows] is used if found, otherwise Dockerfile[.Windows].
120+
# It is currently optional: if no such file exists, Windows images are not included,
121+
# even when Windows is listed in BUILD_PLATFORMS. That way, projects can test that
122+
# Windows binaries can be built before adding a Dockerfile for it.
123+
#
120124
# BUILD_PLATFORMS determines which individual images are included in the multiarch image.
121125
# PULL_BASE_REF must be set to 'master', 'release-x.y', or a tag name, and determines
122126
# the tag for the resulting multiarch image.
@@ -129,6 +133,9 @@ $(CMDS:%=push-multiarch-%): push-multiarch-%: check-pull-base-ref build-%
129133
dockerfile_linux=$$(if [ -e ./cmd/$*/Dockerfile ]; then echo ./cmd/$*/Dockerfile; else echo Dockerfile; fi); \
130134
dockerfile_windows=$$(if [ -e ./cmd/$*/Dockerfile.Windows ]; then echo ./cmd/$*/Dockerfile.Windows; else echo Dockerfile.Windows; fi); \
131135
if [ '$(BUILD_PLATFORMS)' ]; then build_platforms='$(BUILD_PLATFORMS)'; else build_platforms="linux amd64"; fi; \
136+
if ! [ -f "$$dockerfile_windows" ]; then \
137+
build_platforms="$$(echo "$$build_platforms" | sed -e 's/windows *[^ ]* *.exe//g' -e 's/; *;/;/g')"; \
138+
fi; \
132139
pushMultiArch () { \
133140
tag=$$1; \
134141
echo "$$build_platforms" | tr ';' '\n' | while read -r os arch suffix; do \

0 commit comments

Comments
 (0)