Skip to content

Commit d9815c2

Browse files
authored
Merge pull request #181 from mauriciopoppe/armv7-support
Add support to build arm/v7 images
2 parents 4aedf35 + 05c1801 commit d9815c2

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

build.make

+15-13
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ endif
7070
# Specific packages can be excluded from each of the tests below by setting the *_FILTER_CMD variables
7171
# to something like "| grep -v 'github.com/kubernetes-csi/project/pkg/foobar'". See usage below.
7272

73-
# BUILD_PLATFORMS contains a set of tuples [os arch suffix base_image addon_image]
73+
# BUILD_PLATFORMS contains a set of tuples [os arch buildx_platform suffix base_image addon_image]
7474
# separated by semicolon. An empty variable or empty entry (= just a
7575
# semicolon) builds for the default platform of the current Go
7676
# toolchain.
@@ -85,20 +85,20 @@ FULL_LDFLAGS = $(LDFLAGS) $(IMPORTPATH_LDFLAGS) $(EXT_LDFLAGS)
8585
# defined by BUILD_PLATFORMS.
8686
$(CMDS:%=build-%): build-%: check-go-version-go
8787
mkdir -p bin
88-
# os_arch_seen captures all of the $$os-$$arch seen for the current binary
89-
# that we want to build, if we've seen an $$os-$$arch before it means that
88+
# os_arch_seen captures all of the $$os-$$arch-$$buildx_platform seen for the current binary
89+
# that we want to build, if we've seen an $$os-$$arch-$$buildx_platform before it means that
9090
# we don't need to build it again, this is done to avoid building
9191
# the windows binary multiple times (see the default value of $$BUILD_PLATFORMS)
92-
export os_arch_seen="" && echo '$(BUILD_PLATFORMS)' | tr ';' '\n' | while read -r os arch suffix base_image addon_image; do \
93-
os_arch_seen_pre=$${os_arch_seen%%$$os-$$arch*}; \
92+
export os_arch_seen="" && echo '$(BUILD_PLATFORMS)' | tr ';' '\n' | while read -r os arch buildx_platform suffix base_image addon_image; do \
93+
os_arch_seen_pre=$${os_arch_seen%%$$os-$$arch-$$buildx_platform*}; \
9494
if ! [ $${#os_arch_seen_pre} = $${#os_arch_seen} ]; then \
9595
continue; \
9696
fi; \
9797
if ! (set -x; cd ./$(CMDS_DIR)/$* && CGO_ENABLED=0 GOOS="$$os" GOARCH="$$arch" go build $(GOFLAGS_VENDOR) -a -ldflags '$(FULL_LDFLAGS)' -o "$(abspath ./bin)/$*$$suffix" .); then \
9898
echo "Building $* for GOOS=$$os GOARCH=$$arch failed, see error(s) above."; \
9999
exit 1; \
100100
fi; \
101-
os_arch_seen+=";$$os-$$arch"; \
101+
os_arch_seen+=";$$os-$$arch-$$buildx_platform"; \
102102
done
103103

104104
$(CMDS:%=container-%): container-%: build-%
@@ -154,16 +154,17 @@ $(CMDS:%=push-multiarch-%): push-multiarch-%: check-pull-base-ref build-%
154154
dockerfile_windows=$$(if [ -e ./$(CMDS_DIR)/$*/Dockerfile.Windows ]; then echo ./$(CMDS_DIR)/$*/Dockerfile.Windows; else echo Dockerfile.Windows; fi); \
155155
if [ '$(BUILD_PLATFORMS)' ]; then build_platforms='$(BUILD_PLATFORMS)'; else build_platforms="linux amd64"; fi; \
156156
if ! [ -f "$$dockerfile_windows" ]; then \
157-
build_platforms="$$(echo "$$build_platforms" | sed -e 's/windows *[^ ]* *.exe *[^ ]* *[^ ]*//g' -e 's/; *;/;/g' -e 's/;[ ]*$$//')"; \
157+
build_platforms="$$(echo "$$build_platforms" | sed -e 's/windows *[^ ]* *[^ ]* *.exe *[^ ]* *[^ ]*//g' -e 's/; *;/;/g' -e 's/;[ ]*$$//')"; \
158158
fi; \
159159
pushMultiArch () { \
160160
tag=$$1; \
161-
echo "$$build_platforms" | tr ';' '\n' | while read -r os arch suffix base_image addon_image; do \
161+
echo "$$build_platforms" | tr ';' '\n' | while read -r os arch buildx_platform suffix base_image addon_image; do \
162162
escaped_base_image=$${base_image/:/-}; \
163+
escaped_buildx_platform=$${buildx_platform//\//-}; \
163164
if ! [ -z $$escaped_base_image ]; then escaped_base_image+="-"; fi; \
164165
docker buildx build --push \
165-
--tag $(IMAGE_NAME):$$arch-$$os-$$escaped_base_image$$tag \
166-
--platform=$$os/$$arch \
166+
--tag $(IMAGE_NAME):$$escaped_buildx_platform-$$os-$$escaped_base_image$$tag \
167+
--platform=$$os/$$buildx_platform \
167168
--file $$(eval echo \$${dockerfile_$$os}) \
168169
--build-arg binary=./bin/$*$$suffix \
169170
--build-arg ARCH=$$arch \
@@ -172,13 +173,14 @@ $(CMDS:%=push-multiarch-%): push-multiarch-%: check-pull-base-ref build-%
172173
--label revision=$(REV) \
173174
.; \
174175
done; \
175-
images=$$(echo "$$build_platforms" | tr ';' '\n' | while read -r os arch suffix base_image addon_image; do \
176+
images=$$(echo "$$build_platforms" | tr ';' '\n' | while read -r os arch buildx_platform suffix base_image addon_image; do \
176177
escaped_base_image=$${base_image/:/-}; \
178+
escaped_buildx_platform=$${buildx_platform//\//-}; \
177179
if ! [ -z $$escaped_base_image ]; then escaped_base_image+="-"; fi; \
178-
echo $(IMAGE_NAME):$$arch-$$os-$$escaped_base_image$$tag; \
180+
echo $(IMAGE_NAME):$$escaped_buildx_platform-$$os-$$escaped_base_image$$tag; \
179181
done); \
180182
docker manifest create --amend $(IMAGE_NAME):$$tag $$images; \
181-
echo "$$build_platforms" | tr ';' '\n' | while read -r os arch suffix base_image addon_image; do \
183+
echo "$$build_platforms" | tr ';' '\n' | while read -r os arch buildx_platform suffix base_image addon_image; do \
182184
if [ $$os = "windows" ]; then \
183185
escaped_base_image=$${base_image/:/-}; \
184186
if ! [ -z $$escaped_base_image ]; then escaped_base_image+="-"; fi; \

prow.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ version_to_git () {
7878
# the list of windows versions was matched from:
7979
# - https://hub.docker.com/_/microsoft-windows-nanoserver
8080
# - https://hub.docker.com/_/microsoft-windows-servercore
81-
configvar CSI_PROW_BUILD_PLATFORMS "linux amd64; linux ppc64le -ppc64le; linux s390x -s390x; linux arm -arm; linux arm64 -arm64; windows amd64 .exe nanoserver:1809 servercore:ltsc2019; windows amd64 .exe nanoserver:1909 servercore:1909; windows amd64 .exe nanoserver:2004 servercore:2004; windows amd64 .exe nanoserver:20H2 servercore:20H2; windows amd64 .exe nanoserver:ltsc2022 servercore:ltsc2022" "Go target platforms (= GOOS + GOARCH) and file suffix of the resulting binaries"
81+
configvar CSI_PROW_BUILD_PLATFORMS "linux amd64 amd64; linux ppc64le ppc64le -ppc64le; linux s390x s390x -s390x; linux arm arm -arm; linux arm64 arm64 -arm64; linux arm arm/v7 -armv7; windows amd64 amd64 .exe nanoserver:1809 servercore:ltsc2019; windows amd64 amd64 .exe nanoserver:1909 servercore:1909; windows amd64 amd64 .exe nanoserver:2004 servercore:2004; windows amd64 amd64 .exe nanoserver:20H2 servercore:20H2; windows amd64 amd64 .exe nanoserver:ltsc2022 servercore:ltsc2022" "Go target platforms (= GOOS + GOARCH) and file suffix of the resulting binaries"
8282

8383
# If we have a vendor directory, then use it. We must be careful to only
8484
# use this for "make" invocations inside the project's repo itself because

0 commit comments

Comments
 (0)