@@ -78,6 +78,8 @@ class BuildImageJob extends JobWithSource {
78
78
let registryOrg : string
79
79
let registryUsername : string
80
80
let registryPassword : string
81
+ let signingSetupCommands = ""
82
+ let signingCommand = ""
81
83
if ( ! version ) { // This is where we'll push potentially unstable images
82
84
registry = secrets . unstableImageRegistry
83
85
registryOrg = secrets . unstableImageRegistryOrg
@@ -90,6 +92,16 @@ class BuildImageJob extends JobWithSource {
90
92
registryPassword = secrets . stableImageRegistryPassword
91
93
// Since it's defined, the make target will want this env var
92
94
env [ "VERSION" ] = version
95
+ env [ "BASE64_IMAGE_SIGNING_KEY" ] = secrets . base64ImageSigningKey
96
+ // This env var is documented here:
97
+ // https://docs.docker.com/engine/security/trust/trust_automation/
98
+ env [ "DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE" ] = secrets . imageSigningKeyPassphrase
99
+ const keyDir = "~/.docker/trust/private"
100
+ const keyFile = `${ keyDir } /${ secrets . imageSigningKeyHash } .key`
101
+ signingSetupCommands = `mkdir -p ${ keyDir } && chmod 700 ${ keyDir } && ` +
102
+ `printf $BASE64_IMAGE_SIGNING_KEY | base64 -d > ${ keyFile } && chmod 600 ${ keyFile } && ` +
103
+ `docker trust key load --name ${ registryUsername } ${ keyFile } && `
104
+ signingCommand = ` && make sign-${ image } `
93
105
}
94
106
if ( registry ) {
95
107
// Since it's defined, the make target will want this env var
@@ -118,9 +130,11 @@ class BuildImageJob extends JobWithSource {
118
130
// probably up and running.
119
131
"sleep 20 && " +
120
132
`${ registriesLoginCmd } && ` +
133
+ signingSetupCommands +
121
134
"docker buildx create --name builder --use && " +
122
135
"docker info && " +
123
- `make push-${ image } `
136
+ `make push-${ image } ` +
137
+ signingCommand
124
138
]
125
139
this . sidecarContainers . dind = new Container ( dindImg )
126
140
this . sidecarContainers . dind . privileged = true
0 commit comments