Skip to content

Commit 8e617bd

Browse files
authored
ci: migrate from Trivy security scanner to Docker Scout (#125)
See https://docs.docker.com/scout/integrations/ci/gha/
1 parent d067dd0 commit 8e617bd

File tree

4 files changed

+80
-40
lines changed

4 files changed

+80
-40
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ on:
1616

1717
permissions: { }
1818

19-
# TODO: Migrate from Trivy to Docker Scout: https://github.com/docker/scout-action
2019
jobs:
2120
build-and-test:
2221
name: Build & Test
@@ -25,6 +24,7 @@ jobs:
2524

2625
permissions:
2726
contents: read
27+
pull-requests: write # Required to write comments to the PR about security scans results
2828
security-events: write # Required to upload found security gaps
2929

3030
steps:
@@ -36,7 +36,6 @@ jobs:
3636
# -> "*.alpinelinux.org": Standard interactions with Alpine Linux package repositories
3737
# -> "cdn.fwupd.org": Firmware updates (Alpine)
3838
# -> "api.papermc.io": Dynamic retrieval of the PaperMC server
39-
# -> "mirror.gcr.io": Downloading of the Trivy security scanner
4039
# -> "piston-data.mojang.com": Downloading of the Mojang server
4140
# -> "api.minecraftservices.com": Downloading Yggdrasil public key for Reobfuscation
4241
- name: Harden runner
@@ -50,10 +49,9 @@ jobs:
5049
objects.githubusercontent.com:443
5150
raw.githubusercontent.com:443
5251
*.docker.io:443
53-
production.cloudflare.docker.com:443
52+
*.docker.com:443
5453
dl-cdn.alpinelinux.org:443
5554
cdn.fwupd.org:443
56-
mirror.gcr.io:443
5755
api.papermc.io:443
5856
piston-data.mojang.com:443
5957
api.minecraftservices.com:443
@@ -77,21 +75,23 @@ jobs:
7775
with:
7876
source: .
7977
workdir: src/main/docker/
80-
targets: dev
81-
load: true # Export to Docker - Required for tests in later steps
78+
targets: test
79+
load: true # Export to Docker - Required for later steps
8280
set: |
8381
*.cache-from=type=gha,timeout=20s
8482
*.cache-to=type=gha,mode=max,timeout=20s
8583
8684
- name: Test
8785
run: src/test/docker/test.sh
8886

89-
- name: Run Trivy vulnerability scanner
90-
uses: aquasecurity/trivy-action@6c175e9c4083a92bbca2f9724c8a5e33bc2d97a5 # 0.30.0
87+
- name: Docker Scout
88+
uses: docker/scout-action@381b657c498a4d287752e7f2cfb2b41823f566d9 # v1.17.1
9189
with:
92-
image-ref: 'djaytan/papermc-server:dev'
93-
format: sarif
94-
output: results.sarif
90+
command: compare, cves
91+
image: 'djaytan/papermc-server:test'
92+
to-latest: true
93+
organization: djaytan
94+
sarif-file: results.sarif
9595

9696
- name: Upload to GitHub's code scanning dashboard
9797
uses: github/codeql-action/upload-sarif@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
@@ -103,7 +103,7 @@ jobs:
103103
# because 1 configuration present on refs/heads/main was not found".
104104
# The warning occurs when different workflows use different categories for SARIF files on the same branch.
105105
#
106-
# Using a single, consistent category (e.g., 'trivy') ensures all uploads are correctly associated.
106+
# Using a single, consistent category (e.g., 'global') ensures all uploads are correctly associated.
107107
#
108108
# Additional details: https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning#uploading-more-than-one-sarif-file-for-a-commit
109-
category: trivy
109+
category: global

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ $ docker run -d -it \
5151
***JRE 21**, based on [Eclipse Temurin](https://hub.docker.com/_/eclipse-temurin)
5252
* Custom-built using `jlink` to minimize size
5353
* Includes all standard Java modules to ensure broad compatibility with plugins
54-
* 🛡️ **Frequent security scans**: By relying on [Trivy](https://trivy.dev/latest/) and [Docker Scout](https://docs.docker.com/scout/)
54+
* 🛡️ **Frequent security scans**: By relying on [Docker Scout](https://docs.docker.com/scout/)
5555
* 🔄 **Scheduled auto-updates**: Bi-monthly rebuilds to incorporate upstream security patches and PaperMC updates
5656

5757
## 🛠️ Planned Features

src/main/docker/docker-bake.hcl

Lines changed: 65 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
1+
########################################
2+
# Multi-target Docker image build #
3+
########################################
4+
5+
# This file defines multiple build targets using Docker Bake,
6+
# allowing for fine-grained control over how images are built,
7+
# tagged, and promoted across environments (dev, test, release, etc.).
8+
9+
# ─────────────────────────────────────
10+
# 🏗️ Image Targets
11+
# ─────────────────────────────────────
12+
# dev:
13+
# Lightweight image for development and local testing.
14+
# Uses a single architecture and avoids production overhead.
15+
16+
# test:
17+
# Image used for automated testing pipelines.
18+
# Always pulls latest base layers to validate rebuild reliability.
19+
20+
# release:
21+
# Final production image, tagged for distribution.
22+
# Uses full multi-arch build, add annotations, disables cache, and
23+
# assigns versioned + semantic tags (e.g., latest, major, minor,
24+
# timestamp).
25+
26+
# ─────────────────────────────────────
27+
# 💡 Usage Notes
28+
# ─────────────────────────────────────
29+
# - Use `dev` when iterating locally.
30+
# - Use `test` in CI pipelines to verify integrity.
31+
# - Use `release` only in actual publishing pipelines.
32+
33+
# Build with:
34+
# docker buildx bake <target>
35+
#
36+
# Example:
37+
# docker buildx bake dev
38+
139
# ========== VARIABLES ========== #
240

341
# General properties
@@ -55,33 +93,32 @@ function "date" {
5593

5694
# ========== TARGETS ========== #
5795

58-
target "dev" {
59-
description = "Builds the image for development purposes."
96+
target "_common" {
97+
description = "Base configuration inherited by all other targets."
6098
args = {
6199
MINECRAFT_VERSION = "${MINECRAFT_VERSION}"
62100
}
63-
tags = [
64-
tag("dev")
65-
]
101+
}
102+
103+
target "dev" {
104+
inherits = ["_common"]
105+
description = "Builds a lightweight image for development and local testing."
106+
tags = [ tag("dev") ]
107+
}
108+
109+
target "test" {
110+
inherits = ["_common"]
111+
description = "Builds a test image with fresh base layers (always pulls upstream images)."
112+
pull = true
113+
tags = [ tag("test") ]
66114
}
67115

68116
target "release" {
69-
description = "Builds the image for production purposes."
70-
args = {
71-
MINECRAFT_VERSION = "${MINECRAFT_VERSION}"
72-
}
117+
inherits = ["_common"]
118+
description = "Builds and tags the production image for publishing."
73119
platforms = ["linux/amd64", "linux/arm64"]
74120
pull = true
75121
no-cache = true
76-
# Docker tag format: <mc-version>-v<image-version>-<timestamp-YYYYMMDD>
77-
tags = [
78-
equal(IS_LATEST_RELEASE, true) ? tag("latest") : "",
79-
equal(IS_LATEST_RELEASE, true) ? tag("${MINECRAFT_VERSION}") : "",
80-
tag("${MINECRAFT_VERSION}-v${IMAGE_VERSION}"),
81-
tag("${MINECRAFT_VERSION}-v${IMAGE_VERSION}-${date()}"),
82-
tag("${MINECRAFT_VERSION}-v${extractMajorMinorFromSemVer(IMAGE_VERSION)}"),
83-
tag("${MINECRAFT_VERSION}-v${extractMajorFromSemVer(IMAGE_VERSION)}")
84-
]
85122
annotations = [
86123
annotation("org.opencontainers.image.title", "PaperMC Server"),
87124
annotation("org.opencontainers.image.description", "Dockerized and fine-grained customizable PaperMC server."),
@@ -96,12 +133,15 @@ target "release" {
96133
notequal(REVISION, "") ? annotation("org.opencontainers.image.revision", REVISION) : ""
97134
]
98135
attest = [
99-
{
100-
type = "provenance",
101-
mode = "max",
102-
},
103-
{
104-
type = "sbom",
105-
}
136+
{ type = "provenance", mode = "max", },
137+
{ type = "sbom", }
138+
]
139+
tags = [
140+
equal(IS_LATEST_RELEASE, true) ? tag("latest") : "",
141+
equal(IS_LATEST_RELEASE, true) ? tag("${MINECRAFT_VERSION}") : "",
142+
tag("${MINECRAFT_VERSION}-v${IMAGE_VERSION}"),
143+
tag("${MINECRAFT_VERSION}-v${IMAGE_VERSION}-${date()}"),
144+
tag("${MINECRAFT_VERSION}-v${extractMajorMinorFromSemVer(IMAGE_VERSION)}"),
145+
tag("${MINECRAFT_VERSION}-v${extractMajorFromSemVer(IMAGE_VERSION)}")
106146
]
107147
}

src/test/docker/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ docker run --rm -d --name "$CONTAINER_NAME" \
1919
--memory=8GB \
2020
-p 25565:25565 \
2121
-e EULA=true \
22-
'djaytan/papermc-server:dev'
22+
'djaytan/papermc-server:test'
2323

2424
cleanup() {
2525
echo '🛑 Automatically stopping and removing the PaperMC server container...'

0 commit comments

Comments
 (0)