Skip to content

Commit 6ae7b25

Browse files
authored
Merge pull request #300 from nitkon/master
Make image-user test images multi-arch
2 parents ed19775 + 9b29b59 commit 6ae7b25

File tree

4 files changed

+57
-9
lines changed

4 files changed

+57
-9
lines changed

hack/make-rules/BASEIMAGES

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
amd64=amd64
2+
arm=arm32v6
3+
arm64=arm64v8
4+
ppc64le=ppc64le
5+
s390x=s390x

hack/make-rules/Makefile.manifest

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2018 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
.PHONY: manifest-tool
16+
17+
MANIFEST_TOOL_DIR := $(shell mktemp -d)
18+
export PATH := $(MANIFEST_TOOL_DIR):$(PATH)
19+
20+
MANIFEST_TOOL_VERSION := v0.7.0
21+
22+
space :=
23+
space +=
24+
comma := ,
25+
prefix_linux = $(addprefix linux/,$(strip $1))
26+
join_platforms = $(subst $(space),$(comma),$(call prefix_linux,$(strip $1)))
27+
28+
manifest-tool:
29+
curl -sSL https://github.com/estesp/manifest-tool/releases/download/$(MANIFEST_TOOL_VERSION)/manifest-tool-linux-amd64 > $(MANIFEST_TOOL_DIR)/manifest-tool
30+
chmod +x $(MANIFEST_TOOL_DIR)/manifest-tool

images/image-user/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM busybox
15+
ARG ARCH
16+
FROM $ARCH/busybox
1617
ARG USER
1718
USER ${USER}

images/image-user/Makefile

+20-8
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,34 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
include ../../hack/make-rules/Makefile.manifest
16+
include ../../hack/make-rules/BASEIMAGES
17+
1518
.PHONY: all test-image-user-uid test-image-user-username test-image-user-uid-group test-image-user-username-group
1619

20+
REGISTRY = gcr.io/cri-tools
21+
ALL_ARCH = amd64 arm arm64 ppc64le s390x
22+
TAG = latest
23+
IMAGES_LIST = test-image-user-uid test-image-user-username test-image-user-uid-group test-image-user-username-group
24+
1725
all: test-image-user-uid test-image-user-username test-image-user-uid-group test-image-user-username-group
1826

1927
test-image-user-uid:
20-
docker build . -t gcr.io/cri-tools/$@ --build-arg USER=1002
21-
gcloud docker -- push gcr.io/cri-tools/$@
28+
$(foreach arch,$(ALL_ARCH),docker build . -t $(REGISTRY)/$@-$(arch) --build-arg ARCH=$($(arch)) --build-arg USER=1002;)
29+
$(foreach arch,$(ALL_ARCH),docker push $(REGISTRY)/$@-$(arch);)
2230

2331
test-image-user-username:
24-
docker build . -t gcr.io/cri-tools/$@ --build-arg USER=www-data
25-
gcloud docker -- push gcr.io/cri-tools/$@
32+
$(foreach arch,$(ALL_ARCH),docker build . -t $(REGISTRY)/$@-$(arch) --build-arg ARCH=$($(arch)) --build-arg USER=www-data;)
33+
$(foreach arch,$(ALL_ARCH),docker push $(REGISTRY)/$@-$(arch);)
34+
2635

2736
test-image-user-uid-group:
28-
docker build . -t gcr.io/cri-tools/$@ --build-arg USER=1003:users
29-
gcloud docker -- push gcr.io/cri-tools/$@
37+
$(foreach arch,$(ALL_ARCH),docker build . -t $(REGISTRY)/$@-$(arch) --build-arg ARCH=$($(arch)) --build-arg USER=1003:users ;)
38+
$(foreach arch,$(ALL_ARCH),docker push $(REGISTRY)/$@-$(arch);)
3039

3140
test-image-user-username-group:
32-
docker build . -t gcr.io/cri-tools/$@ --build-arg USER=www-data:100
33-
gcloud docker -- push gcr.io/cri-tools/$@
41+
$(foreach arch,$(ALL_ARCH),docker build . -t $(REGISTRY)/$@-$(arch) --build-arg ARCH=$($(arch)) --build-arg USER=www-data:100 ;)
42+
$(foreach arch,$(ALL_ARCH),docker push $(REGISTRY)/$@-$(arch);)
43+
44+
push-manifest: manifest-tool
45+
$(foreach image,$(IMAGES_LIST),manifest-tool push from-args --platforms $(call join_platforms,$(ALL_ARCH)) --template $(REGISTRY)/$(image)-ARCH:$(TAG) --target $(REGISTRY)/$(image):$(TAG);)

0 commit comments

Comments
 (0)