Skip to content

Commit a26b7a9

Browse files
nickygerritsenvmcj
authored andcommitted
Allow to specify UID/GID for contributor container. Fixes #143.
1 parent 46d8f5a commit a26b7a9

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

docker-contributor/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ LABEL maintainer="DOMjudge team <[email protected]>"
44

55
ENV DEBIAN_FRONTEND=noninteractive \
66
CONTAINER_TIMEZONE=Europe/Amsterdam \
7+
UID=1000 \
8+
GID=1000 \
79
MYSQL_HOST=mariadb \
810
MYSQL_USER=domjudge \
911
MYSQL_DATABASE=domjudge \
@@ -43,7 +45,8 @@ RUN ln -sf /dev/stdout /var/log/nginx/access.log \
4345
&& mkdir -p /run/php
4446

4547
# Set up users
46-
RUN useradd -m domjudge \
48+
RUN groupadd -g $GID domjudge \
49+
&& useradd -u $UID -g $GID -m domjudge \
4750
&& groupadd domjudge-run \
4851
&& for id in $(seq 0 4); do useradd -d /nonexistent -g nogroup -s /bin/false "domjudge-run-$id"; done
4952

docker-contributor/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ bin/dj_setup_database install-examples
5757

5858
The following environment variables are supported by the container:
5959

60+
* `UID` (defaults to `1000`): the ID of the user to run DOMjudge as. Should match the host OS user ID.
61+
* `GID` (defaults to `1000`): the ID of the group to run DOMjudge as. Should match the host OS group ID.
6062
* `CONTAINER_TIMEZONE` (defaults to `Europe/Amsterdam`): allows you to change the timezone used inside the container.
6163
* `MYSQL_HOST` (defaults to `mariadb`): set the host to connect to for MySQL. Can be hostname or IP. Docker will add hostnames for any containers you `--link`, so in the example above, the MariaDB container will be available under the hostname `mariadb`.
6264
* `MYSQL_USER` (defaults to `domjudge`): set the user to use for connecting to MySQL.

docker-contributor/scripts/start.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ function file_or_env {
99
fi
1010
}
1111

12+
echo "[..] Changing user/group ID"
13+
groupmod -g "${GID}" domjudge
14+
usermod -u "${UID}" domjudge
15+
echo "[ok] User ID set to ${UID} and group ID set to ${GID}"; echo
16+
1217
echo "[..] Setting timezone"
1318
sudo ln -snf "/usr/share/zoneinfo/${CONTAINER_TIMEZONE}" /etc/localtime
1419
echo "${CONTAINER_TIMEZONE}" | sudo tee /etc/timezone

0 commit comments

Comments
 (0)