-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
70 lines (60 loc) · 1.6 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
SEVERITIES = HIGH,CRITICAL
UNAME_M = $(shell uname -m)
ifndef TARGET_PLATFORMS
ifeq ($(UNAME_M), x86_64)
TARGET_PLATFORMS:=linux/amd64
else ifeq ($(UNAME_M), aarch64)
TARGET_PLATFORMS:=linux/arm64
else
TARGET_PLATFORMS:=linux/$(UNAME_M)
endif
endif
BUILD_META=-build$(shell date +%Y%m%d)
# the metrics server has been moved to https://github.com/kubernetes-sigs/metrics-server
# but still refers internally to github.com/kubernetes-incubator/metrics-server packages
PKG ?= github.com/kubernetes-incubator/metrics-server
SRC ?= github.com/kubernetes-sigs/metrics-server
TAG ?= ${GITHUB_ACTION_TAG}
ifeq ($(TAG),)
TAG := v0.7.2$(BUILD_META)
endif
ifeq (,$(filter %$(BUILD_META),$(TAG)))
$(error TAG $(TAG) needs to end with build metadata: $(BUILD_META))
endif
REPO ?= rancher
IMAGE = $(REPO)/hardened-k8s-metrics-server:$(TAG)
BUILD_OPTS = \
--platform=$(TARGET_PLATFORMS) \
--build-arg PKG=$(PKG) \
--build-arg SRC=$(SRC) \
--build-arg TAG=$(TAG:$(BUILD_META)=) \
--target k8s-metrics-server \
--tag "$(IMAGE)"
.PHONY: image-build
image-build:
docker buildx build \
$(BUILD_OPTS) \
--load \
.
.PHONY: push-image
push-image:
docker buildx build \
$(BUILD_OPTS) \
$(IID_FILE_FLAG) \
--sbom=true \
--attest type=provenance,mode=max \
--push \
.
.PHONY: image-scan
image-scan:
trivy image --severity $(SEVERITIES) --no-progress --ignore-unfixed $(IMAGE)
PHONY: log
log:
@echo "TAG=$(TAG:$(BUILD_META)=)"
@echo "REPO=$(REPO)"
@echo "IMAGE=$(IMAGE)"
@echo "PKG=$(PKG)"
@echo "SRC=$(SRC)"
@echo "BUILD_META=$(BUILD_META)"
@echo "UNAME_M=$(UNAME_M)"
@echo "TARGET_PLATFORMS=$(TARGET_PLATFORMS)"