diff --git a/Dockerfile b/Dockerfile index 6fffdf6..bed37db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,27 @@ -FROM debian:jessie +FROM debian:stretch EXPOSE 34197/udp +ENV FACTORIO_VERSION 0.15.33 + +ADD bin/entrypoint.sh /entrypoint.sh + RUN \ apt-get --yes update &&\ apt-get --yes install wget xz-utils &&\ - apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* &&\ + adduser --disabled-password --gecos "" --home /opt/factorio factorio &&\ + chmod 755 /entrypoint.sh &&\ + mkdir -p /opt/factorio/headless /opt/factorio/saves &&\ + chown -R factorio /opt/factorio -WORKDIR /root/ +USER factorio RUN \ - wget -O /tmp/headless.tgz https://www.factorio.com/get-download/0.15.5/headless/linux64 &&\ - tar xfv /tmp/headless.tgz && rm /tmp/headless.tgz + wget -O /tmp/headless.tgz https://www.factorio.com/get-download/$FACTORIO_VERSION/headless/linux64 &&\ + tar xfv /tmp/headless.tgz -C /opt/factorio/headless && rm /tmp/headless.tgz -ADD bin/entrypoint.sh /entrypoint.sh -ADD default-config.json config/default.json +ADD default-config.json /opt/factorio/headless/factorio/config/default.json + +VOLUME /opt/factorio/saves ENTRYPOINT ["/entrypoint.sh"] CMD ["--server-settings", "config/default.json"] diff --git a/bin/entrypoint.sh b/bin/entrypoint.sh index f367491..807b607 100755 --- a/bin/entrypoint.sh +++ b/bin/entrypoint.sh @@ -1,10 +1,16 @@ #!/bin/bash set -e -FACTORIO_BIN=/root/factorio/bin/x64/factorio -WORLDNAME=/root/saves/world.zip +BASE_DIR=/opt/factorio + +RUN_DIR=${BASE_DIR}/headless/factorio + +FACTORIO_BIN=${RUN_DIR}/bin/x64/factorio +WORLDNAME=${BASE_DIR}/saves/world.zip # Create savefile, if none exists [ ! -f ${WORLDNAME} ] && ${FACTORIO_BIN} --create ${WORLDNAME} +cd ${RUN_DIR} + exec ${FACTORIO_BIN} --start-server ${WORLDNAME} "$@" diff --git a/docker-compose.yml b/docker-compose.yml index c6c74e2..e179085 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: ports: - 34197:34197/udp volumes: - - world:/root/saves/ + - world:/opt/factorio/saves/ volumes: world: