@@ -43,12 +43,22 @@ COVERAGE := pipenv run coverage
43
43
# Only set if not defined
44
44
VERSION ?= dev
45
45
46
+ # Docker related
47
+ DOCKER_REGISTRY_ICR := icr.io
48
+ DOCKER_USER_ICR := iamapikey
49
+ DOCKER_PASS_ICR := $(IBM_CLOUD_API_KEY )
50
+
46
51
# Trivy related
47
52
TRIVY ?= trivy
48
53
TRIVY_VERSION := $(shell curl -s "https://api.github.com/repos/aquasecurity/trivy/releases/latest" | grep '"tag_name":' | sed -E 's/.* "v([^"]+) ".*/\1/')
49
54
TRIVY_OS := $(shell uname | sed 's/Darwin/macOS/' )
50
55
TRIVY_ARCH := $(shell uname -m | cut -d_ -f2 )
51
56
57
+ # Cosign related
58
+ COSIGN ?= /tmp/cosign
59
+ COSIGN_VERSION := $(shell curl -s "https://api.github.com/repos/sigstore/cosign/releases/latest" | grep '"tag_name":' | sed -E 's/.* "v([^"]+) ".*/\1/')
60
+
61
+
52
62
.PHONY : setup-trivy
53
63
setup-trivy :
54
64
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/master/contrib/install.sh | sudo sh -s -- -b /usr/local/bin
@@ -57,6 +67,11 @@ ifdef TRAVIS
57
67
sudo apt update && sudo apt install rpm -y
58
68
endif
59
69
70
+ .PHONY : setup-cosign
71
+ setup-cosign :
72
+ curl -sSfL https://github.com/sigstore/cosign/releases/download/v$(COSIGN_VERSION ) /cosign-linux-amd64 -o $(COSIGN )
73
+ chmod +x $(COSIGN )
74
+
60
75
.PHONY : setup-deploy-tools
61
76
setup-deploy-tools :
62
77
curl -Lo container-structure-test https://storage.googleapis.com/container-structure-test/latest/container-structure-test-$(shell uname | tr '[:upper:]' '[:lower:]') -amd64 && sudo install container-structure-test /usr/local/bin/
@@ -68,7 +83,7 @@ setup-deploy-tools:
68
83
kustomize version
69
84
70
85
.PHONY : setup
71
- setup : setup-trivy setup-deploy-tools
86
+ setup : setup-trivy setup-cosign setup- deploy-tools
72
87
pip install --upgrade pip
73
88
pip install " setuptools>=65.5.1" pipenv
74
89
PIP_IGNORE_INSTALLED=1 pipenv install --dev --deploy --ignore-pipfile
@@ -163,6 +178,8 @@ endif
163
178
# login to cr and set region
164
179
@ibmcloud cr region-set global
165
180
@ibmcloud cr login
181
+ # login to cosign
182
+ @echo $(DOCKER_PASS_ICR) | $(COSIGN) login -u $(DOCKER_USER_ICR) --password-stdin $(DOCKER_REGISTRY_ICR)
166
183
167
184
.PHONY : build-images
168
185
build-images :
@@ -182,6 +199,13 @@ quality-images:
182
199
.PHONY : deploy
183
200
deploy :
184
201
skaffold build
202
+ for image in $( shell skaffold build -q --dry-run | jq -r .builds[].tag) ; do \
203
+ @echo " Signing image $$ {image}" ; \
204
+ $(COSIGN ) sign --key env://COSIGN_PRIVATE_KEY --yes $$ {image}; \
205
+
206
+ @echo "Verifying image $${image}; \
207
+ $(COSIGN) verify --key env://COSIGN_PUBLIC_KEY $${image}; \
208
+ done;
185
209
186
210
.PHONY : clean
187
211
clean :
0 commit comments