mirror of
https://github.com/factoriotools/factorio-docker.git
synced 2025-07-08 02:04:53 +02:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
94f127dea9 | |||
4d43c3aabf |
@ -1,29 +0,0 @@
|
|||||||
FROM frolvlad/alpine-glibc:alpine-3.4
|
|
||||||
|
|
||||||
MAINTAINER https://github.com/dtandersen/docker_factorio_server
|
|
||||||
|
|
||||||
COPY ./factorio.crt /opt/factorio.crt
|
|
||||||
|
|
||||||
ENV VERSION=0.14.16 \
|
|
||||||
SHA1=e27c658bf8a7579b662a1c34815daa223e57bc90
|
|
||||||
|
|
||||||
RUN apk --update --no-cache 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 "$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 && \
|
|
||||||
apk --no-cache del curl && \
|
|
||||||
ln -s /factorio/saves /opt/factorio/saves && \
|
|
||||||
ln -s /factorio/mods /opt/factorio/mods && \
|
|
||||||
ln -s /factorio/config/server-settings.json /opt/factorio/data/server-settings.json && \
|
|
||||||
ln -s /factorio/config/map-gen-settings.json /opt/factorio/data/map-gen-settings.json
|
|
||||||
|
|
||||||
VOLUME /factorio
|
|
||||||
|
|
||||||
EXPOSE 34197/udp 27015/tcp
|
|
||||||
|
|
||||||
COPY ./docker-entrypoint.sh /
|
|
||||||
|
|
||||||
CMD ["/docker-entrypoint.sh"]
|
|
@ -1 +0,0 @@
|
|||||||
sudo docker build -t factorio .
|
|
@ -1,28 +0,0 @@
|
|||||||
#!/bin/bash -x
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
SAVES=/opt/factorio/saves
|
|
||||||
|
|
||||||
mkdir -p /factorio/saves
|
|
||||||
mkdir -p /factorio/mods
|
|
||||||
mkdir -p /factorio/config
|
|
||||||
|
|
||||||
if [ ! -f /factorio/config/server-settings.json ]; then
|
|
||||||
cp /opt/factorio/data/server-settings.example.json /factorio/config/server-settings.json
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f /factorio/config/map-gen-settings.json ]; then
|
|
||||||
cp /opt/factorio/data/map-gen-settings.example.json /factorio/config/map-gen-settings.json
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! find -L $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
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec /opt/factorio/bin/x64/factorio \
|
|
||||||
--port 34197 \
|
|
||||||
--start-server-load-latest \
|
|
||||||
--server-settings /opt/factorio/data/server-settings.json
|
|
@ -1,9 +0,0 @@
|
|||||||
#mkdir -p /tmp/factorio/config
|
|
||||||
#mkdir -p /tmp/factorio/mods
|
|
||||||
#mkdir -p /tmp/factorio/saves
|
|
||||||
#cp -n server-settings.example.json /tmp/factorio/config/server-settings.json
|
|
||||||
#cp -n map-gen-settings.example.json /tmp/factorio/config/map-gen-settings.json
|
|
||||||
sudo docker run --rm -it \
|
|
||||||
-v /tmp/factorio:/factorio \
|
|
||||||
--name factorio \
|
|
||||||
factorio "$@"
|
|
28
Dockerfile
Normal file
28
Dockerfile
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
FROM frolvlad/alpine-glibc:alpine-3.3_glibc-2.23
|
||||||
|
|
||||||
|
MAINTAINER zopanix <zopanix@gmail.com>
|
||||||
|
|
||||||
|
WORKDIR /opt
|
||||||
|
|
||||||
|
COPY ./smart_launch.sh /opt
|
||||||
|
COPY ./factorio.crt /opt
|
||||||
|
|
||||||
|
VOLUME /opt/factorio/saves /opt/factorio/mods
|
||||||
|
|
||||||
|
ENV FACTORIO_AUTOSAVE_INTERVAL=2 \
|
||||||
|
FACTORIO_AUTOSAVE_SLOTS=3 \
|
||||||
|
FACTORIO_DISSALOW_COMMANDS=true \
|
||||||
|
FACTORIO_NO_AUTO_PAUSE=false \
|
||||||
|
VERSION=0.12.33 \
|
||||||
|
FACTORIO_SHA1=9802b22f428eb404369d496f6d40633a64984406
|
||||||
|
|
||||||
|
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 && \
|
||||||
|
rm /tmp/factorio_headless_x64_$VERSION.tar.gz
|
||||||
|
|
||||||
|
EXPOSE 34197/udp
|
||||||
|
|
||||||
|
CMD ["./smart_launch.sh"]
|
||||||
|
|
153
README.md
153
README.md
@ -1,7 +1,11 @@
|
|||||||
# Factorio [](https://hub.docker.com/r/dtandersen/factorio/) [](https://hub.docker.com/r/dtandersen/factorio/)
|
# Supported tags and respective `Dockerfile` links
|
||||||
|
|
||||||
* `0.14.16`, `0.14`, `latest` [(0.14.16/Dockerfile)](https://github.com/dtandersen/docker_factorio_server/blob/0.14.16/Dockerfile)
|
* `0.12.33`, `latest` [(0.12.33/Dockerfile)](https://github.com/dtandersen/docker_factorio_server/blob/dt_0.12.33/Dockerfile)
|
||||||
|
* `0.12.32` [(0.12.32/Dockerfile)](https://github.com/dtandersen/docker_factorio_server/blob/dt_0.12.32/Dockerfile)
|
||||||
|
* `0.12.31` [(0.12.31/Dockerfile)](https://github.com/dtandersen/docker_factorio_server/blob/dt_0.12.31/Dockerfile)
|
||||||
|
* `0.12.30` [(0.12.30/Dockerfile)](https://github.com/dtandersen/docker_factorio_server/blob/dt_0.12.30/Dockerfile)
|
||||||
|
|
||||||
|
[](https://imagelayers.io/?images=dtandersen/factorio:latest 'Get your own badge on imagelayers.io')
|
||||||
|
|
||||||
# What is Factorio?
|
# What is Factorio?
|
||||||
|
|
||||||
@ -11,106 +15,137 @@ You will be mining resources, researching technologies, building infrastructure,
|
|||||||
|
|
||||||
The game is very stable and optimized for building massive factories. You can create your own maps, write mods in Lua or play with friends via Multiplayer.
|
The game is very stable and optimized for building massive factories. You can create your own maps, write mods in Lua or play with friends via Multiplayer.
|
||||||
|
|
||||||
NOTE: This is only the server. The game is available at [factorio.com](https://www.factorio.com) and [Steam](http://store.steampowered.com/app/427520/).
|
NOTE: This is only the server. The game is available on [Steam](http://store.steampowered.com/app/427520/).
|
||||||
|
|
||||||
|
# Features
|
||||||
|
|
||||||
# Usage
|
* Automatically takes latest save or autosave when restarting the container.
|
||||||
|
* Volumes for saves and mods
|
||||||
|
* Set autosave interval and number of saves.
|
||||||
|
* Enable/disable the no-auto-pause option.
|
||||||
|
* Enable/disable console commands in game.
|
||||||
|
* Based on Alpine Linux.
|
||||||
|
|
||||||
|
# How to use this image?
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
Run the server to create the necessary folder structure and configuration files. For this example data is stored in `/tmp/factorio`.
|
This runs factorio with default settings, and your save will be kept:
|
||||||
|
|
||||||
```
|
```
|
||||||
docker run -d -P -v /tmp/factorio:/factorio --name factorio dtandersen/factorio
|
docker run -d \
|
||||||
|
-v [PATH]:/opt/factorio/saves \
|
||||||
|
-p [PORT]:34197/udp \
|
||||||
|
dtandersen/factorio
|
||||||
```
|
```
|
||||||
|
|
||||||
For those new to Docker, here is an explanation of the options:
|
* Where [PATH] is a folder where you'll put your saves, if there already is a save in it with the string "save", that one will be taken by default, otherwize, a new one will be made.
|
||||||
|
* Where [PORT] is the port number you choose, if you're going to launch it on your local machine, don't use the port 34197, take another one at random.
|
||||||
|
|
||||||
* `-d` - Run as a daemon ("detached").
|
## Advanced usage
|
||||||
* `-P` - Expose all ports.
|
|
||||||
* `-v` - Mount `/tmp/factorio` on the local file system to `/factorio` in the container.
|
|
||||||
* `--name` - Name the container "factorio" (otherwise it has a funny random name).
|
|
||||||
|
|
||||||
Check the logs to see what happened:
|
### Without map persistence
|
||||||
|
|
||||||
|
This will generate a new random map with default settings.
|
||||||
|
|
||||||
```
|
```
|
||||||
docker logs factorio
|
docker run -d \
|
||||||
|
-p [PORT]:34197/udp \
|
||||||
|
dtandersen/factorio
|
||||||
```
|
```
|
||||||
|
|
||||||
Stop the server:
|
### With map persistence
|
||||||
|
|
||||||
|
This will generate a new random map with default settings and save it onto the volume.
|
||||||
|
Replace [PATH] with a path to a folder on the host where the map will be saved.
|
||||||
|
|
||||||
```
|
```
|
||||||
docker stop factorio
|
docker run -d \
|
||||||
|
-v [PATH]:/opt/factorio/saves \
|
||||||
|
-p [PORT]:34197/udp \
|
||||||
|
dtandersen/factorio
|
||||||
```
|
```
|
||||||
|
|
||||||
Now there's a `server-settings.json` file in the folder `/tmp/factorio/config`. Modify this to your liking and restart the server:
|
### With existing map
|
||||||
|
|
||||||
|
It's the same as above, it takes the last modified file which contains the word save in the filename as current save when booting the server. This allows when upgrading the container to take the last save, you don't have to rename the last autosave as save.zip
|
||||||
|
|
||||||
```
|
```
|
||||||
docker start factorio
|
docker run -d \
|
||||||
|
-v [PATH]:/opt/factorio/saves \
|
||||||
|
-p [PORT]:34197/udp \
|
||||||
|
dtandersen/factorio
|
||||||
```
|
```
|
||||||
|
|
||||||
Try to connect to the server. Check the logs if it isn't working.
|
### Autosave interval
|
||||||
|
|
||||||
|
You can set the autosave interval. By default it is set at 2 minutes bud you can change it by launching the container with the `FACTORIO_AUTOSAVE_INTERVAL` variable to whatever suits you best.
|
||||||
|
|
||||||
## Saves
|
```
|
||||||
|
docker run -d \
|
||||||
|
--env FACTORIO_AUTOSAVE_INTERVAL=[NUMBER] \
|
||||||
|
-p [PORT]:34197/udp \
|
||||||
|
dtandersen/factorio
|
||||||
|
```
|
||||||
|
|
||||||
A new map named `save.zip` is generated the first time the server is started. The `map-gen-settings.json` file in `/tmp/factorio/config` is used for the map settings. On subsequent runs the newest save is used.
|
Where [NUMBER] is the number of minutes between autosaves.
|
||||||
|
|
||||||
To load an old save stop the server and run the command `touch oldsave.zip`. This resets the date. Then restart the server.
|
### Autosave slots
|
||||||
|
|
||||||
To generate a new map stop the server, delete all of the saves and restart the server.
|
You can set the number of autosave slots. By default it is set at 3 slots bud you can change it by launching the container with the `FACTORIO_AUTOSAVE_SLOTS` variable to whatever suits you best.
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run -d \
|
||||||
|
--env FACTORIO_AUTOSAVE_SLOTS=[NUMBER] \
|
||||||
|
-p [PORT]:34197/udp \
|
||||||
|
dtandersen/factorio
|
||||||
|
```
|
||||||
|
|
||||||
## Mods
|
Where [NUMBER] is the number of autosave slots.
|
||||||
|
|
||||||
Copy mods into the mods folder and restart the server.
|
### Mounting mod volume
|
||||||
|
|
||||||
|
As everybody knows about factorio is you can add mods to it. Now you can also do it in this docker image by mounting a volume.
|
||||||
|
|
||||||
## Remote Console
|
```
|
||||||
|
docker run -d \
|
||||||
|
-v [PATH]:/opt/factorio/mods \
|
||||||
|
-p [PORT]:34197/udp \
|
||||||
|
dtandersen/factorio
|
||||||
|
```
|
||||||
|
|
||||||
RCON is currently disabled.
|
Where [PATH] is the path to the folder with your mods.
|
||||||
|
|
||||||
|
### Allowing in-game commands
|
||||||
|
|
||||||
# Container Details
|
I've always disabled in-game commands because I think it is like cheating, however, you can enable them by setting the the `FACTORIO_DISSALOW_COMMANDS` variable to "false".
|
||||||
|
|
||||||
The philosophy is to keep things simple.
|
```
|
||||||
|
docker run -d \
|
||||||
|
--env FACTORIO_DISSALOW_COMMANDS=false \
|
||||||
|
-p [PORT]:34197/udp \
|
||||||
|
dtandersen/factorio
|
||||||
|
```
|
||||||
|
|
||||||
* Self-configure to a minimal working state.
|
### Activating no-auto-pause in the game when no one is on the server
|
||||||
* Prefer configuration files over environment variables.
|
|
||||||
* Use one volume for data.
|
|
||||||
|
|
||||||
|
I do not recommend this feature, bud it can make the game more difficult if you're up for a challenge :-). Just set the `FACTORIO_NO_AUTO_PAUSE` variable to "true".
|
||||||
|
|
||||||
## Volumes
|
```
|
||||||
|
docker run -d \
|
||||||
|
--env FACTORIO_NO_AUTO_PAUSE=true \
|
||||||
|
-p [PORT]:34197/udp \
|
||||||
|
dtandersen/factorio
|
||||||
|
```
|
||||||
|
|
||||||
To keep things simple, the container uses a single volume mounted at `/factorio`. This volume stores configuration, mods, and saves.
|
### Logs
|
||||||
|
|
||||||
factorio
|
Sometimes it's useful to see the logs of a running container:
|
||||||
|-- config
|
|
||||||
| |-- server-settings.json
|
|
||||||
| +-- map-gen-settings.json
|
|
||||||
|-- mods
|
|
||||||
| |-- fancymod.zip
|
|
||||||
+-- saves
|
|
||||||
|-- _autosave1.zip
|
|
||||||
+-- save.zip
|
|
||||||
|
|
||||||
|
|
||||||
## Ports
|
|
||||||
|
|
||||||
* `34197/udp` - Factorio clients (required).
|
|
||||||
* `27015/tcp` - RCON (optional).
|
|
||||||
|
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
**Server is listed in the in-game server browser, but users can't connect**
|
|
||||||
|
|
||||||
Run Docker with the `--userland-proxy=false` option. The source UDP port is changed by docker-proxy when the server pings "pingpong" servers. See [Incorrect port detected for docker hosted server](https://forums.factorio.com/viewtopic.php?f=49&t=35255).
|
|
||||||
|
|
||||||
|
```
|
||||||
|
docker exec -it [CONTAINER] tail -f /opt/factorio/factorio-current.log
|
||||||
|
```
|
||||||
|
|
||||||
# Credits
|
# Credits
|
||||||
|
|
||||||
Ideas borrowed from:
|
Based on [Zopanix' Factorio Server](https://github.com/zopanix/docker_factorio_server).
|
||||||
|
|
||||||
* [Zopanix](https://github.com/zopanix/docker_factorio_server)
|
|
||||||
* [Rfvgyhn](https://github.com/Rfvgyhn/docker-factorio)
|
|
||||||
|
43
smart_launch.sh
Executable file
43
smart_launch.sh
Executable file
@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -f /opt/factorio/saves/save.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)}')
|
||||||
|
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 "###"
|
||||||
|
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
|
Reference in New Issue
Block a user