Added dynamic creation of map only if needed

This commit is contained in:
Christophe Vandekerchove 2016-02-26 14:59:01 +01:00
parent 3cd89b6870
commit e30bf8d656
2 changed files with 24 additions and 3 deletions

View File

@ -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

21
smart_launch.sh Executable file
View File

@ -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