Skip to content

Commit 158312a

Browse files
committed
Remove ROOTLESS environment variable as you can now just supply --user directly to the container (#389)
Increase healthcheck timeout (#392)
1 parent ebf2718 commit 158312a

File tree

3 files changed

+28
-27
lines changed

3 files changed

+28
-27
lines changed

Dockerfile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ ENV AUTOSAVENUM="5" \
1212
MAXTICKRATE="30" \
1313
PGID="1000" \
1414
PUID="1000" \
15-
ROOTLESS="false" \
1615
SERVERGAMEPORT="7777" \
1716
SERVERSTREAMING="true" \
1817
SKIPUPDATE="false" \
@@ -35,17 +34,13 @@ RUN mkdir -p /config \
3534
COPY init.sh healthcheck.sh /
3635
COPY --chown=steam:steam run.sh /home/steam/
3736

38-
HEALTHCHECK --timeout=10s --start-period=180s \
39-
CMD bash /healthcheck.sh
37+
HEALTHCHECK --timeout=30s --start-period=300s CMD bash /healthcheck.sh
4038

4139
WORKDIR /config
42-
4340
ARG VERSION="DEV"
4441
ENV VERSION=$VERSION
4542
LABEL version=$VERSION
46-
4743
STOPSIGNAL SIGINT
48-
4944
EXPOSE 7777/udp 7777/tcp
5045

5146
ENTRYPOINT [ "/init.sh" ]

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ helm install satisfactory k8s-at-home/satisfactory -f values.yaml
195195
| `MAXTICKRATE` | `30` | set the maximum sim tick rate for your server |
196196
| `PGID` | `1000` | set the group ID of the user the server will run as |
197197
| `PUID` | `1000` | set the user ID of the user the server will run as |
198-
| `ROOTLESS` | `false` | run the container as a non-root user |
199198
| `SERVERGAMEPORT` | `7777` | set the game's port |
200199
| `SERVERIP` | `0.0.0.0` | set the game's ip (usually not needed) |
201200
| `SERVERSTREAMING` | `true` | toggle whether the game utilizes asset streaming |
@@ -248,6 +247,12 @@ really get the best out of multiplayer:
248247
- Right-click each of the 3 config files (Engine.ini, Game.ini, Scalability.ini)
249248
- Go to Properties > tick Read-only under the attributes
250249

250+
## Rootless
251+
252+
If you'd prefer to run the container as a non-root user, just pass your preferred user to the container using Docker's
253+
own user implementation (e.g. `--user 1000:1000`). Do note that the container will print a warning for this, and this
254+
may permissions-related issues.
255+
251256
## Known Issues
252257

253258
- The container is run as `root`. This is pretty common for Docker images, but is bad practice for security reasons.

init.sh

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ if [[ "${LOG,,}" != "true" ]]; then
5353
fi
5454
fi
5555

56-
# check if the user and group IDs have been set
57-
if [[ "$CURRENTUID" -ne "0" ]] && [[ "${ROOTLESS,,}" != "true" ]]; then
58-
printf "${MSGERROR} Current user (%s) is not root (0)\\nPass your user and group to the container using the PGID and PUID environment variables\\nDo not use the --user flag (or user: field in Docker Compose) without setting ROOTLESS=true\\n" "$CURRENTUID"
59-
exit 1
56+
# check if the user and group IDs have been set. If so, reset HOME to the upstream default
57+
if [[ "$CURRENTUID" -ne "0" ]]; then
58+
HOME="/root"
59+
printf "${MSGWARNING} Current user (%s) is not root (0).\\nNo permissions will be adjusted as we're running within a rootless environment.\\n" "$CURRENTUID"
6060
fi
6161

6262
if ! [[ "$PGID" =~ $NUMCHECK ]] ; then
@@ -75,18 +75,18 @@ elif [[ "$PUID" -eq 0 ]]; then
7575
exit 1
7676
fi
7777

78-
if [[ "${ROOTLESS,,}" != "true" ]]; then
79-
if [[ $(getent group $PGID | cut -d: -f1) ]]; then
80-
usermod -a -G "$PGID" steam
81-
else
82-
groupmod -g "$PGID" steam
83-
fi
84-
85-
if [[ $(getent passwd ${PUID} | cut -d: -f1) ]]; then
86-
USER=$(getent passwd $PUID | cut -d: -f1)
87-
else
88-
usermod -u "$PUID" steam
89-
fi
78+
if [[ "$CURRENTUID" -eq "0" ]]; then
79+
if [[ $(getent group $PGID | cut -d: -f1) ]]; then
80+
usermod -a -G "$PGID" steam
81+
else
82+
groupmod -g "$PGID" steam
83+
fi
84+
85+
if [[ $(getent passwd ${PUID} | cut -d: -f1) ]]; then
86+
USER=$(getent passwd $PUID | cut -d: -f1)
87+
else
88+
usermod -u "$PUID" steam
89+
fi
9090
fi
9191

9292
if [[ ! -w "/config" ]]; then
@@ -109,9 +109,10 @@ mkdir -p \
109109

110110
echo "Satisfactory logs can be found in /config/gamefiles/FactoryGame/Saved/Logs" > /config/logs/satisfactory-path.txt
111111

112-
if [[ "${ROOTLESS,,}" != "true" ]]; then
113-
chown -R "$PUID":"$PGID" /config /home/steam /tmp/dumps
114-
exec gosu "$USER" "/home/steam/run.sh" "$@"
112+
if [[ "$CURRENTUID" -eq "0" ]]; then
113+
chown -R "$PUID":"$PGID" /config /home/steam /tmp/dumps
114+
exec gosu "$USER" "/home/steam/run.sh" "$@"
115115
else
116-
exec "/home/steam/run.sh" "$@"
116+
# running within a rootless environment
117+
exec "/home/steam/run.sh" "$@"
117118
fi

0 commit comments

Comments
 (0)