mirror of
https://github.com/factoriotools/factorio-docker.git
synced 2025-01-24 16:54:45 +01:00
Allow puid/pgid to be set as environment vars on stable (#256)
* allow puid/pgid to be set on stable * update docker-entrypoint to include puid, gpid * add quotes to env puid/pgid env vars * add quotes for factorio-vol
This commit is contained in:
parent
ee5b023911
commit
b5c1dff7b4
@ -15,10 +15,12 @@ ENV PORT=34197 \
|
|||||||
CONFIG=/factorio/config \
|
CONFIG=/factorio/config \
|
||||||
MODS=/factorio/mods \
|
MODS=/factorio/mods \
|
||||||
SCENARIOS=/factorio/scenarios \
|
SCENARIOS=/factorio/scenarios \
|
||||||
SCRIPTOUTPUT=/factorio/script-output
|
SCRIPTOUTPUT=/factorio/script-output \
|
||||||
|
PUID="$PUID" \
|
||||||
|
PGID="$PGID"
|
||||||
|
|
||||||
RUN mkdir -p /opt /factorio && \
|
RUN mkdir -p /opt /factorio && \
|
||||||
apk add --update --no-cache pwgen && \
|
apk add --update --no-cache pwgen su-exec shadow && \
|
||||||
apk add --update --no-cache --virtual .build-deps curl && \
|
apk add --update --no-cache --virtual .build-deps curl && \
|
||||||
curl -sSL https://www.factorio.com/get-download/$VERSION/headless/linux64 \
|
curl -sSL https://www.factorio.com/get-download/$VERSION/headless/linux64 \
|
||||||
-o /tmp/factorio_headless_x64_$VERSION.tar.xz && \
|
-o /tmp/factorio_headless_x64_$VERSION.tar.xz && \
|
||||||
@ -41,6 +43,4 @@ EXPOSE $PORT/udp $RCON_PORT/tcp
|
|||||||
|
|
||||||
COPY files/ /
|
COPY files/ /
|
||||||
|
|
||||||
USER $USER
|
|
||||||
|
|
||||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||||
|
@ -3,6 +3,8 @@ set -euo pipefail
|
|||||||
|
|
||||||
id
|
id
|
||||||
|
|
||||||
|
FACTORIO_VOL=/factorio
|
||||||
|
mkdir -p "$FACTORIO_VOL"
|
||||||
mkdir -p "$SAVES"
|
mkdir -p "$SAVES"
|
||||||
mkdir -p "$CONFIG"
|
mkdir -p "$CONFIG"
|
||||||
mkdir -p "$MODS"
|
mkdir -p "$MODS"
|
||||||
@ -29,14 +31,26 @@ if find -L "$SAVES" -iname \*.tmp.zip -mindepth 1 -print | grep -q .; then
|
|||||||
rm -f "$SAVES"/*.tmp.zip
|
rm -f "$SAVES"/*.tmp.zip
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$(id -u)" = '0' ]; then
|
||||||
|
# Update the User and Group ID based on the PUID/PGID variables
|
||||||
|
usermod -o -u "$PUID" factorio
|
||||||
|
groupmod -o -g "$PGID" factorio
|
||||||
|
# Take ownership of factorio data if running as root
|
||||||
|
chown -R factorio:factorio "$FACTORIO_VOL"
|
||||||
|
# Drop to the factorio user
|
||||||
|
SU_EXEC="su-exec factorio"
|
||||||
|
else
|
||||||
|
SU_EXEC=""
|
||||||
|
fi
|
||||||
|
|
||||||
if ! find -L "$SAVES" -iname \*.zip -mindepth 1 -print | grep -q .; then
|
if ! find -L "$SAVES" -iname \*.zip -mindepth 1 -print | grep -q .; then
|
||||||
/opt/factorio/bin/x64/factorio \
|
$SU_EXEC /opt/factorio/bin/x64/factorio \
|
||||||
--create "$SAVES/_autosave1.zip" \
|
--create "$SAVES/_autosave1.zip" \
|
||||||
--map-gen-settings "$CONFIG/map-gen-settings.json" \
|
--map-gen-settings "$CONFIG/map-gen-settings.json" \
|
||||||
--map-settings "$CONFIG/map-settings.json"
|
--map-settings "$CONFIG/map-settings.json"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec /opt/factorio/bin/x64/factorio \
|
$SU_EXEC /opt/factorio/bin/x64/factorio \
|
||||||
--port "$PORT" \
|
--port "$PORT" \
|
||||||
--start-server-load-latest \
|
--start-server-load-latest \
|
||||||
--server-settings "$CONFIG/server-settings.json" \
|
--server-settings "$CONFIG/server-settings.json" \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user