From 06e168f8996b7f6e1d83665eba04b9234a4945ba Mon Sep 17 00:00:00 2001 From: David Andersen Date: Wed, 26 Oct 2016 18:32:06 +0000 Subject: [PATCH 01/11] remove curl after use --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 821b6a0..b257c23 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ COPY ./factorio.crt /opt/factorio.crt ENV VERSION=0.14.16 \ SHA1=e27c658bf8a7579b662a1c34815daa223e57bc90 -RUN apk --update add bash curl && \ +RUN apk --update --no-cache add bash curl && \ curl -sSL --cacert /opt/factorio.crt \ https://www.factorio.com/get-download/$VERSION/headless/linux64 \ -o /tmp/factorio_headless_x64_$VERSION.tar.gz && \ @@ -15,7 +15,8 @@ RUN apk --update add bash curl && \ tar xzf /tmp/factorio_headless_x64_$VERSION.tar.gz --directory /opt && \ rm /tmp/factorio_headless_x64_$VERSION.tar.gz && \ cp /opt/factorio/data/server-settings.example.json /opt/factorio/data/server-settings.json && \ - cp /opt/factorio/data/map-gen-settings.example.json /opt/factorio/data/map-gen-settings.json + cp /opt/factorio/data/map-gen-settings.example.json /opt/factorio/data/map-gen-settings.json && \ + apk --no-cache del curl VOLUME /opt/factorio/saves /opt/factorio/mods From 7992ded59ea594654bac648af3df9adc1ff82373 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Wed, 26 Oct 2016 14:42:44 -0700 Subject: [PATCH 02/11] log example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 89d7a9f..aee91f5 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ docker start factorio Sometimes it's useful to see the logs of a running container: ``` -docker exec -it factorio tail -f /opt/factorio/factorio-current.log +docker logs factorio ``` # Credits From 1c07730c4eb1f84512f2d1c7edb14088e46b278c Mon Sep 17 00:00:00 2001 From: David Andersen Date: Wed, 26 Oct 2016 23:15:09 +0000 Subject: [PATCH 03/11] use one main /factorio volume --- Dockerfile | 10 ++++++---- docker-entrypoint.sh | 15 ++++++++++++++- run.sh | 15 ++++++--------- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index b257c23..633c405 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,11 +14,13 @@ RUN apk --update --no-cache add bash curl && \ echo "$SHA1 /tmp/factorio_headless_x64_$VERSION.tar.gz" | sha1sum -c && \ tar xzf /tmp/factorio_headless_x64_$VERSION.tar.gz --directory /opt && \ rm /tmp/factorio_headless_x64_$VERSION.tar.gz && \ - cp /opt/factorio/data/server-settings.example.json /opt/factorio/data/server-settings.json && \ - cp /opt/factorio/data/map-gen-settings.example.json /opt/factorio/data/map-gen-settings.json && \ - apk --no-cache del curl + apk --no-cache del curl && \ + ln -s /factorio/saves /opt/factorio/saves && \ + ln -s /factorio/mods /opt/factorio/mods && \ + ln -s /factorio/config/server-settings.json /opt/factorio/data/server-settings.json && \ + ln -s /factorio/config/map-gen-settings.json /opt/factorio/data/map-gen-settings.json -VOLUME /opt/factorio/saves /opt/factorio/mods +VOLUME /factorio EXPOSE 34197/udp 27015/tcp diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index adbdb0a..985ac34 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,9 +1,22 @@ #!/bin/bash -x +set -e + SAVES=/opt/factorio/saves +mkdir -p /factorio/saves +mkdir -p /factorio/mods +mkdir -p /factorio/config + +if [ ! -f /factorio/config/server-settings.json ]; then + cp /opt/factorio/data/server-settings.example.json /factorio/config/server-settings.json +fi + +if [ ! -f /factorio/config/map-gen-settings.json ]; then + cp /opt/factorio/data/map-gen-settings.example.json /factorio/config/map-gen-settings.json +fi + if ! find $SAVES -iname \*.zip -mindepth 1 -print | grep -q .; then -#if [ -z $(find $SAVES -iname \*.zip -mindepth 1 -print | grep -q .) ]; then /opt/factorio/bin/x64/factorio \ --create $SAVES/save.zip \ --map-gen-settings /opt/factorio/data/map-gen-settings.json diff --git a/run.sh b/run.sh index 66478f8..10a7c1b 100755 --- a/run.sh +++ b/run.sh @@ -1,12 +1,9 @@ -mkdir -p /tmp/factorio -mkdir -p /tmp/factorio/mods -mkdir -p /tmp/factorio/saves -cp -n server-settings.example.json /tmp/factorio/server-settings.json -cp -n map-gen-settings.example.json /tmp/factorio/map-gen-settings.json +#mkdir -p /tmp/factorio/config +#mkdir -p /tmp/factorio/mods +#mkdir -p /tmp/factorio/saves +#cp -n server-settings.example.json /tmp/factorio/config/server-settings.json +#cp -n map-gen-settings.example.json /tmp/factorio/config/map-gen-settings.json sudo docker run --rm -it \ - -v /tmp/factorio/server-settings.json:/opt/factorio/data/server-settings.json \ - -v /tmp/factorio/map-gen-settings.json:/opt/factorio/data/map-gen-settings.json \ - -v /tmp/factorio/mods:/opt/factorio/mods \ - -v /tmp/factorio/saves:/opt/factorio/saves \ + -v /tmp/factorio:/factorio \ --name factorio \ factorio "$@" From 2cefc1544ce02df9f250252aebeb949e077d7d51 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Wed, 26 Oct 2016 16:30:32 -0700 Subject: [PATCH 04/11] describe new volume structure --- README.md | 56 +++++++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index aee91f5..2b6ab69 100644 --- a/README.md +++ b/README.md @@ -30,43 +30,44 @@ NOTE: This is only the server. The game is available on [Steam](http://store.ste ## Quick Start -Start the server in interactive mode for debugging. The game isn't saved. +Start the server in interactive mode. ``` -docker run --rm -it -P dtandersen/factorio +docker run --rm -it -P -v /tmp/factorio:/factorio dtandersen/factorio ``` +Here is an explanation of the options: + * ```--rm``` - Remove container after stopping * ```-it``` - Interactive mode, i.e. you can see the console * ```-P``` - Expose all ports. +* ```-v``` - Volume to mount. -## Usage +Press ^C to stop the server. There is now a ```server-settings.json``` in ```/tmp/factorio/config```. Modify this to your liking. -Normally the server runs as a daemon and a configuration file is specified. Volumes are mounted for saves and mods. - -Create ```server-config.json``` and modify it to your liking. +Now start the server as a daemon. ``` -docker run -d -P \ - -v /path/to/server-config.json:/opt/factorio/data/server-config.json \ - -v /path/to/saves:/opt/factorio/saves \ - -v /path/to/mods:/opt/factorio/mods \ - --name factorio \ - dtandersen/factorio +docker run -d -P -v /tmp/factorio:/factorio --name factorio dtandersen/factorio ``` -* ```-d``` - Start the server as a daemon. -* ```-P``` - Expose all ports. -* ```-v``` - Mount volumes for config, mods, and saves. -* ```--name``` - Give the container a name (otherwise it'll be random). +Try to connect to the server. Check the logs if it isn't working: + +``` +docker logs factorio +``` ## Saves -The first time the server is started a new map is generated and saved as ```save.zip```. On subsequent runs the newest save is used. To load an old save ```touch save.zip``` and restart the server. +A new map (```save.zip```) is generated the first time the server is started. On subsequent runs the newest save is used. To load an old save ```touch save.zip``` and restart the server. + +To generate a new map delete all of the saves and restart the server. + +For custom map settings edit ```map-gen-settings.json``` in ```/tmp/factorio/config```. ## Mods -Copy them into the mods folder and restart the server. +Copy the mods into the mods folder and restart the server. ## Start/Stopping @@ -84,23 +85,20 @@ docker start factorio ## Volumes -* ```/opt/factorio/saves``` - Saves (recommened) -* ```/opt/factorio/mods``` - Mods (optional) -* ```/opt/factorio/data/server-config.json``` - Configuration (recommended) +The server has only one volume: ```/factorio```. Under this folder there are folders for ```/saves```, ```/mods```, and ```/config```. + +* ```/factorio``` +** ```/config``` +*** ```server-settings.json``` +*** ```map-gen-settings.json``` +** ```/mods``` +** ```/saves``` ## Ports * ```34197/udp``` - Client (required) * ```27015/tcp``` - Remote console (optional) -## Logs - -Sometimes it's useful to see the logs of a running container: - -``` -docker logs factorio -``` - # Credits Based on [Zopanix' Factorio Server](https://github.com/zopanix/docker_factorio_server). From 4280ef8cfc6861ec8d7876a8165b7c1086ae4829 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Wed, 26 Oct 2016 16:41:54 -0700 Subject: [PATCH 05/11] revise docs --- README.md | 52 +++++++++++++++++++++------------------------------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 2b6ab69..9dd5439 100644 --- a/README.md +++ b/README.md @@ -30,33 +30,37 @@ NOTE: This is only the server. The game is available on [Steam](http://store.ste ## Quick Start -Start the server in interactive mode. - -``` -docker run --rm -it -P -v /tmp/factorio:/factorio dtandersen/factorio -``` - -Here is an explanation of the options: - -* ```--rm``` - Remove container after stopping -* ```-it``` - Interactive mode, i.e. you can see the console -* ```-P``` - Expose all ports. -* ```-v``` - Volume to mount. - -Press ^C to stop the server. There is now a ```server-settings.json``` in ```/tmp/factorio/config```. Modify this to your liking. - -Now start the server as a daemon. +Begin by running the server to create the necessary folder structure and configuration files under ```/tmp/factorio```. ``` docker run -d -P -v /tmp/factorio:/factorio --name factorio dtandersen/factorio ``` -Try to connect to the server. Check the logs if it isn't working: +Here is an explanation of the options: + +* ```--d``` - Run as a daemon (detached). +* ```-P``` - Expose all ports. +* ```-v``` - Mount ```/tmp/factorio``` on the local file system to ```/factorio``` in the container. +* ```--name``` - Name the container ```factorio``` (otherwise it has a random name). + +Check the logs to see what happened: ``` docker logs factorio ``` +Stop the server: + +```docker stop factorio``` + +Now there's a ```server-settings.json``` in ```/tmp/factorio/config```. Modify this to your liking. + +Restart the server: + +```docker start factorio``` + +Try to connect to the server. Check the logs if it isn't working. + ## Saves A new map (```save.zip```) is generated the first time the server is started. On subsequent runs the newest save is used. To load an old save ```touch save.zip``` and restart the server. @@ -69,20 +73,6 @@ For custom map settings edit ```map-gen-settings.json``` in ```/tmp/factorio/con Copy the mods into the mods folder and restart the server. -## Start/Stopping - -Assuming the server is named ```factorio```, to stop the server: - -``` -docker stop factorio -``` - -To restart the server: - -``` -docker start factorio -``` - ## Volumes The server has only one volume: ```/factorio```. Under this folder there are folders for ```/saves```, ```/mods```, and ```/config```. From ff1c0a954e5caf2c5476d5f941dc599c1788a41a Mon Sep 17 00:00:00 2001 From: David Andersen Date: Wed, 26 Oct 2016 16:46:21 -0700 Subject: [PATCH 06/11] doc updates --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9dd5439..b1970c6 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ NOTE: This is only the server. The game is available on [Steam](http://store.ste ## Quick Start -Begin by running the server to create the necessary folder structure and configuration files under ```/tmp/factorio```. +Begin by running the server to create the necessary folder structure and configuration files. For this example we'll use ```/tmp/factorio``` to store our data. ``` docker run -d -P -v /tmp/factorio:/factorio --name factorio dtandersen/factorio @@ -53,7 +53,7 @@ Stop the server: ```docker stop factorio``` -Now there's a ```server-settings.json``` in ```/tmp/factorio/config```. Modify this to your liking. +Now there's a ```server-settings.json``` file in the folder ```/tmp/factorio/config```. Modify this to your liking. Restart the server: @@ -63,11 +63,13 @@ Try to connect to the server. Check the logs if it isn't working. ## Saves -A new map (```save.zip```) is generated the first time the server is started. On subsequent runs the newest save is used. To load an old save ```touch save.zip``` and restart the server. +A new map (```save.zip```) is generated the first time the server is started. On subsequent runs the newest save is used. + +To load an old save ```touch save.zip``` and restart the server. To generate a new map delete all of the saves and restart the server. -For custom map settings edit ```map-gen-settings.json``` in ```/tmp/factorio/config```. +For custom map settings edit ```map-gen-settings.json``` in ```/tmp/factorio/config```. Then generate a new map. ## Mods From 35eb0fbfb7dd136a5e4e0bad69e7d913f240a725 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Wed, 26 Oct 2016 16:52:05 -0700 Subject: [PATCH 07/11] format list --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b1970c6..d343af4 100644 --- a/README.md +++ b/README.md @@ -80,16 +80,16 @@ Copy the mods into the mods folder and restart the server. The server has only one volume: ```/factorio```. Under this folder there are folders for ```/saves```, ```/mods```, and ```/config```. * ```/factorio``` -** ```/config``` -*** ```server-settings.json``` -*** ```map-gen-settings.json``` -** ```/mods``` -** ```/saves``` + ** ```/config``` + *** ```server-settings.json``` + *** ```map-gen-settings.json``` + ** ```/mods``` + ** ```/saves``` ## Ports -* ```34197/udp``` - Client (required) -* ```27015/tcp``` - Remote console (optional) +* ```34197/udp``` - Factorio clients (required). +* ```27015/tcp``` - RCON (optional). # Credits From 33a9379f9fcc8a9ad5424c576cb29b109abdb6a3 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Wed, 26 Oct 2016 16:53:13 -0700 Subject: [PATCH 08/11] format list --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d343af4..abe9b69 100644 --- a/README.md +++ b/README.md @@ -80,11 +80,11 @@ Copy the mods into the mods folder and restart the server. The server has only one volume: ```/factorio```. Under this folder there are folders for ```/saves```, ```/mods```, and ```/config```. * ```/factorio``` - ** ```/config``` - *** ```server-settings.json``` - *** ```map-gen-settings.json``` - ** ```/mods``` - ** ```/saves``` + * ```/config``` + * ```server-settings.json``` + * ```map-gen-settings.json``` + * ```/mods``` + * ```/saves``` ## Ports From 6bfeb9dabff24ac611220441d0d2c495050f88b2 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Wed, 26 Oct 2016 16:56:00 -0700 Subject: [PATCH 09/11] docs --- README.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index abe9b69..151905c 100644 --- a/README.md +++ b/README.md @@ -19,14 +19,7 @@ The game is very stable and optimized for building massive factories. You can cr NOTE: This is only the server. The game is available on [Steam](http://store.steampowered.com/app/427520/). -# Features - -* Configurable via ```server-config.json```. -* Automatically loads the last save. -* Volumes for saves and mods. -* Small size. Based on Alpine Linux. - -# How to use this image? +# Usage ## Quick Start @@ -75,9 +68,11 @@ For custom map settings edit ```map-gen-settings.json``` in ```/tmp/factorio/con Copy the mods into the mods folder and restart the server. +# Container Details + ## Volumes -The server has only one volume: ```/factorio```. Under this folder there are folders for ```/saves```, ```/mods```, and ```/config```. +The container has one volume located at ```/factorio```. Under this folder there are sub-folders for configuration, mods, and saves. * ```/factorio``` * ```/config``` From 1c82a0fb656c4fa722b2ca13e941b05491b9e77e Mon Sep 17 00:00:00 2001 From: David Andersen Date: Wed, 26 Oct 2016 16:58:31 -0700 Subject: [PATCH 10/11] remove sample settings --- map-gen-settings.example.json | 18 ----------- server-settings.example.json | 57 ----------------------------------- 2 files changed, 75 deletions(-) delete mode 100644 map-gen-settings.example.json delete mode 100644 server-settings.example.json diff --git a/map-gen-settings.example.json b/map-gen-settings.example.json deleted file mode 100644 index 7f41572..0000000 --- a/map-gen-settings.example.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "_comment": "Sizes can be specified as none, very-low, low, normal, high, very-high", - "terrain_segmentation": "normal", - "water": "normal", - "width": 0, - "height": 0, - "starting_area": "normal", - "peaceful_mode": false, - "autoplace_controls": - { - "coal": {"frequency": "very-low", "size": "high", "richness": "high"}, - "copper-ore": {"frequency": "very-low", "size": "high", "richness": "high"}, - "crude-oil": {"frequency": "normal", "size": "high", "richness": "high"}, - "enemy-base": {"frequency": "low", "size": "normal", "richness": "normal"}, - "iron-ore": {"frequency": "very-low", "size": "high", "richness": "high"}, - "stone": {"frequency": "very-low", "size": "normal", "richness": "normal"} - } -} diff --git a/server-settings.example.json b/server-settings.example.json deleted file mode 100644 index 5b2a68c..0000000 --- a/server-settings.example.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "name": "Name of the game as it will appear in the game listing", - "description": "Description of the game that will appear in the listing", - "tags": ["game", "tags"], - - "_comment_max_players": "Maximum number of players allowed, admins can join even a full server. 0 means unlimited.", - "max_players": 0, - - "_comment_visibility": ["public: Game will be published on the official Factorio matching server", - "lan: Game will be broadcast on LAN"], - "visibility": - { - "public": true, - "lan": true - }, - - "_comment_credentials": "Your factorio.com login credentials. Required for games with visibility public", - "username": "", - "password": "", - - "_comment_token": "Authentication token. May be used instead of 'password' above.", - "token": "", - - "game_password": "", - - "_comment_require_user_verification": "When set to true, the server will only allow clients that have a valid Factorio.com account", - "require_user_verification": true, - - "_comment_max_upload_in_kilobytes_per_second" : "optional, default value is 0. 0 means unlimited.", - "max_upload_in_kilobytes_per_second": 0, - - "_comment_ignore_player_limit_for_returning_players": "Players that played on this map already can join even when the max player limit was reached.", - "ignore_player_limit_for_returning_players": false, - - "_comment_allow_commands": "possible values are, true, false and admins-only", - "allow_commands": "admins-only", - - "_comment_autosave_interval": "Autosave interval in minutes", - "autosave_interval": 10, - - "_comment_autosave_slots": "server autosave slots, it is cycled through when the server autosaves.", - "autosave_slots": 5, - - "_comment_afk_autokick_interval": "How many minutes until someone is kicked when doing nothing, 0 for never.", - "afk_autokick_interval": 0, - - "_comment_auto_pause": "Whether should the server be paused when no players are present.", - "auto_pause": true, - - "only_admins_can_pause_the_game": true, - - "_comment_autosave_only_on_server": "Whether autosaves should be saved only on server or also on all connected clients. Default is true.", - "autosave_only_on_server": true, - - "_comment_admins": "List of case insensitive usernames, that will be promoted immediately", - "admins": [] -} From 487b0d7bd616d58e25b0698255316626f3dee5bd Mon Sep 17 00:00:00 2001 From: David Andersen Date: Thu, 27 Oct 2016 00:08:21 +0000 Subject: [PATCH 11/11] follow symlink --- docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 985ac34..3cd1431 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -16,7 +16,7 @@ if [ ! -f /factorio/config/map-gen-settings.json ]; then cp /opt/factorio/data/map-gen-settings.example.json /factorio/config/map-gen-settings.json fi -if ! find $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 \ --create $SAVES/save.zip \ --map-gen-settings /opt/factorio/data/map-gen-settings.json