diff --git a/Dockerfile b/Dockerfile index 48828c0..f1a2e9e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM debian:latest -MAINTAINER zopanix@gmail.com +MAINTAINER zopanix WORKDIR /opt @@ -22,3 +22,6 @@ RUN echo "# Installing curl" && \ apt-get autoremove -y --purge && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +ENV FACTORIO_AUTOSAVE_INTERVAL 2 +ENV FACTORIO_AUTOSAVE_SLOTS 3 diff --git a/README.md b/README.md index a91d5cb..e29f9c2 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Current Version See [factorio's site](http://www.factorio.com) #### Docker image * Automatically takes latest save or autosave. when restarting the container. +* Added possibility to change defautl autosave interval Versions ----- @@ -24,20 +25,29 @@ How to use ? ### Without map persistence Here is the command : -`docker run -d -p [PORT]:34197/udp factorio` +`docker run --rm -d -p [PORT]:34197/udp zopanix/factorio` This will generate a new random map with default settings. If you're going to launch it on your local machine, don't use the port 34197, take another one at random. ### With map persistence -`docker run -d -v [PATH]:/opt/factorio/saves -p [PORT]:34197/udp factorio` +`docker run --rm -d -v [PATH]:/opt/factorio/saves -p [PORT]:34197/udp zopanix/factorio` This will generate a new random map with default settings and save it onto the volume. Replace [PATH] with a path to a folder on the host where the map will be saved. ### With existing map -`docker run -d -v [PATH]:/opt/factorio/saves -p [PORT]:34197/udp factorio` +`docker run --rm -d -v [PATH]:/opt/factorio/saves -p [PORT]:34197/udp zopanix/factorio` It's the same as above, it takes the last modified file which contains the word save in the filename as current save when booting the server. This allows when upgrading the container to take the last save, you don't have to rename the last autosave as save.zip +### Advanced usage +#### Autosave interval +You can set the autosave interval. By default it is set at 2 minutes bud you can change it by launching the container with the "FACTORIO_AUTOSAVE_INTERVAL" variable to whatever suits you best. +`docker run --rm -d --env FACTORIO_AUTOSAVE_INTERVAL=[NUMBER] -v [PORT]:34197/udp zopanix/factorio` +Where [NUMBER] is the number of minutes between autosaves. +#### Autosave slots +You can set the number of autosave slots. By default it is set at 3 slots bud you can change it by launching the container with the "FACTORIO_AUTOSAVE_SLOTS" variable to whatever suits you best. +`docker run --rm -d --env FACTORIO_AUTOSAVE_SLOTS=[NUMBER] -v [PORT]:34197/udp zopanix/factorio` +Where [NUMBER] is the number of autosave slots. + ToDo's : ----- * Adding possibility to add a mod volume -* Adding possibility to change the number of autosave diff --git a/smart_launch.sh b/smart_launch.sh index 762064b..5e72681 100755 --- a/smart_launch.sh +++ b/smart_launch.sh @@ -14,6 +14,7 @@ else echo "# Creating a new map [save.zip]" echo "###" /opt/factorio/bin/x64/factorio --create save.zip + last_save="save.zip" echo "###" echo "# New map created [save.zip]" echo "###" @@ -22,4 +23,9 @@ fi echo "###" echo "# Launching Game" echo "###" -exec /opt/factorio/bin/x64/factorio --disallow-commands --start-server $last_save +exec /opt/factorio/bin/x64/factorio \ + --disallow-commands \ + --start-server \ + $last_save \ + --autosave-interval ${FACTORIO_AUTOSAVE_INTERVAL} \ + --autosave-slots ${FACTORIO_AUTOSAVE_SLOTS}