Skip to content

Commit 7777470

Browse files
authored
refactor: finalize MkDocs Docker wrapper (#261)
* refactor: finalize MkDocs Docker wrapper * refactor: finalize MkDocs Docker wrapper
1 parent 5268ff3 commit 7777470

2 files changed

Lines changed: 23 additions & 14 deletions

File tree

docs/user-guide/Dockerfile

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
11
# syntax=docker/dockerfile:1.16.0@sha256:e2dd261f92e4b763d789984f6eab84be66ab4f5f08052316d8eb8f173593acf7
22
# check=error=true
33

4+
# BusyBox command help: https://www.busybox.net/downloads/BusyBox.html
45
FROM docker.io/python:3.13.14-alpine@sha256:b4d299311845147e7e47c970566906caf8378a1f04e5d3de65b5f2e834f8e3bf
56

6-
WORKDIR /run
7+
# Setup prerequisites for MkDocs Git-related features (e.g. revisions, collaborators, ...)
8+
RUN apk add --no-cache git
9+
10+
# Trust mounted host files in container at runtime
11+
RUN git config --system --add safe.directory /run
12+
13+
# New user and group for MkDocs
14+
RUN addgroup -S -g 1000 mkdocs && \
15+
adduser -S -u 1000 -G mkdocs mkdocs
16+
17+
USER 1000:1000
18+
19+
ENV HOME=/home/mkdocs
20+
ENV PATH="${PATH}:${HOME}/.local/bin"
21+
22+
WORKDIR ${HOME}
723

824
COPY requirements/requirements.txt .
925

10-
RUN \
11-
## Install MkDocs and its dependencies
12-
pip install --no-cache-dir --require-hashes --requirement requirements.txt \
13-
&& \
14-
rm requirements.txt \
15-
## Setup prerequisites for MkDocs Git-related features (e.g. revisions, collaborators, ...)
16-
&& \
17-
apk add --no-cache git \
18-
&& \
19-
git config --system --add safe.directory /run
20-
21-
USER daemon
26+
# Install MkDocs and its dependencies
27+
RUN pip install --user --require-hashes --requirement requirements.txt && rm requirements.txt
28+
29+
WORKDIR /run
2230

2331
EXPOSE 8000
2432

docs/user-guide/mkdocs.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ case "$(uname)" in
2020
;;
2121
esac
2222

23+
# Constraint: MkDocs' Git plugin requires access to the Git history.
2324
ROOT_PROJECT_DIR="${SCRIPT_DIR}/../.."
2425

2526
echo 'Building Docker image for MkDocs (can take up to a minute)'
@@ -30,7 +31,7 @@ GITHUB_TOKEN="${GITHUB_TOKEN:-$(gh auth token)}"
3031

3132
echo
3233
echo 'Running MkDocs:'
33-
# Avoid permission issues by running the container with the current user ID and group ID
34+
# Avoid permission issues by running the container with the current user ID and group ID.
3435
docker run --rm -p 8000:8000 --name docker-papermc-server-mkdocs \
3536
--user "$(id -u):$(id -g)" \
3637
--mount type=bind,source="${ROOT_PROJECT_DIR}",target=/run \

0 commit comments

Comments
 (0)