Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

Sign docker image with cosign - #96

Merged
Jeroen Knoops (JeroenKnoops) merged 2 commits into
mainfrom
sign-docker-image
Jan 26, 2022
Merged

Jeroen Knoops (JeroenKnoops) merged 2 commits into
mainfrom
sign-docker-image

Conversation

@JeroenKnoops

Copy link
Copy Markdown
Member

Change

When added an argument (sign: true) it will sign the image with Cosign.

Cosign key-pair

You need to provide the COSIGN environment variables in order to actually sign it.
You can create a key pair by installing Cosign on your local machine and run:

cosign generate-key-pair

Store the content of cosign.pub, cosign.key and the password in GitHub Secrets.

Workflow

Now you can use it in a workflow:

- name: Build Docker Images
  uses: philips-software/docker-ci-scripts@v4.0.0
  with:
    dockerfile: .
    image-name: image-name-here
    tags: latest 0.1
    push-branches: main develop
    sign: true
  env:
    DOCKER_USERNAME: ${{ github.actor }}
    DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
    DOCKER_REGISTRY: ghcr.io/organization-here
    GITHUB_ORGANIZATION: organization-here
    COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
    COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
    COSIGN_PUBLIC_KEY: ${{ secrets.COSIGN_PUBLIC_KEY }}

Verify image

Now you can verify the image:

  cosign verify --key cosign.pub organization-here/image-name-here:latest

You will get a result when the image is valid and an error if not.

Breaking change

Previously a SLSA Provenance file was attached when the environment variable COSIGN_PRIVATE_KEY was set. This has been changed, now it only attaches the file to the image when the argument SIGN: true is set.

Related issue

Closes #78

Signed-off-by: Jeroen Knoops <jeroen.knoops@philips.com>
Signed-off-by: Jeroen Knoops <jeroen.knoops@philips.com>
@JeroenKnoops
Jeroen Knoops (JeroenKnoops) deleted the sign-docker-image branch January 26, 2022 19:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add cosign support

2 participants