Skip to content

Commit f0858cf

Browse files
authored
build: fix pip-compile Docker wrapper on Linux systems (#256)
The permission issue is not a concern on Windows, hence why the issue was not spotted at first. The solution consists on building the Docker image with both the UID and GID of the user running the script. This is acceptable since the Docker image is systematically built before being executed.
1 parent 7f474d7 commit f0858cf

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

docs/user-guide/requirements/pip-compile/Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@
44
# Note: impossible to rely on v3.13.14 (missing 'cache_clear' function error)
55
FROM docker.io/python:3.12.11-alpine@sha256:c610e4a94a0e8b888b4b225bfc0e6b59dee607b1e61fb63ff3926083ff617216
66

7-
RUN addgroup -S pip && \
8-
adduser --system --disabled-password --shell /sbin/nologin pip
7+
ARG UID
8+
ARG GID
99

10-
ENV PATH="${PATH}:/home/pip/.local/bin"
10+
# BusyBox command help: https://www.busybox.net/downloads/BusyBox.html
11+
RUN addgroup -S -g ${GID} pip && \
12+
adduser -S -u ${UID} -G pip pip
1113

1214
USER pip
1315

16+
WORKDIR /home/pip/
17+
18+
ENV PATH="${PATH}:/home/pip/.local/bin"
19+
20+
# Long story short: install pip-tools in the user directory to avoid permission issues.
1421
RUN pip install --user pip-tools

docs/user-guide/requirements/pip-compile/pip-compile.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ case "$(uname)" in
2323
esac
2424

2525
echo 'Building Docker image for pip-tools (should only take few seconds)'
26-
docker build --progress quiet -t docker-papermc-server/pip-tools "${SCRIPT_DIR}"
26+
docker build --progress quiet \
27+
--build-arg "UID=$(id -u)" \
28+
--build-arg "GID=$(id -g)" \
29+
-t docker-papermc-server/pip-tools \
30+
"${SCRIPT_DIR}"
2731

2832
echo
2933
echo 'Running pip-compile:'

0 commit comments

Comments
 (0)