1
1
REPO_ROOT: =${CURDIR}
2
2
OUT_DIR =$(REPO_ROOT ) /bin
3
- BINARY_NAME? =kube-network-policies
4
3
5
- # go1.9+ can autodetect GOROOT, but if some other tool sets it ...
6
- GOROOT: =
7
- # enable modules
4
+ # Go build settings
8
5
GO111MODULE =on
9
- # disable CGO by default for static binaries
10
6
CGO_ENABLED =0
11
- export GOROOT GO111MODULE CGO_ENABLED
7
+ export GO111MODULE CGO_ENABLED
12
8
9
+ # Docker image settings
10
+ IMAGE_NAME? =kube-network-policies
11
+ REGISTRY? =gcr.io/k8s-staging-networking
12
+ TAG? =$(shell echo "$$(date +v%Y%m%d ) -$$(git describe --always --dirty ) ")
13
+ PLATFORMS? =linux/amd64,linux/arm64
14
+
15
+ .PHONY : all build build-standard build-npa-v1alpha1
16
+ all : build
17
+ build : build-standard build-npa-v1alpha1
18
+
19
+ build-standard :
20
+ @echo " Building standard binary..."
21
+ go build -o ./bin/kube-network-policies-standard ./cmd/standard
13
22
14
- build :
15
- go build -v -o " $( OUT_DIR) /$( BINARY_NAME) " $(KIND_CLOUD_BUILD_FLAGS ) cmd/main.go
23
+ build-npa-v1alpha1 :
24
+ @echo " Building npa-v1alpha1 binary..."
25
+ go build -o ./bin/kube-network-policies-npa-v1alpha1 ./cmd/npa-v1alpha1
16
26
17
27
clean :
18
28
rm -rf " $( OUT_DIR) /"
19
29
20
30
test :
21
31
CGO_ENABLED=1 go test -v -race -count 1 ./...
22
32
23
- # code linters
24
33
lint :
25
34
hack/lint.sh
26
35
27
36
update :
28
37
go mod tidy
29
38
30
- # Generate Go code from the proto definition
31
39
proto :
32
40
hack/generate-proto.sh
33
41
34
- # get image name from directory we're building
35
- IMAGE_NAME =kube-network-policies
36
- # docker image registry, default to upstream
37
- REGISTRY? =gcr.io/k8s-staging-networking
38
- # tag based on date-sha
39
- TAG? =$(shell echo "$$(date +v%Y%m%d ) -$$(git describe --always --dirty ) ")
40
- # the full image tag
41
- KNP_IMAGE? =$(REGISTRY ) /$(IMAGE_NAME ) :$(TAG )
42
- PLATFORMS? =linux/amd64,linux/arm64
43
-
44
42
.PHONY : ensure-buildx
45
43
ensure-buildx :
46
44
./hack/init-buildx.sh
47
-
48
- image-build :
45
+
46
+ # Individual image build targets (load into local docker)
47
+ image-build-standard : build-standard
49
48
docker buildx build . \
50
- --tag=" ${KNP_IMAGE} " \
49
+ --build-arg TARGET_BUILD=standard \
50
+ --tag=" ${REGISTRY} /$( IMAGE_NAME) :$( TAG) " \
51
51
--load
52
52
53
- image-push :
53
+ image-build-npa-v1alpha1 : build-npa-v1alpha1
54
54
docker buildx build . \
55
+ --build-arg TARGET_BUILD=npa-v1alpha1 \
56
+ --tag=" ${REGISTRY} /$( IMAGE_NAME) :$( TAG) -npa-v1alpha1" \
57
+ --load
58
+
59
+ # Individual image push targets (multi-platform)
60
+ image-push-standard : build-standard
61
+ docker buildx build . \
62
+ --build-arg TARGET_BUILD=standard \
63
+ --platform=" ${PLATFORMS} " \
64
+ --tag=" ${REGISTRY} /$( IMAGE_NAME) :$( TAG) " \
65
+ --push
66
+
67
+ image-push-npa-v1alpha1 : build-npa-v1alpha1
68
+ docker buildx build . \
69
+ --build-arg TARGET_BUILD=npa-v1alpha1 \
55
70
--platform=" ${PLATFORMS} " \
56
- --tag=" ${KNP_IMAGE} " \
71
+ --tag=" ${REGISTRY} / $( IMAGE_NAME ) : $( TAG ) -npa-v1alpha1 " \
57
72
--push
58
73
59
- .PHONY : release # Build a multi-arch docker image
60
- release : ensure-buildx image-push
74
+ # --- Aggregate Targets ---
75
+ .PHONY : images-build images-push release
76
+
77
+ # Build all image variants and load them into the local Docker daemon
78
+ images-build : ensure-buildx image-build-standard image-build-npa-v1alpha1
79
+
80
+ # Build and push all multi-platform image variants to the registry
81
+ images-push : ensure-buildx image-push-standard image-push-npa-v1alpha1
82
+
83
+ # The main release target, which pushes all images
84
+ release : images-push
0 commit comments