Skip to content

Commit 1f0b619

Browse files
authored
ci: rely on Docker GitHub Actions to leverage more features (#59)
cf. https://docs.docker.com/build/ci/github-actions/ Relying on GitHub Actions provided by Docker provide two main benefits: * Automatic and easy cache management (https://docs.docker.com/build/ci/github-actions/cache/) * Build summary (https://docs.docker.com/build/ci/github-actions/build-summary/) Coupling with GitHub Actions and Docker's specific GHA is limited thanks to Docker Bake.
1 parent 5aea6f1 commit 1f0b619

File tree

5 files changed

+24
-23
lines changed

5 files changed

+24
-23
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ on:
1111

1212
permissions: {}
1313

14+
# TODO: Experiment GitHub deployments
1415
# TODO: do we want to test multi-arch build?
15-
# TODO: what about cache?
16+
# TODO: reproductible builds? https://docs.docker.com/build/ci/github-actions/reproducible-builds/
1617
jobs:
1718
build-and-test:
1819
name: Build & Test
@@ -66,13 +67,24 @@ jobs:
6667
username: ${{ vars.DOCKERHUB_USERNAME }}
6768
password: ${{ secrets.DOCKERHUB_TOKEN }}
6869

69-
- name: Build & Test
70-
run: src/test/build-and-test.sh
70+
- name: Set up Docker Buildx
71+
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
72+
73+
- name: Build
74+
uses: docker/bake-action@4ba453fbc2db7735392b93edf935aaf9b1e8f747 # v6.5.0
75+
with:
76+
source: .
77+
workdir: src/main/
78+
targets: dev
79+
load: true # Required for tests in later steps
80+
81+
- name: Test
82+
run: src/test/test.sh
7183

7284
- name: Run Trivy vulnerability scanner
7385
uses: aquasecurity/trivy-action@6c175e9c4083a92bbca2f9724c8a5e33bc2d97a5 # 0.30.0
7486
with:
75-
image-ref: djaytan/papermc-server:dev
87+
image-ref: 'djaytan/papermc-server:dev'
7688
format: sarif
7789
output: results.sarif
7890

src/main/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ COPY --chown=papermc --chmod=500 runtime/start.sh ./
8383
EXPOSE 25565/tcp
8484
EXPOSE 25565/udp
8585

86+
# TODO: Pre-launch server to pre-download Mojang's server jar for quick startup
8687
ENTRYPOINT ["./start.sh"]
8788

8889
# TODO: healthcheck

src/test/build-dev.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/test/localdev.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ set -Eeuo pipefail
44

55
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
66

7-
bash "$SCRIPT_DIR"/build-dev.sh
7+
cd "${SCRIPT_DIR}/../main"
8+
9+
echo '🏗️ Building the DEV image...'
10+
docker buildx bake dev --print
11+
docker buildx bake dev
12+
echo '✅ Image built successfully.'
813

914
echo '▶️ Starting the localdev PaperMC server...'
1015
docker run --rm -it -p 25565:25565/tcp -p 25565:25565/udp -e EULA=true 'djaytan/papermc-server:dev'
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
#!/usr/bin/env bash
2+
# Assumption: The OCI image is already built and tagged as 'djaytan/papermc-server:dev'
23

34
set -Eeuo pipefail
45

5-
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
6-
7-
bash "$SCRIPT_DIR"/build-dev.sh
8-
96
CONTAINER_NAME='test-papermc-server'
107

118
echo '📋 Testing the Docker PaperMC server image...'

0 commit comments

Comments
 (0)