mirror of
https://github.com/factoriotools/factorio-docker.git
synced 2025-07-01 14:38:05 +02:00
Compare commits
79 Commits
Author | SHA1 | Date | |
---|---|---|---|
66c11b1a82 | |||
49055cfe1b | |||
ab818efda4 | |||
6da1250b5b | |||
deaaf83967 | |||
9691472b84 | |||
236b27d94e | |||
457ab79b5b | |||
235a2abb60 | |||
c52f649b35 | |||
52167abffa | |||
f20fe0ad85 | |||
1cd2015cc4 | |||
c4b2d30366 | |||
5c81134430 | |||
7d220042a9 | |||
e61a3aa622 | |||
773005b320 | |||
51185620dd | |||
c24b7bc41b | |||
5301aff1b1 | |||
502f13c1cd | |||
fe3d0d65bc | |||
4bc30e718c | |||
994a091595 | |||
c754e64e47 | |||
a2726704ed | |||
f4e8b30e90 | |||
07dcd690bd | |||
4bf909979a | |||
7ec79a6e1b | |||
6a1317cb7a | |||
15efa9caec | |||
41b2c9b743 | |||
4e4810aea3 | |||
d667a247e1 | |||
ce1f980525 | |||
120ee1bbdb | |||
5cba3991ef | |||
412c16e379 | |||
82635a9cff | |||
c495fc38a4 | |||
b580447de4 | |||
2290034ecf | |||
300300e7ec | |||
179be082d9 | |||
efcc29cfed | |||
1b7decd8ce | |||
b38750e4ac | |||
bfb8b7fd95 | |||
8b5d4e06df | |||
33060cc4fb | |||
e1beb32f81 | |||
2c1d1cd985 | |||
39fd391e9b | |||
a5d6466f0b | |||
c6b15d89c1 | |||
7c9011dcee | |||
b5af3130e2 | |||
e307b1d537 | |||
8c0ddf99ce | |||
d7b79c567a | |||
3e62698b4b | |||
d4870219f6 | |||
01194242b9 | |||
4255475b18 | |||
4ff8179912 | |||
db14988396 | |||
cd29f2003b | |||
cd2d89a7bc | |||
2d9f646728 | |||
9e96ca5aa8 | |||
5c947846d1 | |||
edd0c95d9b | |||
6651289d6e | |||
784626b689 | |||
47ce1706db | |||
460ba0187d | |||
6d496def35 |
17
.travis.yml
17
.travis.yml
@ -1,8 +1,8 @@
|
||||
dist: xenial
|
||||
sudo: required
|
||||
language: bash
|
||||
services:
|
||||
services:
|
||||
- docker
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@ -14,14 +14,21 @@ jobs:
|
||||
script:
|
||||
- git ls-files --exclude='*Dockerfile' --ignored | xargs --max-lines=1 -I{} sh -c 'docker run --rm -i -v ${PWD}/.hadolint.yaml:/.hadolint.yaml hadolint/hadolint < "$1"' -- {}
|
||||
- bash -c 'shopt -s globstar; shellcheck **/*.sh'
|
||||
|
||||
- &build
|
||||
stage: build
|
||||
env: VERSION_SHORT=0.17 EXTRA_TAG=latest
|
||||
stage: Build & update Docker HUB description
|
||||
env: VERSION_SHORT=0.18 EXTRA_TAG=latest
|
||||
script:
|
||||
- ./build.sh $VERSION_SHORT
|
||||
- <<: *build
|
||||
env: VERSION_SHORT=0.16 EXTRA_TAG=stable
|
||||
env: VERSION_SHORT=0.17 EXTRA_TAG=stable
|
||||
- <<: *build
|
||||
env: VERSION_SHORT=0.16
|
||||
- <<: *build
|
||||
env: VERSION_SHORT=0.15
|
||||
- <<: *build
|
||||
env: VERSION_SHORT=0.14
|
||||
- <<: *build
|
||||
if: branch = master AND type != pull_request
|
||||
env:
|
||||
script: docker run -v $PWD:/workspace -e DOCKERHUB_USERNAME=$DOCKER_USERNAME -e DOCKERHUB_PASSWORD=$DOCKER_PASSWORD -e DOCKERHUB_REPOSITORY='factoriotools/factorio' -e README_FILEPATH='/workspace/README.md' peterevans/dockerhub-description:2.1.0
|
||||
|
@ -9,8 +9,8 @@ ARG PGID=845
|
||||
|
||||
ENV PORT=34197 \
|
||||
RCON_PORT=27015 \
|
||||
VERSION=0.17.57 \
|
||||
SHA1=7546ea3c272b2027534e5fc2c4e4b3351e9cf620 \
|
||||
VERSION=0.17.79 \
|
||||
SHA1=7f127baf3cf01c6e545a9ca376dec1ac37468f8a \
|
||||
SAVES=/factorio/saves \
|
||||
CONFIG=/factorio/config \
|
||||
MODS=/factorio/mods \
|
||||
|
@ -2,6 +2,10 @@
|
||||
set -eoux pipefail
|
||||
|
||||
FACTORIO_VOL=/factorio
|
||||
LOAD_LATEST_SAVE="${LOAD_LATEST_SAVE:-true}"
|
||||
GENERATE_NEW_SAVE="${GENERATE_NEW_SAVE:-false}"
|
||||
SAVE_NAME="${SAVE_NAME:-""}"
|
||||
|
||||
mkdir -p "$FACTORIO_VOL"
|
||||
mkdir -p "$SAVES"
|
||||
mkdir -p "$CONFIG"
|
||||
@ -50,18 +54,28 @@ else
|
||||
fi
|
||||
|
||||
NRSAVES=$(find -L "$SAVES" -iname \*.zip -mindepth 1 | wc -l)
|
||||
if [[ $NRSAVES -eq 0 ]]; then
|
||||
# Generate a new map if no save ZIPs exist
|
||||
$SU_EXEC /opt/factorio/bin/x64/factorio \
|
||||
--create "$SAVES/_autosave1.zip" \
|
||||
--map-gen-settings "$CONFIG/map-gen-settings.json" \
|
||||
--map-settings "$CONFIG/map-settings.json"
|
||||
if [[ $GENERATE_NEW_SAVE != true && $NRSAVES == 0 ]]; then
|
||||
GENERATE_NEW_SAVE=true
|
||||
SAVE_NAME=_autosave1
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
exec $SU_EXEC /opt/factorio/bin/x64/factorio \
|
||||
if [[ $GENERATE_NEW_SAVE == true ]]; then
|
||||
if [[ -z "$SAVE_NAME" ]]; then
|
||||
echo "If \$GENERATE_NEW_SAVE is true, you must specify \$SAVE_NAME"
|
||||
exit 1
|
||||
fi
|
||||
if [[ -f "$SAVES/$SAVE_NAME.zip" ]]; then
|
||||
echo "Map $SAVES/$SAVE_NAME.zip already exists, skipping map generation"
|
||||
else
|
||||
$SU_EXEC /opt/factorio/bin/x64/factorio \
|
||||
--create "$SAVES/$SAVE_NAME.zip" \
|
||||
--map-gen-settings "$CONFIG/map-gen-settings.json" \
|
||||
--map-settings "$CONFIG/map-settings.json"
|
||||
fi
|
||||
fi
|
||||
|
||||
FLAGS=(\
|
||||
--port "$PORT" \
|
||||
--start-server-load-latest \
|
||||
--server-settings "$CONFIG/server-settings.json" \
|
||||
--server-banlist "$CONFIG/server-banlist.json" \
|
||||
--rcon-port "$RCON_PORT" \
|
||||
@ -70,4 +84,13 @@ exec $SU_EXEC /opt/factorio/bin/x64/factorio \
|
||||
--server-adminlist "$CONFIG/server-adminlist.json" \
|
||||
--rcon-password "$(cat "$CONFIG/rconpw")" \
|
||||
--server-id /factorio/config/server-id.json \
|
||||
"$@"
|
||||
)
|
||||
|
||||
if [[ $LOAD_LATEST_SAVE == true ]]; then
|
||||
FLAGS+=( --start-server-load-latest )
|
||||
else
|
||||
FLAGS+=( --start-server "$SAVE_NAME" )
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
exec $SU_EXEC /opt/factorio/bin/x64/factorio "${FLAGS[@]}" "$@"
|
||||
|
@ -33,8 +33,10 @@ exec /opt/factorio/bin/x64/factorio \
|
||||
--port "$PORT" \
|
||||
--start-server-load-scenario "$SERVER_SCENARIO" \
|
||||
--server-settings "$CONFIG/server-settings.json" \
|
||||
--server-whitelist "$CONFIG/server-whitelist.json" \
|
||||
--server-banlist "$CONFIG/server-banlist.json" \
|
||||
--server-whitelist "$CONFIG/server-whitelist.json" \
|
||||
--use-server-whitelist \
|
||||
--server-adminlist "$CONFIG/server-adminlist.json" \
|
||||
--rcon-port "$RCON_PORT" \
|
||||
--rcon-password "$(cat "$CONFIG/rconpw")" \
|
||||
--server-id /factorio/config/server-id.json
|
||||
|
@ -32,19 +32,20 @@ update_mod()
|
||||
MOD_INFO_URL="$MOD_BASE_URL/api/mods/$MOD_NAME"
|
||||
MOD_INFO_JSON=$(curl --silent "$MOD_INFO_URL")
|
||||
|
||||
if ! echo "$MOD_INFO_JSON" | jq -e .name >/dev/null; then
|
||||
print_success " Custom mod not on $MOD_BASE_URL, skipped."
|
||||
return 0
|
||||
fi
|
||||
|
||||
MOD_INFO=$(echo "$MOD_INFO_JSON" | jq -j --arg version "$FACTORIO_VERSION" ".releases|reverse|map(select(.info_json.factorio_version as \$mod_version | \$version | startswith(\$mod_version)))[0]|.file_name, \";\", .download_url, \";\", .sha1")
|
||||
|
||||
MOD_FILENAME=$(echo "$MOD_INFO" | cut -f1 -d";")
|
||||
MOD_URL=$(echo "$MOD_INFO" | cut -f2 -d";")
|
||||
MOD_SHA1=$(echo "$MOD_INFO" | cut -f3 -d";")
|
||||
|
||||
if [[ -z $MOD_URL ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ $MOD_FILENAME == null ]]; then
|
||||
print_failure " Not compatible with version"
|
||||
return 1
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -f $MOD_DIR/$MOD_FILENAME ]]; then
|
||||
@ -58,7 +59,7 @@ update_mod()
|
||||
|
||||
if [[ $HTTP_STATUS != 200 ]]; then
|
||||
print_failure " Download failed: Code $HTTP_STATUS."
|
||||
rm "$MOD_DIR/$MOD_FILENAME"
|
||||
rm -f "$MOD_DIR/$MOD_FILENAME"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@ -69,7 +70,7 @@ update_mod()
|
||||
|
||||
if ! [[ $(sha1sum "$MOD_DIR/$MOD_FILENAME") =~ $MOD_SHA1 ]]; then
|
||||
print_failure " SHA1 mismatch!"
|
||||
rm "$MOD_DIR/$MOD_FILENAME"
|
||||
rm -f "$MOD_DIR/$MOD_FILENAME"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@ -78,7 +79,7 @@ update_mod()
|
||||
for file in "$MOD_DIR/${MOD_NAME}_"*".zip"; do # wildcard does usually not work in quotes: https://unix.stackexchange.com/a/67761
|
||||
if [[ $file != $MOD_DIR/$MOD_FILENAME ]]; then
|
||||
print_success " Deleting old version: $file"
|
||||
rm "$file"
|
||||
rm -f "$file"
|
||||
fi
|
||||
done
|
||||
|
||||
|
46
0.18/Dockerfile
Normal file
46
0.18/Dockerfile
Normal file
@ -0,0 +1,46 @@
|
||||
FROM frolvlad/alpine-glibc:alpine-3.9
|
||||
|
||||
LABEL maintainer="https://github.com/factoriotools/factorio-docker"
|
||||
|
||||
ARG USER=factorio
|
||||
ARG GROUP=factorio
|
||||
ARG PUID=845
|
||||
ARG PGID=845
|
||||
|
||||
ENV PORT=34197 \
|
||||
RCON_PORT=27015 \
|
||||
VERSION=0.18.21 \
|
||||
SHA1=21bab03c7bc85fbf9c640ad1f8eba1825ecbcb91 \
|
||||
SAVES=/factorio/saves \
|
||||
CONFIG=/factorio/config \
|
||||
MODS=/factorio/mods \
|
||||
SCENARIOS=/factorio/scenarios \
|
||||
SCRIPTOUTPUT=/factorio/script-output \
|
||||
PUID="$PUID" \
|
||||
PGID="$PGID"
|
||||
|
||||
RUN set -ox pipefail \
|
||||
&& archive="/tmp/factorio_headless_x64_$VERSION.tar.xz" \
|
||||
&& mkdir -p /opt /factorio \
|
||||
&& apk add --update --no-cache --no-progress bash binutils curl file gettext jq libintl pwgen shadow su-exec \
|
||||
&& curl -sSL "https://www.factorio.com/get-download/$VERSION/headless/linux64" -o "$archive" \
|
||||
&& echo "$SHA1 $archive" | sha1sum -c \
|
||||
|| (sha1sum "$archive" && file "$archive" && exit 1) \
|
||||
&& tar xf "$archive" --directory /opt \
|
||||
&& chmod ugo=rwx /opt/factorio \
|
||||
&& rm "$archive" \
|
||||
&& ln -s "$SAVES" /opt/factorio/saves \
|
||||
&& ln -s "$MODS" /opt/factorio/mods \
|
||||
&& ln -s "$SCENARIOS" /opt/factorio/scenarios \
|
||||
&& ln -s "$SCRIPTOUTPUT" /opt/factorio/script-output \
|
||||
&& addgroup -g "$PGID" -S "$GROUP" \
|
||||
&& adduser -u "$PUID" -G "$GROUP" -s /bin/sh -SDH "$USER" \
|
||||
&& chown -R "$USER":"$GROUP" /opt/factorio /factorio
|
||||
|
||||
VOLUME /factorio
|
||||
|
||||
EXPOSE $PORT/udp $RCON_PORT/tcp
|
||||
|
||||
COPY files/ /
|
||||
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
15
0.18/docker-compose.yml
Normal file
15
0.18/docker-compose.yml
Normal file
@ -0,0 +1,15 @@
|
||||
version: '2'
|
||||
services:
|
||||
factorio:
|
||||
build: .
|
||||
ports:
|
||||
- "34197:34197/udp"
|
||||
- "27015:27015/tcp"
|
||||
volumes:
|
||||
- /opt/factorio:/factorio
|
||||
# environment:
|
||||
# - PUID=1000
|
||||
# - PGID=1000
|
||||
# - UPDATE_MODS_ON_START=true
|
||||
# - USERNAME=FactorioUsername
|
||||
# - TOKEN=FactorioToken
|
96
0.18/files/docker-entrypoint.sh
Executable file
96
0.18/files/docker-entrypoint.sh
Executable file
@ -0,0 +1,96 @@
|
||||
#!/bin/bash
|
||||
set -eoux pipefail
|
||||
|
||||
FACTORIO_VOL=/factorio
|
||||
LOAD_LATEST_SAVE="${LOAD_LATEST_SAVE:-true}"
|
||||
GENERATE_NEW_SAVE="${GENERATE_NEW_SAVE:-false}"
|
||||
SAVE_NAME="${SAVE_NAME:-""}"
|
||||
|
||||
mkdir -p "$FACTORIO_VOL"
|
||||
mkdir -p "$SAVES"
|
||||
mkdir -p "$CONFIG"
|
||||
mkdir -p "$MODS"
|
||||
mkdir -p "$SCENARIOS"
|
||||
mkdir -p "$SCRIPTOUTPUT"
|
||||
|
||||
if [[ ! -f $CONFIG/rconpw ]]; then
|
||||
# Generate a new RCON password if none exists
|
||||
pwgen 15 1 >"$CONFIG/rconpw"
|
||||
fi
|
||||
|
||||
if [[ ! -f $CONFIG/server-settings.json ]]; then
|
||||
# Copy default settings if server-settings.json doesn't exist
|
||||
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
|
||||
|
||||
NRTMPSAVES=$( find -L "$SAVES" -iname \*.tmp.zip -mindepth 1 | wc -l )
|
||||
if [[ $NRTMPSAVES -gt 0 ]]; then
|
||||
# Delete incomplete saves (such as after a forced exit)
|
||||
rm -f "$SAVES"/*.tmp.zip
|
||||
fi
|
||||
|
||||
if [[ ${UPDATE_MODS_ON_START:-} ]]; then
|
||||
./docker-update-mods.sh
|
||||
fi
|
||||
|
||||
if [[ $(id -u) = 0 ]]; then
|
||||
# Update the User and Group ID based on the PUID/PGID variables
|
||||
usermod -o -u "$PUID" factorio
|
||||
groupmod -o -g "$PGID" factorio
|
||||
# Take ownership of factorio data if running as root
|
||||
chown -R factorio:factorio "$FACTORIO_VOL"
|
||||
# Drop to the factorio user
|
||||
SU_EXEC="su-exec factorio"
|
||||
else
|
||||
SU_EXEC=""
|
||||
fi
|
||||
|
||||
NRSAVES=$(find -L "$SAVES" -iname \*.zip -mindepth 1 | wc -l)
|
||||
if [[ $GENERATE_NEW_SAVE != true && $NRSAVES == 0 ]]; then
|
||||
GENERATE_NEW_SAVE=true
|
||||
SAVE_NAME=_autosave1
|
||||
fi
|
||||
|
||||
if [[ $GENERATE_NEW_SAVE == true ]]; then
|
||||
if [[ -z "$SAVE_NAME" ]]; then
|
||||
echo "If \$GENERATE_NEW_SAVE is true, you must specify \$SAVE_NAME"
|
||||
exit 1
|
||||
fi
|
||||
if [[ -f "$SAVES/$SAVE_NAME.zip" ]]; then
|
||||
echo "Map $SAVES/$SAVE_NAME.zip already exists, skipping map generation"
|
||||
else
|
||||
$SU_EXEC /opt/factorio/bin/x64/factorio \
|
||||
--create "$SAVES/$SAVE_NAME.zip" \
|
||||
--map-gen-settings "$CONFIG/map-gen-settings.json" \
|
||||
--map-settings "$CONFIG/map-settings.json"
|
||||
fi
|
||||
fi
|
||||
|
||||
FLAGS=(\
|
||||
--port "$PORT" \
|
||||
--server-settings "$CONFIG/server-settings.json" \
|
||||
--server-banlist "$CONFIG/server-banlist.json" \
|
||||
--rcon-port "$RCON_PORT" \
|
||||
--server-whitelist "$CONFIG/server-whitelist.json" \
|
||||
--use-server-whitelist \
|
||||
--server-adminlist "$CONFIG/server-adminlist.json" \
|
||||
--rcon-password "$(cat "$CONFIG/rconpw")" \
|
||||
--server-id /factorio/config/server-id.json \
|
||||
)
|
||||
|
||||
if [[ $LOAD_LATEST_SAVE == true ]]; then
|
||||
FLAGS+=( --start-server-load-latest )
|
||||
else
|
||||
FLAGS+=( --start-server "$SAVE_NAME" )
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
exec $SU_EXEC /opt/factorio/bin/x64/factorio "${FLAGS[@]}" "$@"
|
28
0.18/files/docker-update-mods.sh
Executable file
28
0.18/files/docker-update-mods.sh
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
set -eou pipefail
|
||||
|
||||
if [[ -f /run/secrets/username ]]; then
|
||||
USERNAME=$(cat /run/secrets/username)
|
||||
fi
|
||||
|
||||
if [[ -f /run/secrets/username ]]; then
|
||||
TOKEN=$(cat /run/secrets/token)
|
||||
fi
|
||||
|
||||
if [[ -z ${USERNAME:-} ]]; then
|
||||
USERNAME="$(jq -j ".username" "$CONFIG/server-settings.json")"
|
||||
fi
|
||||
|
||||
if [[ -z ${TOKEN:-} ]]; then
|
||||
TOKEN="$(jq -j ".token" "$CONFIG/server-settings.json")"
|
||||
fi
|
||||
|
||||
if [[ -z ${USERNAME:-} ]]; then
|
||||
echo "You need to provide your Factorio username to update mods."
|
||||
fi
|
||||
|
||||
if [[ -z ${TOKEN:-} ]]; then
|
||||
echo "You need to provide your Factorio token to update mods."
|
||||
fi
|
||||
|
||||
./update-mods.sh "$VERSION" "$MODS" "$USERNAME" "$TOKEN"
|
42
0.18/files/scenario.sh
Executable file
42
0.18/files/scenario.sh
Executable file
@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
set -eoux pipefail
|
||||
|
||||
if [[ -z ${1:-} ]]; then
|
||||
echo "No argument supplied"
|
||||
fi
|
||||
|
||||
SERVER_SCENARIO="$1"
|
||||
mkdir -p "$SAVES"
|
||||
mkdir -p "$CONFIG"
|
||||
mkdir -p "$MODS"
|
||||
mkdir -p "$SCENARIOS"
|
||||
|
||||
#chown -R factorio /factorio
|
||||
|
||||
if [[ ! -f $CONFIG/rconpw ]]; then
|
||||
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 "$SERVER_SCENARIO" \
|
||||
--server-settings "$CONFIG/server-settings.json" \
|
||||
--server-banlist "$CONFIG/server-banlist.json" \
|
||||
--server-whitelist "$CONFIG/server-whitelist.json" \
|
||||
--use-server-whitelist \
|
||||
--server-adminlist "$CONFIG/server-adminlist.json" \
|
||||
--rcon-port "$RCON_PORT" \
|
||||
--rcon-password "$(cat "$CONFIG/rconpw")" \
|
||||
--server-id /factorio/config/server-id.json
|
27
0.18/files/scenario2map.sh
Executable file
27
0.18/files/scenario2map.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
set -eoux pipefail
|
||||
|
||||
if [[ -z ${1:-} ]]; then
|
||||
echo "No argument supplied"
|
||||
fi
|
||||
|
||||
SERVER_SCENARIO="$1"
|
||||
mkdir -p "$SAVES"
|
||||
mkdir -p "$CONFIG"
|
||||
mkdir -p "$MODS"
|
||||
mkdir -p "$SCENARIOS"
|
||||
|
||||
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 "$SERVER_SCENARIO"
|
95
0.18/files/update-mods.sh
Executable file
95
0.18/files/update-mods.sh
Executable file
@ -0,0 +1,95 @@
|
||||
#!/bin/bash
|
||||
set -eou pipefail
|
||||
|
||||
FACTORIO_VERSION=$1
|
||||
MOD_DIR=$2
|
||||
USERNAME=$3
|
||||
TOKEN=$4
|
||||
|
||||
MOD_BASE_URL="https://mods.factorio.com"
|
||||
|
||||
print_step()
|
||||
{
|
||||
echo "$1"
|
||||
}
|
||||
|
||||
print_success()
|
||||
{
|
||||
echo "$1"
|
||||
}
|
||||
|
||||
print_failure()
|
||||
{
|
||||
echo "$1"
|
||||
}
|
||||
|
||||
update_mod()
|
||||
{
|
||||
MOD_NAME="${1// /%20}"
|
||||
|
||||
print_step "Checking for update of mod $MOD_NAME..."
|
||||
|
||||
MOD_INFO_URL="$MOD_BASE_URL/api/mods/$MOD_NAME"
|
||||
MOD_INFO_JSON=$(curl --silent "$MOD_INFO_URL")
|
||||
|
||||
if ! echo "$MOD_INFO_JSON" | jq -e .name >/dev/null; then
|
||||
print_success " Custom mod not on $MOD_BASE_URL, skipped."
|
||||
return 0
|
||||
fi
|
||||
|
||||
MOD_INFO=$(echo "$MOD_INFO_JSON" | jq -j --arg version "$FACTORIO_VERSION" ".releases|reverse|map(select(.info_json.factorio_version as \$mod_version | \$version | startswith(\$mod_version)))[0]|.file_name, \";\", .download_url, \";\", .sha1")
|
||||
|
||||
MOD_FILENAME=$(echo "$MOD_INFO" | cut -f1 -d";")
|
||||
MOD_URL=$(echo "$MOD_INFO" | cut -f2 -d";")
|
||||
MOD_SHA1=$(echo "$MOD_INFO" | cut -f3 -d";")
|
||||
|
||||
if [[ $MOD_FILENAME == null ]]; then
|
||||
print_failure " Not compatible with version"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -f $MOD_DIR/$MOD_FILENAME ]]; then
|
||||
print_success " Already up-to-date."
|
||||
return 0
|
||||
fi
|
||||
|
||||
print_step "Downloading..."
|
||||
FULL_URL="$MOD_BASE_URL$MOD_URL?username=$USERNAME&token=$TOKEN"
|
||||
HTTP_STATUS=$(curl --silent -L -w "%{http_code}" -o "$MOD_DIR/$MOD_FILENAME" "$FULL_URL")
|
||||
|
||||
if [[ $HTTP_STATUS != 200 ]]; then
|
||||
print_failure " Download failed: Code $HTTP_STATUS."
|
||||
rm -f "$MOD_DIR/$MOD_FILENAME"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ ! -f $MOD_DIR/$MOD_FILENAME ]]; then
|
||||
print_failure " Downloaded file missing!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! [[ $(sha1sum "$MOD_DIR/$MOD_FILENAME") =~ $MOD_SHA1 ]]; then
|
||||
print_failure " SHA1 mismatch!"
|
||||
rm -f "$MOD_DIR/$MOD_FILENAME"
|
||||
return 1
|
||||
fi
|
||||
|
||||
print_success " Download complete."
|
||||
|
||||
for file in "$MOD_DIR/${MOD_NAME}_"*".zip"; do # wildcard does usually not work in quotes: https://unix.stackexchange.com/a/67761
|
||||
if [[ $file != $MOD_DIR/$MOD_FILENAME ]]; then
|
||||
print_success " Deleting old version: $file"
|
||||
rm -f "$file"
|
||||
fi
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
if [[ -f $MOD_DIR/mod-list.json ]]; then
|
||||
jq -r ".mods|map(select(.enabled))|.[].name" "$MOD_DIR/mod-list.json" | while read -r mod; do
|
||||
if [[ $mod != base ]]; then
|
||||
update_mod "$mod"
|
||||
fi
|
||||
done
|
||||
fi
|
242
README.md
242
README.md
@ -1,11 +1,12 @@
|
||||
# Factorio [](https://travis-ci.org/factoriotools/factorio-docker) [](https://hub.docker.com/r/factoriotools/factorio/) [](https://hub.docker.com/r/factoriotools/factorio/) [](https://hub.docker.com/r/factoriotools/factorio/) [](https://microbadger.com/images/factoriotools/factorio "Get your own image badge on microbadger.com")
|
||||
# Factorio [](https://travis-ci.org/factoriotools/factorio-docker)  [](https://hub.docker.com/r/factoriotools/factorio/) [](https://hub.docker.com/r/factoriotools/factorio/) [](https://hub.docker.com/r/factoriotools/factorio/) [](https://microbadger.com/images/factoriotools/factorio "Get your own image badge on microbadger.com")
|
||||
|
||||
* `0.17.57`, `0.17`, `latest` [(0.17/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.17/Dockerfile)
|
||||
* `0.16.51`, `0.16`, `stable` [(0.16/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.16/Dockerfile)
|
||||
* `0.18.21`, `0.18`, `latest` [(0.18/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.18/Dockerfile)
|
||||
* `0.17.79`, `0.17`, `stable` [(0.17/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.17/Dockerfile)
|
||||
* `0.16.51`, `0.16` [(0.16/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.16/Dockerfile)
|
||||
* `0.15.40`, `0.15` [(0.15/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.15/Dockerfile)
|
||||
* `0.14.23`, `0.14` [(0.14/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.14/Dockerfile)
|
||||
|
||||
*Tag descriptions*
|
||||
## Tag descriptions
|
||||
|
||||
* `latest` - most up-to-date version (may be experimental).
|
||||
* `stable` - version declared stable on [factorio.com](https://www.factorio.com).
|
||||
@ -13,8 +14,7 @@
|
||||
* `0.x.y` - a specific version.
|
||||
* `0.x-z` - incremental fix for that version.
|
||||
|
||||
|
||||
# What is Factorio?
|
||||
## What is Factorio?
|
||||
|
||||
[Factorio](https://www.factorio.com) is a game in which you build and maintain factories.
|
||||
|
||||
@ -22,16 +22,15 @@ 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.
|
||||
|
||||
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 full game is available at [Factorio.com](https://www.factorio.com), [Steam](https://store.steampowered.com/app/427520/), [GOG.com](https://www.gog.com/game/factorio) and [Humble Bundle](https://www.humblebundle.com/store/factorio).
|
||||
|
||||
## Usage
|
||||
|
||||
# Usage
|
||||
|
||||
## Quick Start
|
||||
### Quick Start
|
||||
|
||||
Run the server to create the necessary folder structure and configuration files. For this example data is stored in `/opt/factorio`.
|
||||
|
||||
```
|
||||
```shell
|
||||
sudo mkdir -p /opt/factorio
|
||||
sudo chown 845:845 /opt/factorio
|
||||
sudo docker run -d \
|
||||
@ -55,36 +54,36 @@ The `chown` command is needed because in 0.16+, we no longer run the game server
|
||||
|
||||
Check the logs to see what happened:
|
||||
|
||||
```
|
||||
```shell
|
||||
docker logs factorio
|
||||
```
|
||||
|
||||
Stop the server:
|
||||
|
||||
```
|
||||
```shell
|
||||
docker stop factorio
|
||||
```
|
||||
|
||||
Now there's a `server-settings.json` file in the folder `/opt/factorio/config`. Modify this to your liking and restart the server:
|
||||
|
||||
```
|
||||
```shell
|
||||
docker start factorio
|
||||
```
|
||||
|
||||
Try to connect to the server. Check the logs if it isn't working.
|
||||
|
||||
|
||||
## Console
|
||||
### Console
|
||||
|
||||
To issue console commands to the server, start the server in interactive mode with `-it`. Open the console with `docker attach` and then type commands.
|
||||
|
||||
docker run -d -it \
|
||||
--name factorio \
|
||||
factoriotools/factorio
|
||||
docker attach factorio
|
||||
```shell
|
||||
docker run -d -it \
|
||||
--name factorio \
|
||||
factoriotools/factorio
|
||||
docker attach factorio
|
||||
```
|
||||
|
||||
|
||||
## Upgrading
|
||||
### Upgrading
|
||||
|
||||
Before upgrading backup the save. It's easy to make a save in the client.
|
||||
|
||||
@ -92,14 +91,15 @@ Ensure `-v` was used to run the server so the save is outside of the Docker cont
|
||||
|
||||
Delete the container and refresh the image:
|
||||
|
||||
docker stop factorio
|
||||
docker rm factorio
|
||||
docker pull factoriotools/factorio
|
||||
```shell
|
||||
docker stop factorio
|
||||
docker rm factorio
|
||||
docker pull factoriotools/factorio
|
||||
```
|
||||
|
||||
Now run the server as before. In about a minute the new version of Factorio should be up and running, complete with saves and config!
|
||||
|
||||
|
||||
## Saves
|
||||
### Saves
|
||||
|
||||
A new map named `_autosave1.zip` is generated the first time the server is started. The `map-gen-settings.json` and `map-settings.json` files in `/opt/factorio/config` are used for the map settings. On subsequent runs the newest save is used.
|
||||
|
||||
@ -107,19 +107,50 @@ To load an old save stop the server and run the command `touch oldsave.zip`. Thi
|
||||
|
||||
To generate a new map stop the server, delete all of the saves and restart the server.
|
||||
|
||||
#### Specify a save directly (0.17.79-2+)
|
||||
|
||||
## Mods
|
||||
You can specify a specific save to load by configuring the server through a set of environment variables:
|
||||
|
||||
To load an existing save set `SAVE_NAME` to the name of your existing save file located within the `saves` directory, without the `.zip` extension:
|
||||
|
||||
```shell
|
||||
sudo docker run -d \
|
||||
-p 34197:34197/udp \
|
||||
-p 27015:27015/tcp \
|
||||
-v /opt/factorio:/factorio \
|
||||
-e ENABLE_SERVER_LOAD_LATEST=false \
|
||||
-e SAVE_NAME=replaceme \
|
||||
--name factorio \
|
||||
--restart=always \
|
||||
factoriotools/factorio
|
||||
```
|
||||
|
||||
To generate a new map set `ENABLE_GENERATE_NEW_MAP_SAVE=true` and specify `SAVE_NAME`:
|
||||
|
||||
```shell
|
||||
sudo docker run -d \
|
||||
-p 34197:34197/udp \
|
||||
-p 27015:27015/tcp \
|
||||
-v /opt/factorio:/factorio \
|
||||
-e ENABLE_SERVER_LOAD_LATEST=false \
|
||||
-e ENABLE_GENERATE_NEW_MAP_SAVE=true \
|
||||
-e SAVE_NAME=replaceme \
|
||||
--name factorio \
|
||||
--restart=always \
|
||||
factoriotools/factorio
|
||||
```
|
||||
|
||||
### Mods
|
||||
|
||||
Copy mods into the mods folder and restart the server.
|
||||
|
||||
As of 0.17 a new environment variable was added ``UPDATE_MODS_ON_START`` which if set to ``true`` will cause the mods get to updated on server start. If set a valid [Factorio Username and Token](https://www.factorio.com/profile) must be supplied or else the server will not start. They can either be set as docker secrets, environment variables, or pulled from the server-settings.json file.
|
||||
|
||||
|
||||
## Scenarios
|
||||
### 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.
|
||||
|
||||
```
|
||||
```shell
|
||||
docker run -d \
|
||||
-p 34197:34197/udp \
|
||||
-p 27015:27015/tcp \
|
||||
@ -131,11 +162,11 @@ docker run -d \
|
||||
MyScenarioName
|
||||
```
|
||||
|
||||
## Converting Scenarios to Regular Maps
|
||||
### 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 usage 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.
|
||||
|
||||
```
|
||||
```shell
|
||||
docker run -d \
|
||||
-p 34197:34197/udp \
|
||||
-p 27015:27015/tcp \
|
||||
@ -147,7 +178,7 @@ docker run -d \
|
||||
MyScenarioName
|
||||
```
|
||||
|
||||
## RCON
|
||||
### RCON
|
||||
|
||||
Set the RCON password in the `rconpw` file. A random password is generated if `rconpw` doesn't exist.
|
||||
|
||||
@ -155,60 +186,67 @@ To change the password, stop the server, modify `rconpw`, and restart the server
|
||||
|
||||
To "disable" RCON don't expose port 27015, i.e. start the server without `-p 27015:27015/tcp`. RCON is still running, but nobody can to connect to it.
|
||||
|
||||
|
||||
## Whitelisting (0.15.3+)
|
||||
### Whitelisting (0.15.3+)
|
||||
|
||||
Create file `config/server-whitelist.json` and add the whitelisted users.
|
||||
|
||||
[
|
||||
"you",
|
||||
"friend"
|
||||
]
|
||||
```json
|
||||
[
|
||||
"you",
|
||||
"friend"
|
||||
]
|
||||
```
|
||||
|
||||
## Banlisting (0.17.1+)
|
||||
### Banlisting (0.17.1+)
|
||||
|
||||
Create file `config/server-banlist.json` and add the banlisted users.
|
||||
|
||||
[
|
||||
"bad_person",
|
||||
"other_bad_person"
|
||||
]
|
||||
```json
|
||||
[
|
||||
"bad_person",
|
||||
"other_bad_person"
|
||||
]
|
||||
```
|
||||
|
||||
## Adminlisting (0.17.1+)
|
||||
### Adminlisting (0.17.1+)
|
||||
|
||||
Create file `config/server-adminlist.json` and add the adminlisted users.
|
||||
|
||||
[
|
||||
"you",
|
||||
"friend"
|
||||
]
|
||||
```json
|
||||
[
|
||||
"you",
|
||||
"friend"
|
||||
]
|
||||
```
|
||||
|
||||
## Customize configuration files (0.17.x+)
|
||||
### Customize configuration files (0.17.x+)
|
||||
|
||||
Out-of-the box, factorio does not support environment variables inside the configuration files. A workaround is the usage of `envsubst` which generates the configuration files dynamically during startup from environment variables set in docker-compose:
|
||||
|
||||
Example which replaces the server-settings.json:
|
||||
|
||||
|
||||
factorio_1:
|
||||
image: factoriotools/factorio
|
||||
ports:
|
||||
- "34197:34197/udp"
|
||||
volumes:
|
||||
- /opt/factorio:/factorio
|
||||
- ./server-settings.json:/server-settings.json
|
||||
environment:
|
||||
- INSTANCE_NAME=Your Instance's Name
|
||||
- INSTANCE_DESC=Your Instance's Description
|
||||
entrypoint: /bin/sh -c "mkdir -p /factorio/config && envsubst < /server-settings.json > /factorio/config/server-settings.json && exec /docker-entrypoint.sh"
|
||||
```yaml
|
||||
factorio_1:
|
||||
image: factoriotools/factorio
|
||||
ports:
|
||||
- "34197:34197/udp"
|
||||
volumes:
|
||||
- /opt/factorio:/factorio
|
||||
- ./server-settings.json:/server-settings.json
|
||||
environment:
|
||||
- INSTANCE_NAME=Your Instance's Name
|
||||
- INSTANCE_DESC=Your Instance's Description
|
||||
entrypoint: /bin/sh -c "mkdir -p /factorio/config && envsubst < /server-settings.json > /factorio/config/server-settings.json && exec /docker-entrypoint.sh"
|
||||
```
|
||||
|
||||
The `server-settings.json` file may then contain the variable references like this:
|
||||
|
||||
"name": "${INSTANCE_NAME}",
|
||||
"description": "${INSTANCE_DESC}",
|
||||
```json
|
||||
"name": "${INSTANCE_NAME}",
|
||||
"description": "${INSTANCE_DESC}",
|
||||
```
|
||||
|
||||
|
||||
# Container Details
|
||||
## Container Details
|
||||
|
||||
The philosophy is to [keep it simple](http://wiki.c2.com/?KeepItSimple).
|
||||
|
||||
@ -216,26 +254,27 @@ The philosophy is to [keep it simple](http://wiki.c2.com/?KeepItSimple).
|
||||
* Prefer configuration files over environment variables.
|
||||
* Use one volume for data.
|
||||
|
||||
|
||||
## Volumes
|
||||
### Volumes
|
||||
|
||||
To keep things simple, the container uses a single volume mounted at `/factorio`. This volume stores configuration, mods, and saves.
|
||||
|
||||
The files in this volume should be owned by the factorio user, uid 845.
|
||||
|
||||
factorio
|
||||
|-- config
|
||||
| |-- map-gen-settings.json
|
||||
| |-- map-settings.json
|
||||
| |-- rconpw
|
||||
| |-- server-adminlist.json
|
||||
| |-- server-banlist.json
|
||||
| |-- server-settings.json
|
||||
| `-- server-whitelist.json
|
||||
|-- mods
|
||||
| `-- fancymod.zip
|
||||
`-- saves
|
||||
`-- _autosave1.zip
|
||||
```text
|
||||
factorio
|
||||
|-- config
|
||||
| |-- map-gen-settings.json
|
||||
| |-- map-settings.json
|
||||
| |-- rconpw
|
||||
| |-- server-adminlist.json
|
||||
| |-- server-banlist.json
|
||||
| |-- server-settings.json
|
||||
| `-- server-whitelist.json
|
||||
|-- mods
|
||||
| `-- fancymod.zip
|
||||
`-- saves
|
||||
`-- _autosave1.zip
|
||||
```
|
||||
|
||||
## Docker Compose
|
||||
|
||||
@ -243,14 +282,14 @@ The files in this volume should be owned by the factorio user, uid 845.
|
||||
|
||||
First get a [docker-compose.yml](https://github.com/factoriotools/factorio-docker/blob/master/0.17/docker-compose.yml) file. To get it from this repository:
|
||||
|
||||
```
|
||||
```shell
|
||||
git clone https://github.com/factoriotools/factorio-docker.git
|
||||
cd docker_factorio_server/0.17
|
||||
```
|
||||
|
||||
Or make your own:
|
||||
|
||||
```
|
||||
```shell
|
||||
version: '2'
|
||||
services:
|
||||
factorio:
|
||||
@ -264,30 +303,22 @@ services:
|
||||
|
||||
Now cd to the directory with docker-compose.yml and run:
|
||||
|
||||
```
|
||||
```shell
|
||||
sudo mkdir -p /opt/factorio
|
||||
sudo chown 845:845 /opt/factorio
|
||||
sudo docker-compose up -d
|
||||
```
|
||||
|
||||
|
||||
## Ports
|
||||
### Ports
|
||||
|
||||
* `34197/udp` - Game server (required).
|
||||
* `27015/tcp` - RCON (optional).
|
||||
|
||||
|
||||
## Environment Variables
|
||||
|
||||
* `PORT` (0.15+) - Start the server on an alternate port, .e.g. `docker run -e "PORT=34198"`.
|
||||
* `RCON_PORT` (0.16+) - Start the RCON on an alternate port, .e.g. `docker run -e "RCON_PORT=34198"`.
|
||||
|
||||
|
||||
## LAN Games
|
||||
|
||||
Ensure the `lan` setting in server-settings.json is `true`.
|
||||
|
||||
```
|
||||
```shell
|
||||
"visibility":
|
||||
{
|
||||
"public": false,
|
||||
@ -297,7 +328,7 @@ Ensure the `lan` setting in server-settings.json is `true`.
|
||||
|
||||
Start the container with the `--network=host` option so clients can automatically find LAN games. Refer to the Quick Start to create the `/opt/factorio` directory.
|
||||
|
||||
```
|
||||
```shell
|
||||
sudo docker run -d \
|
||||
--network=host \
|
||||
-p 34197:34197/udp \
|
||||
@ -308,24 +339,26 @@ sudo docker run -d \
|
||||
factoriotools/factorio
|
||||
```
|
||||
|
||||
## Vagrant
|
||||
## Deploy to other plaforms
|
||||
|
||||
### Vagrant
|
||||
|
||||
[Vagrant](https://www.vagrantup.com/) is a easy way to setup a virtual machine (VM) to run Docker. The [Factorio Vagrant box repository](https://github.com/dtandersen/factorio-lan-vagrant) contains a sample Vagrantfile.
|
||||
|
||||
For LAN games the VM needs an internal IP in order for clients to connect. One way to do this is with a public network. The VM uses DHCP to acquire an IP address. The VM must also forward port 34197.
|
||||
|
||||
```
|
||||
```ruby
|
||||
config.vm.network "public_network"
|
||||
config.vm.network "forwarded_port", guest: 34197, host: 34197
|
||||
```
|
||||
|
||||
## Amazon Web Services (AWS) Deployment
|
||||
### Amazon Web Services (AWS) Deployment
|
||||
|
||||
If you're looking for a simple way to deploy this to the Amazon Web Services Cloud, check out the [Factorio Server Deployment (CloudFormation) repository](https://github.com/m-chandler/factorio-spot-pricing). This repository contains a CloudFormation template that will get you up and running in AWS in a matter of minutes. Optionally it uses Spot Pricing so the server is very cheap, and you can easily turn it off when not in use.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**My server is listed in the server browser, but nobody can connect**
|
||||
### My server is listed in the server browser, but nobody can connect
|
||||
|
||||
Check the logs. If there is the line `Own address is RIGHT IP:WRONG PORT`, then this could be caused by the Docker proxy. If the the IP and port is correct it's probably a port forwarding or firewall issue instead.
|
||||
|
||||
@ -333,16 +366,15 @@ By default, Docker routes traffic through a proxy. The proxy changes the source
|
||||
|
||||
To fix the incorrect port, start the Docker service with the `--userland-proxy=false` switch. Docker will route traffic with iptables rules instead of a proxy. Add the switch to the `DOCKER_OPTS` environment variable or `ExecStart` in the Docker systemd service definition. The specifics vary by operating system.
|
||||
|
||||
**When I run a server on a port besides 34197 nobody can connect from the server browser**
|
||||
### When I run a server on a port besides 34197 nobody can connect from the server browser
|
||||
|
||||
Use the `PORT` environment variable to start the server on the a different port, .e.g. `docker run -e "PORT=34198"`. This changes the source port on the packets used for port detection. `-p 34198:34197` works fine for private servers, but the server browser detects the wrong port.
|
||||
|
||||
|
||||
# Contributors
|
||||
## Contributors
|
||||
|
||||
* [dtandersen](https://github.com/dtandersen) - Maintainer
|
||||
* [Fank](https://github.com/Fankserver) - Keeper of the Factorio watchdog that keeps the version up-to-date.
|
||||
* [SuperSandro2000](https://github.com/supersandro2000) - CI Guy, Maintainer and runner of the Factorio watchdog, contributed version updates
|
||||
* [Fank](https://github.com/Fankserver) - Programmer of the Factorio watchdog that keeps the version up-to-date.
|
||||
* [SuperSandro2000](https://github.com/supersandro2000) - CI Guy, Maintainer and runner of the Factorio watchdog. Contributed version updates and wrote the Travis scripts.
|
||||
* [DBendit](https://github.com/DBendit/docker_factorio_server) - Coded admin list, ban list support and contributed version updates
|
||||
* [Zopanix](https://github.com/zopanix/docker_factorio_server) - Original Author
|
||||
* [Rfvgyhn](https://github.com/Rfvgyhn/docker-factorio) - Coded randomly generated RCON password
|
||||
|
72
build.sh
72
build.sh
@ -2,9 +2,9 @@
|
||||
set -eoux pipefail
|
||||
|
||||
if [[ -z ${1:-} ]] && [[ -n ${CI:-} ]]; then
|
||||
echo "Usage: ./build.sh \$VERSION_SHORT"
|
||||
echo 'Usage: ./build.sh VERSION_SHORT'
|
||||
exit 1
|
||||
elif [[ $CI == true ]]; then
|
||||
elif [[ ${CI:-} == true ]] || [[ -n ${1:-} ]]; then
|
||||
VERSION_SHORT="$1"
|
||||
else
|
||||
VERSION_SHORT=$(find . -maxdepth 1 -type d | sort | tail -1 | grep -o "[[0-9]].[[0-9]]*")
|
||||
@ -16,61 +16,81 @@ cd "$VERSION_SHORT" || exit 1
|
||||
VERSION=$(grep -oP '[0-9]+\.[0-9]+\.[0-9]+' Dockerfile | head -1)
|
||||
DOCKER_REPO=factoriotools/factorio
|
||||
|
||||
if [[ $TRAVIS_PULL_REQUEST == true ]]; then
|
||||
if [[ ${TRAVIS_PULL_REQUEST:-} == true ]]; then
|
||||
TAGS="$DOCKER_REPO:$TRAVIS_PULL_REQUEST_SLUG"
|
||||
else
|
||||
# we are either on master or on a tag build
|
||||
if [[ $TRAVIS_BRANCH == master ]] || [[ $TRAVIS_BRANCH == "$VERSION" ]]; then
|
||||
TAGS="$DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
|
||||
# we are on an incremental build of a tag
|
||||
elif [[ $VERSION == "${TRAVIS_BRANCH%-*}" ]]; then
|
||||
TAGS="$DOCKER_REPO:$TRAVIS_BRANCH -t $DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
|
||||
# we build a other branch than master
|
||||
elif [[ -n $TRAVIS_BRANCH ]]; then
|
||||
TAGS="$DOCKER_REPO:$TRAVIS_BRANCH"
|
||||
# we are not in CI and tag version and version short
|
||||
elif [[ $CI == "" ]]; then
|
||||
TAGS="$DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
|
||||
if [[ -n ${CI:-} ]]; then
|
||||
# we are either on master or on a tag build
|
||||
if [[ $TRAVIS_BRANCH == master ]] || [[ $TRAVIS_BRANCH == "$VERSION" ]]; then
|
||||
TAGS="-t $DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
|
||||
# we are on an incremental build of a tag
|
||||
elif [[ $VERSION == "${TRAVIS_BRANCH%-*}" ]]; then
|
||||
TAGS="-t $DOCKER_REPO:$TRAVIS_BRANCH -t $DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
|
||||
# we build a other branch than master
|
||||
elif [[ -n $TRAVIS_BRANCH ]]; then
|
||||
TAGS="-t $DOCKER_REPO:$TRAVIS_BRANCH"
|
||||
fi
|
||||
else
|
||||
# we are not in CI and tag version and version short
|
||||
TAGS="-t $DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
|
||||
fi
|
||||
|
||||
if [[ -n ${EXTRA_TAG:-} ]]; then
|
||||
TAGS="$TAGS -t $DOCKER_REPO:$EXTRA_TAG"
|
||||
IFS=","
|
||||
for TAG in $EXTRA_TAG; do
|
||||
TAGS+=" -t $DOCKER_REPO:$TAG"
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ ${STABLE:-} == "$VERSION" ]]; then
|
||||
TAGS+=" -t $DOCKER_REPO:stable"
|
||||
fi
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
docker build . -t $TAGS
|
||||
# shellcheck disable=SC2068
|
||||
eval docker build . ${TAGS[@]}
|
||||
docker images
|
||||
|
||||
if [[ ${TRAVIS_BRANCH:-} ]]; then
|
||||
TRAVIS_BRANCH_VERSION=${TRAVIS_BRANCH%-*}
|
||||
fi
|
||||
|
||||
# only push when:
|
||||
# latest changes where made in the folder corosponding to the version we build, we are on master and don#t build a PR.
|
||||
if [[ $(dirname "$(git diff --name-only HEAD^)") =~ $VERSION_SHORT ]] && [[ $TRAVIS_BRANCH == master ]] && [[ $TRAVIS_PULL_REQUEST_BRANCH == "" ]] ||
|
||||
if [[ $(dirname "$(git diff --name-only HEAD^)") =~ $VERSION_SHORT ]] && [[ ${TRAVIS_BRANCH:-} == master ]] && [[ $TRAVIS_PULL_REQUEST_BRANCH == "" ]] ||
|
||||
# we build a tag and we are not on master
|
||||
[[ $VERSION == "${TRAVIS_BRANCH%-*}" ]] && [[ $TRAVIS_PULL_REQUEST_BRANCH == "" ]] ||
|
||||
[[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" ]] && [[ ${TRAVIS_PULL_REQUEST_BRANCH:-} == "" ]] ||
|
||||
# we are not in CI
|
||||
[[ $CI == "" ]]; then
|
||||
[[ -z ${CI:-} ]]; then
|
||||
|
||||
if [[ $CI == true ]]; then
|
||||
if [[ ${CI:-} == true ]]; then
|
||||
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
||||
fi
|
||||
|
||||
# push a tag on a branch other than master
|
||||
if [[ -n $TRAVIS_BRANCH ]] && [[ $VERSION != "${TRAVIS_BRANCH%-*}" ]] && [[ $TRAVIS_BRANCH != "master" ]]; then
|
||||
if [[ -n ${TRAVIS_BRANCH:-} ]] && [[ $VERSION != "${TRAVIS_BRANCH_VERSION:-}" ]] && [[ ${TRAVIS_BRANCH:-} != "master" ]]; then
|
||||
docker push "$DOCKER_REPO:$TRAVIS_BRANCH"
|
||||
fi
|
||||
|
||||
# push an incremental tag
|
||||
if [[ $VERSION == "${TRAVIS_BRANCH%-*}" ]]; then
|
||||
if [[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" ]]; then
|
||||
docker push "$DOCKER_REPO:$TRAVIS_BRANCH"
|
||||
fi
|
||||
|
||||
if [[ -n $TRAVIS_TAG ]] || [[ $CI == "" ]]; then
|
||||
if [[ -n ${TRAVIS_TAG:-} ]] || [[ -z ${CI:-} ]]; then
|
||||
docker push "$DOCKER_REPO:$VERSION"
|
||||
docker push "$DOCKER_REPO:$VERSION_SHORT"
|
||||
fi
|
||||
|
||||
if [[ -n ${EXTRA_TAG:-} ]]; then
|
||||
docker push "$DOCKER_REPO:$EXTRA_TAG"
|
||||
IFS=","
|
||||
for TAG in $EXTRA_TAG; do
|
||||
docker push "$DOCKER_REPO:$TAG"
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ ${STABLE:-} == "$VERSION" ]]; then
|
||||
docker push "$DOCKER_REPO:stable"
|
||||
fi
|
||||
|
||||
curl -X POST https://hooks.microbadger.com/images/factoriotools/factorio/TmmKGNp8jKcFqZvcJhTCIAJVluw=
|
||||
|
Reference in New Issue
Block a user