1
1
2
2
.PHONY : default
3
- default : base-image load-balancer proxy tapa ipam nsp ctraffic frontend
3
+ default :
4
+ $(MAKE ) -s $(IMAGES )
4
5
5
6
.PHONY : all
6
7
all : default
@@ -12,6 +13,8 @@ help: ## Display this help.
12
13
# Variables
13
14
# ###########################################################################
14
15
16
+ IMAGES ?= base-image load-balancer proxy tapa ipam nsp ctraffic frontend
17
+
15
18
# Versions
16
19
VERSION ?= latest
17
20
VERSION_LOAD_BALANCER ?= $(VERSION )
@@ -42,11 +45,14 @@ GINKGO = $(shell pwd)/bin/ginkgo
42
45
MOCKGEN = $(shell pwd) /bin/mockgen
43
46
PROTOC_GEN_GO = $(shell pwd) /bin/protoc-gen-go
44
47
PROTOC_GEN_GO_GRPC = $(shell pwd) /bin/protoc-gen-go-grpc
48
+ NANCY = $(shell pwd) /bin/nancy
45
49
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST ) ) ) )
46
50
47
51
BUILD_DIR ?= build
48
52
BUILD_STEPS ?= build tag push
49
53
54
+ OUTPUT_DIR ?= _output/
55
+
50
56
# ############################################################################
51
57
# Container: Build, tag, push
52
58
# ############################################################################
@@ -67,39 +73,39 @@ push:
67
73
68
74
.PHONY : base-image
69
75
base-image : # # Build the base-image
70
- VERSION=$(VERSION_BASE_IMAGE ) IMAGE=base-image $(MAKE ) $(BUILD_STEPS )
76
+ VERSION=$(VERSION_BASE_IMAGE ) IMAGE=base-image $(MAKE ) -s $(BUILD_STEPS )
71
77
72
78
.PHONY : debug-image
73
79
debug-image : # # Build the debug-image
74
80
docker build -t $(DEBUG_IMAGE ) -f ./build/debug/Dockerfile .
75
81
76
82
.PHONY : load-balancer
77
83
load-balancer : # # Build the load-balancer.
78
- VERSION=$(VERSION_LOAD_BALANCER ) IMAGE=load-balancer $(MAKE ) $(BUILD_STEPS )
84
+ VERSION=$(VERSION_LOAD_BALANCER ) IMAGE=load-balancer $(MAKE ) -s $(BUILD_STEPS )
79
85
80
86
.PHONY : proxy
81
87
proxy : # # Build the proxy.
82
- VERSION=$(VERSION_PROXY ) IMAGE=proxy $(MAKE ) $(BUILD_STEPS )
88
+ VERSION=$(VERSION_PROXY ) IMAGE=proxy $(MAKE ) -s $(BUILD_STEPS )
83
89
84
90
.PHONY : tapa
85
91
tapa : # # Build the tapa.
86
- VERSION=$(VERSION_TAPA ) IMAGE=tapa $(MAKE ) $(BUILD_STEPS )
92
+ VERSION=$(VERSION_TAPA ) IMAGE=tapa $(MAKE ) -s $(BUILD_STEPS )
87
93
88
94
.PHONY : ipam
89
95
ipam : # # Build the ipam.
90
- VERSION=$(VERSION_IPAM ) IMAGE=ipam $(MAKE ) $(BUILD_STEPS )
96
+ VERSION=$(VERSION_IPAM ) IMAGE=ipam $(MAKE ) -s $(BUILD_STEPS )
91
97
92
98
.PHONY : nsp
93
99
nsp : # # Build the nsp.
94
- VERSION=$(VERSION_NSP ) IMAGE=nsp $(MAKE ) $(BUILD_STEPS )
100
+ VERSION=$(VERSION_NSP ) IMAGE=nsp $(MAKE ) -s $(BUILD_STEPS )
95
101
96
102
.PHONY : ctraffic
97
103
ctraffic : # # Build the ctraffic.
98
- VERSION=$(VERSION_CTRAFFIC ) IMAGE=ctraffic $(MAKE ) $(BUILD_STEPS )
104
+ VERSION=$(VERSION_CTRAFFIC ) IMAGE=ctraffic $(MAKE ) -s $(BUILD_STEPS )
99
105
100
106
.PHONY : frontend
101
107
frontend : # # Build the frontend.
102
- VERSION=$(VERSION_FRONTEND ) IMAGE=frontend $(MAKE ) $(BUILD_STEPS )
108
+ VERSION=$(VERSION_FRONTEND ) IMAGE=frontend $(MAKE ) -s $(BUILD_STEPS )
103
109
104
110
# ############################################################################
105
111
# #@ Testing & Code check
@@ -133,6 +139,38 @@ cover:
133
139
.PHONY : check
134
140
check : lint test # # Run the linter and the Unit tests.
135
141
142
+ # ############################################################################
143
+ # #@ Security Scan
144
+ # ############################################################################
145
+
146
+ # https://github.com/anchore/grype
147
+ .PHONY : grype
148
+ grype : # # Run grype scanner on images.
149
+ @BUILD_STEPS=grype-scan $(MAKE ) -s $(IMAGES )
150
+
151
+ .PHONY : grype-scan
152
+ grype-scan : output-dir
153
+ docker run --rm \
154
+ --volume /var/run/docker.sock:/var/run/docker.sock \
155
+ --name Grype anchore/grype:v0.47.0 \
156
+ $(REGISTRY ) /$(IMAGE ) :$(VERSION ) --add-cpes-if-none > $(OUTPUT_DIR ) /grype_$(IMAGE ) _$(VERSION ) .txt
157
+
158
+ # https://github.com/aquasecurity/trivy
159
+ .PHONY : trivy
160
+ trivy : # # Run trivy scanner on images.
161
+ @BUILD_STEPS=trivy-scan $(MAKE ) -s $(IMAGES )
162
+
163
+ .PHONY : trivy-scan
164
+ trivy-scan : output-dir
165
+ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
166
+ -v $(HOME ) /Library/Caches :/root/.cache/ aquasec/trivy:0.31.3 image \
167
+ $(REGISTRY ) /$(IMAGE ) :$(VERSION ) > $(OUTPUT_DIR ) /trivy_$(IMAGE ) _$(VERSION ) .txt
168
+
169
+ # https://github.com/sonatype-nexus-community/nancy
170
+ .PHONY : nancy
171
+ nancy : nancy-tool # # Run nancy scanner on dependencies.
172
+ go list -json -deps ./... | nancy sleuth
173
+
136
174
# ############################################################################
137
175
# #@ Code generation
138
176
# ############################################################################
@@ -160,6 +198,10 @@ proto: ipam-proto nsp-proto ambassador-proto ## Compile the proto.
160
198
# Tools
161
199
# ############################################################################
162
200
201
+ .PHONY : output-dir
202
+ output-dir :
203
+ mkdir -p $(OUTPUT_DIR )
204
+
163
205
.PHONY : golangci-lint
164
206
golangci-lint :
165
207
$(call go-get-tool,$(GOLANGCI_LINT ) ,github.com/golangci/golangci-lint/cmd/[email protected] )
@@ -189,6 +231,10 @@ mockgen:
189
231
ginkgo :
190
232
$(call go-get-tool,$(GINKGO ) ,github.com/onsi/ginkgo/v2/[email protected] )
191
233
234
+ .PHONY : nancy-tool
235
+ nancy-tool :
236
+ $(call go-get-tool,$(NANCY ) ,github.com/sonatype-nexus-community/[email protected] )
237
+
192
238
# go-get-tool will 'go get' any package $2 and install it to $1.
193
239
define go-get-tool
194
240
@[ -f $(1 ) ] || { \
0 commit comments