2021-10-30 09:50:23 -03:00
|
|
|
# Signing Docker Images and Manifests
|
2021-08-24 11:22:09 -03:00
|
|
|
|
|
|
|
Signing Docker Images and Manifests is also possible with GoReleaser.
|
2022-09-17 00:13:09 -03:00
|
|
|
This pipe was designed based on the common [sign](/customization/sign/) pipe
|
|
|
|
having [cosign](https://github.com/sigstore/cosign) in mind.
|
2021-08-24 11:22:09 -03:00
|
|
|
|
|
|
|
!!! info
|
2022-09-17 00:13:09 -03:00
|
|
|
Note that this pipe will run only at the end of the GoReleaser execution (in
|
|
|
|
its publishing phase), as cosign will change the image in the registry.
|
2021-08-24 11:22:09 -03:00
|
|
|
|
|
|
|
|
|
|
|
To customize the signing pipeline you can use the following options:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
# .goreleaser.yml
|
|
|
|
docker_signs:
|
|
|
|
-
|
|
|
|
# ID of the sign config, must be unique.
|
|
|
|
# Only relevant if you want to produce some sort of signature file.
|
|
|
|
#
|
2023-04-02 17:16:21 -03:00
|
|
|
# Default: 'default'
|
2021-08-24 11:22:09 -03:00
|
|
|
id: foo
|
|
|
|
|
|
|
|
# Path to the signature command
|
|
|
|
#
|
2023-04-02 17:16:21 -03:00
|
|
|
# Default: 'cosign'
|
2021-08-24 11:22:09 -03:00
|
|
|
cmd: cosign
|
|
|
|
|
2023-04-02 17:16:21 -03:00
|
|
|
# Command line arguments for the command
|
2021-08-24 11:22:09 -03:00
|
|
|
#
|
2023-04-02 17:16:21 -03:00
|
|
|
# Templates: allowed
|
|
|
|
# Default: ["sign", "--key=cosign.key", "${artifact}@${digest}", "--yes"]
|
2023-03-02 15:11:43 -03:00
|
|
|
args:
|
|
|
|
- "sign"
|
|
|
|
- "--key=cosign.key"
|
|
|
|
- "--upload=false"
|
|
|
|
- "${artifact}"
|
|
|
|
- "--yes" # needed on cosign 2.0.0+
|
2021-08-24 11:22:09 -03:00
|
|
|
|
|
|
|
|
|
|
|
# Which artifacts to sign
|
|
|
|
#
|
|
|
|
# all: all artifacts
|
|
|
|
# none: no signing
|
|
|
|
# images: only docker images
|
|
|
|
# manifests: only docker manifests
|
|
|
|
#
|
2023-04-02 17:16:21 -03:00
|
|
|
# Default: 'none'
|
2021-08-24 11:22:09 -03:00
|
|
|
artifacts: all
|
|
|
|
|
|
|
|
# IDs of the artifacts to sign.
|
|
|
|
ids:
|
|
|
|
- foo
|
|
|
|
- bar
|
|
|
|
|
2023-04-02 17:16:21 -03:00
|
|
|
# Stdin data to be given to the signature command as stdin.
|
|
|
|
#
|
|
|
|
# Templates: allowed
|
2021-09-15 13:50:43 +02:00
|
|
|
stdin: '{{ .Env.COSIGN_PWD }}'
|
2021-08-24 11:22:09 -03:00
|
|
|
|
|
|
|
# StdinFile file to be given to the signature command as stdin.
|
|
|
|
stdin_file: ./.password
|
2021-11-11 22:56:03 -03:00
|
|
|
|
|
|
|
# List of environment variables that will be passed to the signing command as well as the templates.
|
|
|
|
env:
|
|
|
|
- FOO=bar
|
|
|
|
- HONK=honkhonk
|
2021-12-06 10:07:47 -03:00
|
|
|
|
|
|
|
# By default, the stdout and stderr of the signing cmd are discarded unless GoReleaser is running with `--debug` set.
|
|
|
|
# You can set this to true if you want them to be displayed regardless.
|
|
|
|
#
|
2023-04-02 17:16:21 -03:00
|
|
|
# Since: v1.2
|
2021-12-06 10:07:47 -03:00
|
|
|
output: true
|
2021-08-24 11:22:09 -03:00
|
|
|
```
|
|
|
|
|
2021-11-11 22:56:03 -03:00
|
|
|
### Available variable names
|
|
|
|
|
|
|
|
These environment variables might be available in the fields that are templateable:
|
|
|
|
|
2021-11-21 21:01:08 -03:00
|
|
|
- `${artifact}`: the path to the artifact that will be signed [^1]
|
2022-11-15 08:21:18 -03:00
|
|
|
- `${digest}`: the digest of the image/manifest that will be signed [^2]
|
2021-11-11 22:56:03 -03:00
|
|
|
- `${artifactID}`: the ID of the artifact that will be signed
|
2022-09-17 00:13:09 -03:00
|
|
|
- `${certificate}`: the certificate file name, if provided
|
2021-11-21 21:01:08 -03:00
|
|
|
|
2022-09-17 00:13:09 -03:00
|
|
|
[^1]: notice that this might contain `/` characters, which depending on how
|
|
|
|
you use it might evaluate to actual paths within the file system. Use with
|
|
|
|
care.
|
2022-11-15 08:21:18 -03:00
|
|
|
[^2]: those are extracted automatically when running Docker push from within
|
|
|
|
GoReleaser. Using the digest helps making sure you're signing the right image
|
|
|
|
and avoid concurrency issues.
|
2021-11-21 21:01:08 -03:00
|
|
|
|
2021-11-11 22:56:03 -03:00
|
|
|
|
2021-08-24 11:22:09 -03:00
|
|
|
## Common usage example
|
|
|
|
|
|
|
|
Assuming you have a `cosign.key` in the repository root and a `COSIGN_PWD`
|
|
|
|
environment variable, the simplest configuration to sign both Docker images
|
|
|
|
and manifests would look like this:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
# .goreleaser.yml
|
|
|
|
docker_signs:
|
|
|
|
- artifacts: all
|
|
|
|
stdin: '{{ .Env.COSIGN_PWD }}'
|
|
|
|
```
|
|
|
|
|
|
|
|
Later on you (and anyone else) can verify the image with:
|
|
|
|
|
2022-09-17 00:13:09 -03:00
|
|
|
```bash
|
2021-12-03 18:22:31 +01:00
|
|
|
cosign verify --key cosign.pub your/image
|
2021-08-24 11:22:09 -03:00
|
|
|
```
|