mirror of
https://github.com/factoriotools/factorio-docker.git
synced 2024-11-10 04:37:23 +01:00
commit
754663df49
@ -10,7 +10,12 @@ ARG PGID=845
|
||||
ENV PORT=34197 \
|
||||
RCON_PORT=27015 \
|
||||
VERSION=0.16.29 \
|
||||
SHA1=4015ab311b3b769f9ac2fb33f83d0ee3474c6cc7
|
||||
SHA1=4015ab311b3b769f9ac2fb33f83d0ee3474c6cc7 \
|
||||
SAVES=/factorio/saves \
|
||||
CONFIG=/factorio/config \
|
||||
MODS=/factorio/mods \
|
||||
SCENARIOS=/factorio/scenarios \
|
||||
ENTRYPOINTS=/factorio/entrypoints
|
||||
|
||||
RUN mkdir -p /opt /factorio && \
|
||||
apk add --update --no-cache pwgen && \
|
||||
@ -21,8 +26,10 @@ RUN mkdir -p /opt /factorio && \
|
||||
tar xf /tmp/factorio_headless_x64_$VERSION.tar.xz --directory /opt && \
|
||||
chmod ugo=rwx /opt/factorio && \
|
||||
rm /tmp/factorio_headless_x64_$VERSION.tar.xz && \
|
||||
ln -s /factorio/saves /opt/factorio/saves && \
|
||||
ln -s /factorio/mods /opt/factorio/mods && \
|
||||
ln -s -f $SAVES /opt/factorio/saves && \
|
||||
ln -s -f $MODS /opt/factorio/mods && \
|
||||
ln -s -f $SCENARIOS /opt/factorio/scenarios && \
|
||||
ln -s -f $ENTRYPOINTS /opt/factorio/entrypoints && \
|
||||
apk del .build-deps && \
|
||||
addgroup -g $PGID -S $GROUP && \
|
||||
adduser -u $PUID -G $GROUP -s /bin/sh -SDH $USER && \
|
||||
@ -33,6 +40,11 @@ VOLUME /factorio
|
||||
EXPOSE $PORT/udp $RCON_PORT/tcp
|
||||
|
||||
COPY ./docker-entrypoint.sh /
|
||||
COPY ./scenario2map.sh /factorio/entrypoints
|
||||
COPY ./scenario.sh /factorio/entrypoints
|
||||
|
||||
#symbolic link the default entrypoint to the entrypoints directory so it can be inspected and copied to new entrypoints
|
||||
#RUN ln -s -f /docker-entrypoint.sh $ENTRYPOINTS/docker-entrypoint.sh
|
||||
|
||||
USER $USER
|
||||
|
||||
|
@ -4,12 +4,11 @@ set -e
|
||||
|
||||
id
|
||||
|
||||
SAVES=/factorio/saves
|
||||
CONFIG=/factorio/config
|
||||
|
||||
mkdir -p $SAVES
|
||||
mkdir -p /factorio/mods
|
||||
mkdir -p $CONFIG
|
||||
mkdir -p $MODS
|
||||
mkdir -p $SCENARIOS
|
||||
mkdir -p $ENTRYPOINTS
|
||||
|
||||
#chown -R factorio /factorio
|
||||
|
||||
|
49
0.16/scenario.sh
Executable file
49
0.16/scenario.sh
Executable file
@ -0,0 +1,49 @@
|
||||
#!/bin/sh -x
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "No argument supplied"
|
||||
fi
|
||||
SCENARIO=$1
|
||||
|
||||
set -e
|
||||
|
||||
id
|
||||
|
||||
SAVES=/factorio/saves
|
||||
CONFIG=/factorio/config
|
||||
MODS=/factorio/mods
|
||||
SCENARIOS=/factorio/scenarios
|
||||
|
||||
mkdir -p $SAVES
|
||||
mkdir -p $CONFIG
|
||||
mkdir -p $MODS
|
||||
mkdir -p $SCENARIOS
|
||||
|
||||
#chown -R factorio /factorio
|
||||
|
||||
if [ ! -f $CONFIG/rconpw ]; then
|
||||
echo $(pwgen 15 1) > $CONFIG/rconpw
|
||||
fi
|
||||
|
||||
if [ ! -f $CONFIG/server-settings.json ]; then
|
||||
cp /opt/factorio/data/server-settings.example.json $CONFIG/server-settings.json
|
||||
fi
|
||||
|
||||
if [ ! -f $CONFIG/map-gen-settings.json ]; then
|
||||
cp /opt/factorio/data/map-gen-settings.example.json $CONFIG/map-gen-settings.json
|
||||
fi
|
||||
|
||||
if [ ! -f $CONFIG/map-settings.json ]; then
|
||||
cp /opt/factorio/data/map-settings.example.json $CONFIG/map-settings.json
|
||||
fi
|
||||
|
||||
|
||||
exec /opt/factorio/bin/x64/factorio \
|
||||
--port $PORT \
|
||||
--start-server-load-scenario $SCENARIO \
|
||||
--server-settings $CONFIG/server-settings.json \
|
||||
--server-whitelist $CONFIG/server-whitelist.json \
|
||||
--server-banlist $CONFIG/server-banlist.json \
|
||||
--rcon-port $RCON_PORT \
|
||||
--rcon-password "$(cat $CONFIG/rconpw)" \
|
||||
--server-id /factorio/config/server-id.json
|
37
0.16/scenario2map.sh
Executable file
37
0.16/scenario2map.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh -x
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "No argument supplied"
|
||||
fi
|
||||
SCENARIO=$1
|
||||
|
||||
set -e
|
||||
|
||||
id
|
||||
|
||||
SAVES=/factorio/saves
|
||||
CONFIG=/factorio/config
|
||||
MODS=/factorio/mods
|
||||
SCENARIOS=/factorio/scenarios
|
||||
|
||||
mkdir -p $SAVES
|
||||
mkdir -p $CONFIG
|
||||
mkdir -p $MODS
|
||||
mkdir -p $SCENARIOS
|
||||
|
||||
#chown -R factorio /factorio
|
||||
|
||||
if [ ! -f $CONFIG/server-settings.json ]; then
|
||||
cp /opt/factorio/data/server-settings.example.json $CONFIG/server-settings.json
|
||||
fi
|
||||
|
||||
if [ ! -f $CONFIG/map-gen-settings.json ]; then
|
||||
cp /opt/factorio/data/map-gen-settings.example.json $CONFIG/map-gen-settings.json
|
||||
fi
|
||||
|
||||
if [ ! -f $CONFIG/map-settings.json ]; then
|
||||
cp /opt/factorio/data/map-settings.example.json $CONFIG/map-settings.json
|
||||
fi
|
||||
|
||||
exec /opt/factorio/bin/x64/factorio \
|
||||
--scenario2map $SCENARIO
|
32
README.md
32
README.md
@ -113,6 +113,38 @@ To generate a new map stop the server, delete all of the saves and restart the s
|
||||
Copy mods into the mods folder and restart the server.
|
||||
|
||||
|
||||
## Scenarios
|
||||
|
||||
If you want to launch a scenario from a clean start (not from a saved map) you'll need to start the docker image from an alternate entrypoint. To do this, use the example entrypoint file stored in the /factorio/entrypoints directory in the volume, and launch the image with the following syntax. Note that this is the normal syntax with the addition of the --entrypoint setting AND the additional argument at the end, which is the name of the Scenario in the Scenarios folder.
|
||||
|
||||
```
|
||||
docker run -d \
|
||||
-p 34197:34197/udp \
|
||||
-p 27015:27015/tcp \
|
||||
-v /opt/factorio:/factorio \
|
||||
--name factorio \
|
||||
--restart=always \
|
||||
--entrypoint "/factorio/entrypoints/scenario.sh" \
|
||||
dtandersen/factorio \
|
||||
MyScenarioName
|
||||
```
|
||||
|
||||
## Converting Scenarios to Regular Maps
|
||||
|
||||
If you would like to export your scenario to a saved map, you can use the example entrypoint similar to the Scenario usag above. Factorio will run once, converting the Scenario to a saved Map in your saves directory. A restart of the docker image using the standard options will then load that map, just as if the scenario were just started by the Scenarios example noted above.
|
||||
|
||||
```
|
||||
docker run -d \
|
||||
-p 34197:34197/udp \
|
||||
-p 27015:27015/tcp \
|
||||
-v /opt/factorio:/factorio \
|
||||
--name factorio \
|
||||
--restart=always \
|
||||
--entrypoint "/factorio/entrypoints/scenario2map.sh" \
|
||||
dtandersen/factorio
|
||||
MyScenarioName
|
||||
```
|
||||
|
||||
## RCON
|
||||
|
||||
Set the RCON password in the `rconpw` file. A random password is generated if `rconpw` doesn't exist.
|
||||
|
Loading…
Reference in New Issue
Block a user