Skip to content

Commit 5935aa0

Browse files
authored
ci: simplify CI build by sharing user guide OCI image with localdev (#254)
1 parent a44ce6f commit 5935aa0

File tree

8 files changed

+56
-30
lines changed

8 files changed

+56
-30
lines changed

.github/release/release.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env sh
2+
# TODO: move in sources
23

34
set -eu
45

.github/workflows/docs-deploy.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ jobs:
2424
# Firewall rules:
2525
# -> "*.github.com": Standard interactions with GitHub
2626
# -> "*.pypi.org" & "files.pythonhosted.org": Downloading Python packages
27+
# -> "*.docker.io" & "*.docker.com": Standard interactions with Docker
28+
# -> "*.alpinelinux.org": Standard interactions with Alpine Linux package repositories
29+
# -> "cdn.fwupd.org": Firmware updates (Alpine)
2730
- name: Harden runner
2831
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
2932
with:
@@ -34,29 +37,32 @@ jobs:
3437
api.github.com:443
3538
pypi.org:443
3639
files.pythonhosted.org:443
40+
*.docker.io:443
41+
*.docker.com:443
42+
dl-cdn.alpinelinux.org:443
43+
cdn.fwupd.org:443
3744
3845
- name: Checkout repository
3946
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4047
with:
4148
persist-credentials: false
42-
fetch-depth: 0 # Required by MkDocs' revisioning feature
49+
fetch-depth: 0 # Required by MkDocs' Git-related features
4350

44-
- name: Setup Python
45-
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
51+
- name: Login to Docker Hub
52+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
53+
if: github.event.pull_request.head.repo.fork == false
4654
with:
47-
python-version: 3.13
48-
49-
- name: Install MkDocs Material
50-
run: pip install --require-hashes --requirement docs/user-guide/requirements/requirements.txt
55+
username: ${{ vars.DOCKERHUB_USERNAME }}
56+
password: ${{ secrets.DOCKERHUB_TOKEN }}
5157

5258
- name: Copy License
5359
run: cp LICENSE.md docs/user-guide/src/license.md
5460

5561
- name: Build Site
5662
working-directory: docs/user-guide/
5763
env:
58-
MKDOCS_GIT_COMMITTERS_APIKEY: ${{ github.token }} # Avoid exceeding the GitHub API rate limits
59-
run: mkdocs build --strict
64+
GITHUB_TOKEN: ${{ github.token }} # Avoid exceeding the GitHub API rate limits
65+
run: ./build.sh
6066

6167
- name: Upload artifact
6268
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1

.github/workflows/docs-validate.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ jobs:
2424
# Firewall rules:
2525
# -> "*.github.com": Standard interactions with GitHub
2626
# -> "*.pypi.org" & "files.pythonhosted.org": Downloading Python packages
27+
# -> "*.docker.io" & "*.docker.com": Standard interactions with Docker
28+
# -> "*.alpinelinux.org": Standard interactions with Alpine Linux package repositories
29+
# -> "cdn.fwupd.org": Firmware updates (Alpine)
2730
- name: Harden runner
2831
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
2932
with:
@@ -34,26 +37,29 @@ jobs:
3437
api.github.com:443
3538
pypi.org:443
3639
files.pythonhosted.org:443
40+
*.docker.io:443
41+
*.docker.com:443
42+
dl-cdn.alpinelinux.org:443
43+
cdn.fwupd.org:443
3744
3845
- name: Checkout repository
3946
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4047
with:
4148
persist-credentials: false
42-
fetch-depth: 0 # Required by MkDocs' revisioning feature
49+
fetch-depth: 0 # Required by MkDocs' Git-related features
4350

44-
- name: Setup Python
45-
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
51+
- name: Login to Docker Hub
52+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
53+
if: github.event.pull_request.head.repo.fork == false
4654
with:
47-
python-version: 3.13
48-
49-
- name: Install MkDocs Material
50-
run: pip install --require-hashes --requirement docs/user-guide/requirements/requirements.txt
55+
username: ${{ vars.DOCKERHUB_USERNAME }}
56+
password: ${{ secrets.DOCKERHUB_TOKEN }}
5157

5258
- name: Copy License
5359
run: cp LICENSE.md docs/user-guide/src/license.md
5460

5561
- name: Build Site
5662
working-directory: docs/user-guide/
5763
env:
58-
MKDOCS_GIT_COMMITTERS_APIKEY: ${{ github.token }} # Avoid exceeding the GitHub API rate limits
59-
run: mkdocs build --strict
64+
GITHUB_TOKEN: ${{ github.token }} # Avoid exceeding the GitHub API rate limits
65+
run: ./build.sh

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ $ docker run -d -it \
5252
* 🪶 **Lightweight**~125 MB
5353
* 🧘 **Minimalist** – Includes only essential dependencies to reduce image size and surface area.
5454
* 🧩 **Customizable** – Streamlined and fine-grained configuration options.
55-
* 📚 **Well-documented** – Comprehensive and structured documentation covering features, configuration, and usage.
55+
* 📚 **Well-documented** – Comprehensive and structured documentation covering features, configuration, and
56+
usage ([link](https://djaytan.github.io/docker-papermc-server/)).
5657
* 👤 **UID-agnostic** – Supports running the server with a custom/arbitrary UID (typically required when running container
5758
in [OpenShift](https://www.redhat.com/en/technologies/cloud-computing/openshift)).
5859
* 🔐 **Rootless by default** – Runs as a non-root user when no custom UID is specified.

docs/user-guide/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.cache/
2+
site/

docs/user-guide/README.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,12 @@ That said, unless you have a specific reason, it’s recommended to use `localde
4848

4949
## ➕ Adding Dependencies
5050

51-
When introducing new dependencies, make sure to update both the **local development environment** and the **CI build environment**, as they are managed
52-
separately.
51+
### 🐍 Python Packages
5352

54-
### 💻 Locally
55-
56-
To update the local environment, open the `Dockerfile` and modify the `RUN pip install ...` line to include any additional packages you need.
53+
Python dependencies are declared in `requirements/requirements.in`.
54+
After editing this file to include the new packages, run the `requirements/requirements.sh` script.
55+
This will regenerate `requirements/requirements.txt`, which is the file actually used by both the localdev and CI environments to install dependencies in a consistent and reproducible way.
5756

58-
### 🤖 In CI
57+
### 🐧 Alpine Linux Packages
5958

60-
Dependencies for the CI environment are declared in `requirements/requirements.in`.
61-
After editing this file to include the new packages, run the `requirements/requirements.sh` script.
62-
This will regenerate `requirements/requirements.txt`, which is the file actually used by the CI to install dependencies in a consistent and reproducible way.
59+
To add Alpine system packages, modify the `Dockerfile` directly.

docs/user-guide/build.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env sh
2+
3+
set -eu
4+
5+
SCRIPT_DIR=$(cd "$(dirname "$0")" > /dev/null 2>&1 && pwd -P)
6+
7+
cd "${SCRIPT_DIR}"
8+
9+
sh mkdocs.sh build --strict

docs/user-guide/mkdocs.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,19 @@ esac
2222

2323
ROOT_PROJECT_DIR="${SCRIPT_DIR}/../.."
2424

25-
echo 'Building Docker image for MkDocs (can take a while - ~1 minutes)'
25+
echo 'Building Docker image for MkDocs (can take up to a minute)'
2626
docker build --progress quiet -t docker-papermc-server/mkdocs "${SCRIPT_DIR}"
2727

28+
# Avoid exceeding the GitHub API rate limits
29+
GITHUB_TOKEN="${GITHUB_TOKEN:-$(gh auth token)}"
30+
2831
echo
2932
echo 'Running MkDocs:'
33+
# Avoid permission issues by running the container with the current user ID and group ID
3034
docker run --rm -p 8000:8000 --name docker-papermc-server-mkdocs \
35+
--user "$(id -u):$(id -g)" \
3136
--volume="${ROOT_PROJECT_DIR}:/run" \
3237
--workdir /run/docs/user-guide \
33-
-e MKDOCS_GIT_COMMITTERS_APIKEY="$(gh auth token)" \
38+
-e MKDOCS_GIT_COMMITTERS_APIKEY="${GITHUB_TOKEN}" \
3439
docker-papermc-server/mkdocs \
3540
"$@"

0 commit comments

Comments
 (0)