Skip to content

Commit 3886cc2

Browse files
authored
build: create MkDocs OCI image from scratch (#246)
1 parent 004347e commit 3886cc2

5 files changed

Lines changed: 44 additions & 16 deletions

File tree

docs/user-guide/Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# syntax=docker/dockerfile:1.16.0@sha256:e2dd261f92e4b763d789984f6eab84be66ab4f5f08052316d8eb8f173593acf7
2+
# check=error=true
3+
4+
# Note: impossible to rely on v3.13.14 (missing 'cache_clear' function error)
5+
FROM docker.io/python:3.12.11-alpine@sha256:c610e4a94a0e8b888b4b225bfc0e6b59dee607b1e61fb63ff3926083ff617216
6+
7+
WORKDIR /run
8+
9+
# Install MkDocs
10+
RUN pip install mkdocs-material[recommended]
11+
12+
# Install MkDocs Git-related features (e.g. revisions, collaborators, ...)
13+
RUN apk add --no-cache git && \
14+
pip install \
15+
mkdocs-git-revision-date-localized-plugin \
16+
mkdocs-git-committers-plugin-2 && \
17+
git config --system --add safe.directory /run
18+
19+
USER daemon
20+
21+
EXPOSE 8000
22+
23+
ENTRYPOINT ["mkdocs"]

docs/user-guide/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,24 @@ Instead, open the site using one of the following URLs:
3636
* `http://localhost:8000/docker-papermc-server/`
3737
* `http://127.0.0.1:8000/docker-papermc-server/`
3838

39+
## 🛠 Wrapper Script
40+
41+
To run `mkdocs` commands manually, use the `mkdocs.sh` wrapper script. For example:
42+
43+
```bash
44+
./mkdocs.sh build
45+
```
46+
47+
That said, unless you have a specific reason, it’s recommended to use `localdev.sh`, as it handles everything needed for local development.
48+
3949
## ➕ Adding Dependencies
4050

4151
When introducing new dependencies, make sure to update both the **local development environment** and the **CI build environment**, as they are managed
4252
separately.
4353

4454
### 💻 Locally
4555

46-
To update the local environment, open the `wrappers/mkdocs/Dockerfile` and modify the `RUN pip install ...` line to include any additional packages you need.
56+
To update the local environment, open the `Dockerfile` and modify the `RUN pip install ...` line to include any additional packages you need.
4757

4858
### 🤖 In CI
4959

docs/user-guide/localdev.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ set -eu
55
SCRIPT_DIR=$(cd "$(dirname "$0")" > /dev/null 2>&1 && pwd -P)
66

77
echo 'The preview is going to be available at http://localhost:8000/docker-papermc-server/'
8+
echo
89

9-
sh "${SCRIPT_DIR}"/wrappers/mkdocs/mkdocs
10+
sh "${SCRIPT_DIR}/mkdocs" serve --dev-addr '0.0.0.0:8000'
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
set -eu
55

6-
SCRIPT_DIR=$(cd "$(dirname "$0")" > /dev/null 2>&1 && pwd -P)
6+
SCRIPT_DIR="$(cd "$(dirname "$0")" > /dev/null 2>&1 && pwd -P)"
77

88
# On Windows environments (Cygwin, MinGW, MSYS), Docker volume mounts require Windows-style paths.
99
# However, automatic path conversion by MSYS can cause unexpected issues,
@@ -20,13 +20,16 @@ case "$(uname)" in
2020
;;
2121
esac
2222

23-
ROOT_PROJECT_DIR="${SCRIPT_DIR}/../../../.."
23+
ROOT_PROJECT_DIR="${SCRIPT_DIR}/../.."
2424

25-
docker build -t docker-papermc-server/mkdocs "${SCRIPT_DIR}"
25+
echo 'Building Docker image for MkDocs (can take a while)'
26+
docker build --progress quiet -t docker-papermc-server/mkdocs "${SCRIPT_DIR}"
2627

28+
echo
29+
echo 'Running MkDocs:'
2730
docker run --rm -p 8000:8000 --name docker-papermc-server-mkdocs \
28-
--volume="${ROOT_PROJECT_DIR}:/docs" \
29-
--workdir /docs/docs/user-guide \
31+
--volume="${ROOT_PROJECT_DIR}:/run" \
32+
--workdir /run/docs/user-guide \
3033
-e MKDOCS_GIT_COMMITTERS_APIKEY="$(gh auth token)" \
3134
docker-papermc-server/mkdocs \
3235
"$@"

docs/user-guide/wrappers/mkdocs/Dockerfile

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

0 commit comments

Comments
 (0)