File tree Expand file tree Collapse file tree 6 files changed +53
-21
lines changed Expand file tree Collapse file tree 6 files changed +53
-21
lines changed Original file line number Diff line number Diff line change @@ -1024,6 +1024,7 @@ jobs:
1024
1024
# Necessary to push docker images to ghcr.io.
1025
1025
packages : write
1026
1026
# Necessary for GCP authentication (https://github.com/google-github-actions/setup-gcloud#usage)
1027
+ # Also necessary for keyless cosign (https://docs.sigstore.dev/cosign/signing/overview/)
1027
1028
id-token : write
1028
1029
env :
1029
1030
DOCKER_CLI_EXPERIMENTAL : " enabled"
@@ -1069,6 +1070,16 @@ jobs:
1069
1070
- name : Install zstd
1070
1071
run : sudo apt-get install -y zstd
1071
1072
1073
+ - name : Install cosign
1074
+ uses : sigstore/cosign-installer@d7d6bc7722e3daa8354c50bcb52f4837da5e9b6a # v3.8.1
1075
+ with :
1076
+ cosign-release : " v2.4.3"
1077
+
1078
+ - name : Install syft
1079
+ uses : anchore/sbom-action/download-syft@f325610c9f50a54015d37c8d16cb3b0e2c8f4de0 # v0.18.0
1080
+ with :
1081
+ syft-version : " v1.20.0"
1082
+
1072
1083
- name : Setup Windows EV Signing Certificate
1073
1084
run : |
1074
1085
set -euo pipefail
Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ jobs:
122
122
# Necessary to push docker images to ghcr.io.
123
123
packages : write
124
124
# Necessary for GCP authentication (https://github.com/google-github-actions/setup-gcloud#usage)
125
+ # Also necessary for keyless cosign (https://docs.sigstore.dev/cosign/signing/overview/)
125
126
id-token : write
126
127
env :
127
128
# Necessary for Docker manifest
@@ -246,6 +247,16 @@ jobs:
246
247
apple-codesign-0.22.0-x86_64-unknown-linux-musl/rcodesign
247
248
rm /tmp/rcodesign.tar.gz
248
249
250
+ - name : Install cosign
251
+ uses : sigstore/cosign-installer@d7d6bc7722e3daa8354c50bcb52f4837da5e9b6a # v3.8.1
252
+ with :
253
+ cosign-release : " v2.4.3"
254
+
255
+ - name : Install syft
256
+ uses : anchore/sbom-action/download-syft@f325610c9f50a54015d37c8d16cb3b0e2c8f4de0 # v0.18.0
257
+ with :
258
+ syft-version : " v1.20.0"
259
+
249
260
- name : Setup Apple Developer certificate and API key
250
261
run : |
251
262
set -euo pipefail
Original file line number Diff line number Diff line change @@ -278,7 +278,9 @@ ARG CLOUD_SQL_PROXY_VERSION=2.2.0 \
278
278
KUBECTX_VERSION=0.9.4 \
279
279
STRIPE_VERSION=1.14.5 \
280
280
TERRAGRUNT_VERSION=0.45.11 \
281
- TRIVY_VERSION=0.41.0
281
+ TRIVY_VERSION=0.41.0 \
282
+ SYFT_VERSION=1.20.0 \
283
+ COSIGN_VERSION=2.4.3
282
284
283
285
# cloud_sql_proxy, for connecting to cloudsql instances
284
286
# the upstream go.mod prevents this from being installed with go install
@@ -316,7 +318,13 @@ RUN curl --silent --show-error --location --output /usr/local/bin/cloud_sql_prox
316
318
chmod a=rx /usr/local/bin/terragrunt && \
317
319
# AquaSec Trivy for scanning container images for security issues
318
320
curl --silent --show-error --location "https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz" | \
319
- tar --extract --gzip --directory=/usr/local/bin --file=- trivy
321
+ tar --extract --gzip --directory=/usr/local/bin --file=- trivy && \
322
+ # Anchore Syft for SBOM generation
323
+ curl --silent --show-error --location "https://github.com/anchore/syft/releases/download/v${SYFT_VERSION}/syft_${SYFT_VERSION}_linux-amd64.tar.gz" | \
324
+ tar --extract --gzip --directory=/usr/local/bin --file=- syft \
325
+ # Sigstore Cosign for artifact signing and attestation
326
+ curl --silent --show-error --location --output /usr/local/bin/cosign "https://github.com/sigstore/cosign/releases/download/v${COSIGN_VERSION}/cosign-linux-amd64" && \
327
+ chmod a=rx /usr/local/bin/cosign
320
328
321
329
# We use yq during "make deploy" to manually substitute out fields in
322
330
# our helm values.yaml file. See https://github.com/helm/helm/issues/3141
Original file line number Diff line number Diff line change 113
113
bat
114
114
cairo
115
115
curl
116
+ cosign
116
117
delve
117
118
dive
118
119
drpc . defaultPackage . ${ system }
161
162
shellcheck
162
163
( pinnedPkgs . shfmt )
163
164
sqlc
165
+ syft
164
166
unstablePkgs . terraform
165
167
typos
166
168
which
Original file line number Diff line number Diff line change 136
136
137
137
log " --- Building Docker image for $arch ($image_tag )"
138
138
139
- docker buildx build \
139
+ docker build \
140
140
--platform " $arch " \
141
141
--build-arg " BASE_IMAGE=$base_image " \
142
142
--build-arg " CODER_VERSION=$version " \
143
- --provenance true \
144
- --sbom true \
145
143
--no-cache \
146
144
--tag " $image_tag " \
147
145
-f Dockerfile \
@@ -155,4 +153,17 @@ if [[ "$push" == 1 ]]; then
155
153
docker push " $image_tag " 1>&2
156
154
fi
157
155
156
+ log " --- Generating SBOM for Docker image ($image_tag )"
157
+ syft " $image_tag " -o spdx-json > " ${image_tag} .spdx.json"
158
+
159
+ if [[ " $push " == 1 ]]; then
160
+ log " --- Attesting SBOM to Docker image for $arch ($image_tag )"
161
+ COSIGN_EXPERIMENTAL=1 cosign clean " $image_tag "
162
+
163
+ COSIGN_EXPERIMENTAL=1 cosign attest --type spdxjson \
164
+ --predicate " ${image_tag} .spdx.json" \
165
+ --yes \
166
+ " $image_tag "
167
+ fi
168
+
158
169
echo " $image_tag "
Original file line number Diff line number Diff line change 77
77
78
78
# Sadly, manifests don't seem to support labels.
79
79
log " --- Creating multi-arch Docker image ($target )"
80
-
81
- # Create a buildx builder instance if it doesn't exist
82
- if ! docker buildx inspect multiarch-builder & > /dev/null; then
83
- docker buildx create --name multiarch-builder --use
84
- fi
85
-
86
- # Create manifest with buildx imagetools
87
- log " --- Creating multi-arch manifest with attestations"
88
-
89
- # For images with attestations, we preserve the entire structure by using image tags directly,
90
- # letting Docker handle retrieving both the architecture manifests and attestation manifests
91
- docker buildx imagetools create --tag " $target " " $@ "
80
+ docker manifest create \
81
+ " $target " \
82
+ " ${create_args[@]} "
92
83
93
84
if [[ " $push " == 1 ]]; then
94
- log " --- Verifying multi-arch Docker image ($target )"
95
- # The manifest is already created and pushed when using buildx imagetools create
96
- # We just need to verify it exists
97
- docker buildx imagetools inspect " $target "
85
+ log " --- Pushing multi-arch Docker image ($target )"
86
+ docker manifest push " $target "
98
87
fi
99
88
100
89
echo " $target "
You can’t perform that action at this time.
0 commit comments