-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathMakefile
More file actions
98 lines (86 loc) · 2.35 KB
/
Makefile
File metadata and controls
98 lines (86 loc) · 2.35 KB
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
# Set default ARCH, but allow it to be overridden
UNAME_ARCH := $(shell uname -m)
ifeq ($(UNAME_ARCH),x86_64)
ARCH ?= amd64
else ifeq ($(UNAME_ARCH),aarch64)
ARCH ?= arm64
else
ARCH ?= $(UNAME_ARCH)
endif
# Export ARCH so it's available to subshells (like the scripts)
export ARCH
PLATFORM ?= linux/$(ARCH)
.PHONY: all build integration-test-binary test validate ci package-helm image clean push-image
all: ci
build:
@echo "--- Building Webhook Binary ---"
@bash -c 'source scripts/version && \
mkdir -p bin && \
docker buildx build \
--file package/Dockerfile \
--target binary \
--build-arg VERSION=$${VERSION} \
--build-arg COMMIT=$${COMMIT} \
--platform=$(PLATFORM) \
--output=type=local,dest=./bin \
. '
integration-test-binary:
@echo "--- Building Integration Test Binary ---"
@bash -c 'source scripts/version && \
mkdir -p bin && \
docker buildx build \
--file package/Dockerfile \
--target integration-test-binary \
--platform=$(PLATFORM) \
--output=type=local,dest=./bin \
. '
test:
@echo "--- Running Unit Tests ---"
@docker buildx build \
--file package/Dockerfile \
--target test \
--progress=plain \
.
validate:
@echo "--- Validating ---"
@docker buildx build \
--file package/Dockerfile \
--target validate \
--progress=plain \
.
package-helm:
./scripts/package-helm
image: build
@echo "--- Building Development Image ---"
@bash -c 'source scripts/version && \
docker buildx build \
--file package/Dockerfile \
--build-arg VERSION=$${VERSION} \
--build-arg COMMIT=$${COMMIT} \
--platform=$(PLATFORM) \
-t rancher/webhook:$${TAG} \
--load \
. && \
mkdir -p dist && \
chmod a+rwx dist && \
docker save -o dist/rancher-webhook-image.tar rancher/webhook:$${TAG} && \
echo IMAGE_TAG=$${TAG} > dist/image_tag'
#push-image is used by the publish-image github action
push-image:
@echo "--- Building and Pushing Image ---"
@bash -c 'source scripts/version && \
docker buildx build \
$${IID_FILE_FLAG} \
--file package/Dockerfile \
--build-arg VERSION=$${VERSION} \
--build-arg COMMIT=$${COMMIT} \
--platform=$${TARGET_PLATFORMS} \
--sbom=true \
--attest type=provenance,mode=max \
-t $${REPO}/rancher-webhook:$${TAG} \
--push \
. '
# ci target is for CI, ensuring tests and validation run first
ci: test validate image package-helm
clean:
rm -rf bin dist