Skip to content
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

Make image-user test images multi-arch #300

Merged
merged 1 commit into from
May 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions hack/make-rules/BASEIMAGES
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
amd64=amd64
arm=arm32v6
arm64=arm64v8
ppc64le=ppc64le
s390x=s390x
30 changes: 30 additions & 0 deletions hack/make-rules/Makefile.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

.PHONY: manifest-tool

MANIFEST_TOOL_DIR := $(shell mktemp -d)
export PATH := $(MANIFEST_TOOL_DIR):$(PATH)

MANIFEST_TOOL_VERSION := v0.7.0

space :=
space +=
comma := ,
prefix_linux = $(addprefix linux/,$(strip $1))
join_platforms = $(subst $(space),$(comma),$(call prefix_linux,$(strip $1)))

manifest-tool:
curl -sSL https://github.com/estesp/manifest-tool/releases/download/$(MANIFEST_TOOL_VERSION)/manifest-tool-linux-amd64 > $(MANIFEST_TOOL_DIR)/manifest-tool
chmod +x $(MANIFEST_TOOL_DIR)/manifest-tool
3 changes: 2 additions & 1 deletion images/image-user/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM busybox
ARG ARCH
FROM $ARCH/busybox
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems there are no arm/busybox and arm64/busybox images?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@feiskyer : Should we use arm32v7 and arm64v8 ? Reference

Copy link
Member

@mkumatag mkumatag May 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we have to use arm32v7 and arm64v8 but these does not match the architecture value what you get via go env

ARG USER
USER ${USER}
28 changes: 20 additions & 8 deletions images/image-user/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,34 @@
# See the License for the specific language governing permissions and
# limitations under the License.

include ../../hack/make-rules/Makefile.manifest
include ../../hack/make-rules/BASEIMAGES

.PHONY: all test-image-user-uid test-image-user-username test-image-user-uid-group test-image-user-username-group

REGISTRY = gcr.io/cri-tools
ALL_ARCH = amd64 arm arm64 ppc64le s390x
TAG = latest
IMAGES_LIST = test-image-user-uid test-image-user-username test-image-user-uid-group test-image-user-username-group

all: test-image-user-uid test-image-user-username test-image-user-uid-group test-image-user-username-group

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

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


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

test-image-user-username-group:
docker build . -t gcr.io/cri-tools/$@ --build-arg USER=www-data:100
gcloud docker -- push gcr.io/cri-tools/$@
$(foreach arch,$(ALL_ARCH),docker build . -t $(REGISTRY)/$@-$(arch) --build-arg ARCH=$($(arch)) --build-arg USER=www-data:100 ;)
$(foreach arch,$(ALL_ARCH),docker push $(REGISTRY)/$@-$(arch);)

push-manifest: manifest-tool
$(foreach image,$(IMAGES_LIST),manifest-tool push from-args --platforms $(call join_platforms,$(ALL_ARCH)) --template $(REGISTRY)/$(image)-ARCH:$(TAG) --target $(REGISTRY)/$(image):$(TAG);)