-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathMakefile
76 lines (64 loc) · 1.67 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
SEVERITIES = HIGH,CRITICAL
UNAME_M = $(shell uname -m)
ARCH=
ifeq ($(UNAME_M), x86_64)
ARCH=amd64
else ifeq ($(UNAME_M), aarch64)
ARCH=arm64
else
ARCH=$(UNAME_M)
endif
ifeq ($(OS),)
OS=$(shell go env GOOS)
endif
ifeq ($(OS),windows)
DOCKERFILE=Dockerfile.windows
else
DOCKERFILE=Dockerfile
endif
BUILD_META=-build$(shell TZ=UTC date +%Y%m%d)
ORG ?= rancher
PKG ?= github.com/containerd/containerd
SRC ?= github.com/k3s-io/containerd
TAG ?= v2.0.2-k3s1$(BUILD_META)
ifneq (${GITHUB_ACTION_TAG},)
TAG = ${GITHUB_ACTION_TAG}
endif
ifeq (,$(filter %$(BUILD_META),$(TAG)))
$(error TAG needs to end with build metadata)
endif
.PHONY: image-build
image-build:
docker build \
--pull \
--build-arg PKG=$(PKG) \
--build-arg SRC=$(SRC) \
--build-arg TAG=$(TAG:$(BUILD_META)=) \
--build-arg ARCH=$(ARCH) \
--build-arg GOOS=$(OS) \
--tag $(ORG)/hardened-containerd:$(TAG)-$(ARCH)-$(OS) \
--file $(DOCKERFILE) \
.
.PHONY: image-push
image-push:
docker push $(ORG)/hardened-containerd:$(TAG)-$(ARCH)-$(OS)
.PHONY: image-manifest
image-manifest:
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create --amend \
$(ORG)/hardened-containerd:$(TAG) \
$(ORG)/hardened-containerd:$(TAG)-$(ARCH)-$(OS)
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push \
$(ORG)/hardened-containerd:$(TAG)
.PHONY: image-scan
image-scan:
trivy image --severity $(SEVERITIES) --no-progress --ignore-unfixed $(ORG)/hardened-containerd:$(TAG)-$(ARCH)-$(OS)
.PHONY: log
log:
@echo "ARCH=$(ARCH)"
@echo "TAG=$(TAG:$(BUILD_META)=)"
@echo "ORG=$(ORG)"
@echo "PKG=$(PKG)"
@echo "SRC=$(SRC)"
@echo "BUILD_META=$(BUILD_META)"
@echo "K3S_ROOT_VERSION=$(K3S_ROOT_VERSION)"
@echo "UNAME_M=$(UNAME_M)"