This workflow automates the building, scanning, and signing of container images using GitHub Actions.
- Build and Push Unsigned Image: Creates a Docker image and pushes it to GHCR.
- Build and Push Signed Image: Builds a signed container image using Cosign.
- Scan Image for Vulnerabilities: Uses Trivy to detect security issues.
- Sign and Verify Image: Ensures authenticity with Cosign.
- Uses Docker Buildx to build a multi-platform image.
- Pushes an unsigned image to GitHub Container Registry (GHCR).
- Checkout repository code.
- Set up Docker Buildx.
- Authenticate to GHCR.
- Generate metadata (tags) for the image.
- Build and push the unsigned image.
- Builds and signs the image using Cosign.
- Supports linux/amd64 and linux/arm64 platforms.
- Stores the signed image in GHCR.
- Install Cosign for signing images.
- Enable QEMU for multi-platform support.
- Set up Docker Buildx.
- Authenticate to GHCR.
- Generate metadata (tags) for the image.
- Build and push the signed image.
- Uses Aqua Security's Trivy to scan for vulnerabilities.
- Supports severity levels MEDIUM, HIGH, CRITICAL.
- Generates a Software Bill of Materials (SBOM) report.
- Authenticate using GitHub credentials.
- Scan the signed image.
- Upload the SBOM report as a GitHub artifact.
- Uses Cosign to sign and verify the image.
- Ensures the container image is trusted and secure before deployment.
- Sign the image using
cosign sign
. - Verify the signature using
cosign verify
.
Name | Description |
---|---|
COSIGN_PRIVATE_KEY |
Private key used for signing. |
COSIGN_PASSWORD |
Password to unlock the private key. |
COSIGN_PUBLIC_KEY |
Public key for verifying the signature. |
- Ensure you have the required secrets set up in your GitHub repository:
GITHUB_TOKEN
COSIGN_PRIVATE_KEY
COSIGN_PUBLIC_KEY
COSIGN_PASSWORD
- Push a Docker image to a private registry.
- Trigger the GitHub Action.
- View Trivy results under GitHub Actions → Artifacts.
- Verify that the image is signed successfully.
- Build fails: Ensure
GHCR
authentication is correctly configured. - Trivy scan issues: Check if the correct image tag is used.
- Cosign verification fails: Verify that the correct public key is used.
For any issues, refer to:
- This workflow supports multi-platform builds.
- Trivy can scan for misconfigurations, secrets, and licenses.
- Cosign integrates with Sigstore for keyless signing.
This workflow ensures that your container images are secure, signed, and verifiable before deployment. ✅
Use Cosign to verify a signed image:
cosign verify --key <path-to-public-key> ghcr.io/shivaswaroop40/containerimages/my-signed-image
-
Docker Buildx • Advanced Docker builds with multi-platform support.
-
Cosign • Sign and verify container images to enhance security.
-
GHCR • GitHub-hosted container registry for Docker images. Feedback and Contributions
-
Trivy: Container Security Tool
We welcome your feedback and contributions!
- Open issues to suggest improvements or report problems.
- Submit pull requests to enhance the workflow.
Link to my presentation: CNCF
Contact
Feel free to reach out for questions or collaboration opportunities!
Email: [email protected]
LinkedIn: Shiva Swaroop N K
Twitter: Shiva Swaroop N K