From 65658b10d6fe957d8c0a83b1b5ab0451a6678b90 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 25 Oct 2016 16:49:23 +0000 Subject: [PATCH] use server-settings.json for settings --- Dockerfile | 27 ++++++++++++--------------- smart_launch.sh | 42 +++++++----------------------------------- 2 files changed, 19 insertions(+), 50 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1e2a151..de7c061 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,25 @@ FROM frolvlad/alpine-glibc:alpine-3.3_glibc-2.23 -MAINTAINER zopanix +MAINTAINER https://github.com/dtandersen/docker_factorio_server -WORKDIR /opt +#WORKDIR /opt -COPY ./smart_launch.sh /opt -COPY ./factorio.crt /opt +COPY ./factorio.crt /opt/factorio.crt -VOLUME /opt/factorio/saves /opt/factorio/mods +EXPOSE 34197/udp 27015/tcp -ENV FACTORIO_AUTOSAVE_INTERVAL=2 \ - FACTORIO_AUTOSAVE_SLOTS=3 \ - FACTORIO_DISSALOW_COMMANDS=true \ - FACTORIO_NO_AUTO_PAUSE=false \ - VERSION=0.14.14 \ - FACTORIO_SHA1=decd1ef34a75b309791e65bc92b164f10479753b + +ENV VERSION=0.14.14 \ + SHA1=decd1ef34a75b309791e65bc92b164f10479753b RUN apk --update 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 && \ - echo "$FACTORIO_SHA1 /tmp/factorio_headless_x64_$VERSION.tar.gz" | sha1sum -c && \ - tar xzf /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 +VOLUME /opt/factorio/saves /opt/factorio/mods -EXPOSE 34197/udp +COPY ./smart_launch.sh /opt -CMD ["./smart_launch.sh"] +CMD ["/opt/smart_launch.sh"] diff --git a/smart_launch.sh b/smart_launch.sh index dac61f8..8ddb057 100755 --- a/smart_launch.sh +++ b/smart_launch.sh @@ -1,43 +1,15 @@ -#!/bin/bash +#!/bin/bash -x -if [ -f /opt/factorio/saves/save.zip ] +SAVES=/opt/factorio/saves + +if [ -f $SAVES/*.zip ] then - echo "###" - echo "# Using existing map [save.zip]" - echo "###" - echo "###" - echo "# Finding latest map" - echo "###" - last_save=$(ls /opt/factorio/saves -lt | grep save |head -1 |awk '{print $(NF)}') + last_save=$(ls $SAVES -lt | grep save |head -1 |awk '{print $(NF)}') else - echo "###" - 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 "###" + /opt/factorio/bin/x64/factorio --create $SAVES/$last_save fi -# Checking options -if [ "$FACTORIO_DISSALOW_COMMANDS" == false ]; then - disallow_commands="" -else - disallow_commands="--disallow-commands" -fi -if [ "$FACTORIO_NO_AUTO_PAUSE" == true ]; then - no_auto_pause="--no-auto-pause" -else - no_auto_pause="" -fi -echo "###" -echo "# Launching Game" -echo "###" exec /opt/factorio/bin/x64/factorio \ - $disallow_commands \ - $no_auto_pause \ - --autosave-interval ${FACTORIO_AUTOSAVE_INTERVAL} \ - --autosave-slots ${FACTORIO_AUTOSAVE_SLOTS} \ --start-server \ - $last_save + $SAVES/$last_save