From 6f33dd84440d65d664bb7d9e4959faff512af752 Mon Sep 17 00:00:00 2001 From: Christophe Vandekerchove Date: Fri, 26 Feb 2016 14:59:01 +0100 Subject: [PATCH] Added dynamic creation of map only if needed --- Dockerfile | 6 +++--- smart_launch.sh | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100755 smart_launch.sh diff --git a/Dockerfile b/Dockerfile index 34f0e13..50fcd19 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,13 +6,13 @@ WORKDIR /opt COPY ./factorio.tar.gz /opt -RUN tar -xzf factorio.tar.gz +COPY ./smart_launch.sh /opt -RUN ["/opt/factorio/bin/x64/factorio", "--create", "save.zip"] +RUN tar -xzf factorio.tar.gz WORKDIR /opt/factorio -CMD ["/opt/factorio/bin/x64/factorio", "--disallow-commands", "--start-server", "save.zip"] +CMD ["./smart_launch.sh"] EXPOSE 34197/udp diff --git a/smart_launch.sh b/smart_launch.sh new file mode 100755 index 0000000..8321311 --- /dev/null +++ b/smart_launch.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ -f /opt/factorio/saves/save.zip ] +then + echo "###" + echo "# Using existing map [save.zip]" + echo "###" +else + echo "###" + echo "# Creating a new map [save.zip]" + echo "###" + opt/factorio/bin/x64/factorio --create save.zip + echo "###" + echo "# New map created [save.zip]" + echo "###" +fi + +echo "###" +echo "# Launching Game" +echo "###" +exec /opt/factorio/bin/x64/factorio --disallow-commands --start-server save.zip