From 16602ba40b220c2d12883caa33d1024a5339cdae Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 25 Oct 2016 21:57:49 -0700 Subject: [PATCH 1/5] specify location of settings --- Dockerfile | 4 +++- docker-entrypoint.sh | 8 ++++++-- map-gen-settings.example.json | 24 ++++++++++++++++++++++++ run.sh | 1 + 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 map-gen-settings.example.json diff --git a/Dockerfile b/Dockerfile index 50fca14..821b6a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,9 @@ RUN apk --update add bash curl && \ -o /tmp/factorio_headless_x64_$VERSION.tar.gz && \ 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 + 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 VOLUME /opt/factorio/saves /opt/factorio/mods diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 8040453..6294cbc 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -4,7 +4,11 @@ SAVES=/opt/factorio/saves if [ ! -f $SAVES/*.zip ] then - /opt/factorio/bin/x64/factorio --create $SAVES/save.zip + /opt/factorio/bin/x64/factorio \ + --create $SAVES/save.zip \ + --map-gen-settings /opt/factorio/data/map-gen-settings.json fi -exec /opt/factorio/bin/x64/factorio --start-server-load-latest +exec /opt/factorio/bin/x64/factorio \ + --start-server-load-latest \ + --server-settings /opt/factorio/data/server-settings.json diff --git a/map-gen-settings.example.json b/map-gen-settings.example.json new file mode 100644 index 0000000..a7ff667 --- /dev/null +++ b/map-gen-settings.example.json @@ -0,0 +1,24 @@ +{ + "_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/run.sh b/run.sh index e0805ac..76c7e6c 100755 --- a/run.sh +++ b/run.sh @@ -1,5 +1,6 @@ sudo docker run --rm -it \ -v /home/vagrant/docker_factorio_server/server-settings.json:/opt/factorio/data/server-settings.json \ + -v /home/vagrant/docker_factorio_server/map-gen-settings.json:/opt/factorio/data/map-gen-settings.json \ -v /data/mods:/opt/factorio/mods \ -v /data/saves:/opt/factorio/saves \ --name factorio \ From 08090e70a0dc567c0d7394e208b1a6d4626ae9da Mon Sep 17 00:00:00 2001 From: David Andersen Date: Wed, 26 Oct 2016 17:26:47 +0000 Subject: [PATCH 2/5] fixed check for saves --- docker-entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 6294cbc..c6852a0 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -2,8 +2,8 @@ SAVES=/opt/factorio/saves -if [ ! -f $SAVES/*.zip ] -then +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 From 81edeb0183d2f04e59e00c90a524c69083f5dfd5 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Wed, 26 Oct 2016 17:27:11 +0000 Subject: [PATCH 3/5] fixed json syntax --- map-gen-settings.example.json | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/map-gen-settings.example.json b/map-gen-settings.example.json index a7ff667..7f41572 100644 --- a/map-gen-settings.example.json +++ b/map-gen-settings.example.json @@ -1,6 +1,5 @@ { - "_comment": "Sizes can be specified as none, very-low, low, normal, -high, very-high", + "_comment": "Sizes can be specified as none, very-low, low, normal, high, very-high", "terrain_segmentation": "normal", "water": "normal", "width": 0, @@ -10,15 +9,10 @@ high, very-high", "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"} + "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"} } } From 86ec899b060306a0886ba8dfddd184867352b7f2 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Wed, 26 Oct 2016 17:27:28 +0000 Subject: [PATCH 4/5] mount volumes to /tmp --- run.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/run.sh b/run.sh index 76c7e6c..66478f8 100755 --- a/run.sh +++ b/run.sh @@ -1,7 +1,12 @@ +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 sudo docker run --rm -it \ - -v /home/vagrant/docker_factorio_server/server-settings.json:/opt/factorio/data/server-settings.json \ - -v /home/vagrant/docker_factorio_server/map-gen-settings.json:/opt/factorio/data/map-gen-settings.json \ - -v /data/mods:/opt/factorio/mods \ - -v /data/saves:/opt/factorio/saves \ + -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 \ --name factorio \ - factorio + factorio "$@" From 0fdac9cebb4eb0f8aedba678e2a3e5478093a347 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Wed, 26 Oct 2016 17:46:34 +0000 Subject: [PATCH 5/5] specify port --- docker-entrypoint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index c6852a0..adbdb0a 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -10,5 +10,6 @@ if ! find $SAVES -iname \*.zip -mindepth 1 -print | grep -q .; then fi exec /opt/factorio/bin/x64/factorio \ + --port 34197 \ --start-server-load-latest \ --server-settings /opt/factorio/data/server-settings.json