This repository has been archived by the owner on Jan 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
99 lines (81 loc) · 2.91 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Copyright 2017 Heptio Inc.
#
# 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.
# Note the only reason we are creating this is because upstream
# does not yet publish a released e2e container
# https://github.com/kubernetes/kubernetes/issues/47920
TARGET = sonobuoy-plugin-systemd-logs
GOTARGET = github.com/heptio/$(TARGET)
REGISTRY ?= gcr.io/heptio-images
IMAGE = $(REGISTRY)/$(TARGET)
DOCKER ?= docker
DIR := ${CURDIR}
VERSION ?= v0.2
ARCH ?= amd64
LINUX_ARCHS = amd64 arm64 ppc64le
PLATFORMS = linux/amd64,linux/arm64,linux/ppc64le
IMAGEARCH ?=
QEMUARCH ?=
MANIFEST_TOOL_VERSION := v1.0.0
ifneq ($(ARCH),amd64)
TARGET = sonobuoy-plugin-systemd-logs-$(ARCH)
endif
ifeq ($(ARCH),amd64)
IMAGEARCH =
QEMUARCH = x86_64
else ifeq ($(ARCH),arm)
IMAGEARCH = arm32v7/
QEMUARCH = arm
else ifeq ($(ARCH),arm64)
IMAGEARCH = arm64v8/
QEMUARCH = aarch64
else ifeq ($(ARCH),ppc64le)
IMAGEARCH = ppc64le/
QEMUARCH = ppc64le
else
$(error unknown arch "$(ARCH)")
endif
all: container
pre-cross:
docker run --rm --privileged multiarch/qemu-user-static:register --reset
build-container: get_systemd_logs.sh
$(DOCKER) build --build-arg IMAGEARCH=$(IMAGEARCH) \
--build-arg QEMUARCH=$(QEMUARCH) \
-t $(REGISTRY)/$(TARGET):latest -t $(REGISTRY)/$(TARGET):$(VERSION) .
container: pre-cross
for arch in $(LINUX_ARCHS); do \
$(MAKE) build-container ARCH=$$arch TARGET="sonobuoy-plugin-systemd-logs-$$arch"; \
done
push-image:
$(DOCKER) push $(REGISTRY)/$(TARGET):latest
$(DOCKER) push $(REGISTRY)/$(TARGET):$(VERSION)
push_manifest:
./manifest-tool -username oauth2accesstoken --password "`gcloud auth print-access-token`" push from-args --platforms $(PLATFORMS) --template $(REGISTRY)/$(TARGET)-ARCH:$(VERSION) --target $(REGISTRY)/$(TARGET):$(VERSION)
pre-push:
curl -sSL https://github.com/estesp/manifest-tool/releases/download/$(MANIFEST_TOOL_VERSION)/manifest-tool-linux-amd64 > manifest-tool
chmod +x manifest-tool
push: pre-push container
for arch in $(LINUX_ARCHS); do \
$(MAKE) push-image TARGET="sonobuoy-plugin-systemd-logs-$$arch"; \
done
$(MAKE) push_manifest VERSION=latest
$(MAKE) push_manifest
.PHONY: all container push
clean-image:
$(DOCKER) rmi $(REGISTRY)/$(TARGET):latest $(REGISTRY)/$(TARGET):latest || true
$(DOCKER) rmi $(REGISTRY)/$(TARGET):latest $(REGISTRY)/$(TARGET):$(VERSION) || true
clean:
rm -f manifest-tool*
for arch in $(LINUX_ARCHS); do \
$(MAKE) clean-image TARGET=$(TARGET)-$$arch; \
done