mirror of
https://github.com/factoriotools/factorio-docker.git
synced 2025-07-01 14:38:05 +02:00
Compare commits
59 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
9f8f6da0d2 | |||
71c75671d5 | |||
5a66d1a8df | |||
a48b9d107d | |||
e5f34134f7 | |||
5d997bf1c7 | |||
7a08cbb04c | |||
40cc26ca02 | |||
e8705a44b8 | |||
fe9875343f | |||
06729a6097 | |||
95766e90c9 | |||
4afbed52c8 | |||
fd7b8cd839 | |||
9c92ac9342 | |||
1b6c8adf28 | |||
65c5833fd9 | |||
c949351391 | |||
6ae5795d38 | |||
29ee60236e | |||
7028eb72f6 | |||
dfeb95d614 | |||
f8c62978ee | |||
28598a42a3 | |||
4ba56ee010 | |||
d2a02e8a66 | |||
5b24f8ac74 |
@ -16,11 +16,11 @@ jobs:
|
||||
- bash -c 'shopt -s globstar; shellcheck **/*.sh'
|
||||
- &build
|
||||
stage: build
|
||||
env: VERSION_SHORT=0.17 EXTRA_TAG=latest
|
||||
env: VERSION_SHORT=0.17 EXTRA_TAG=latest,stable
|
||||
script:
|
||||
- ./build.sh $VERSION_SHORT
|
||||
- <<: *build
|
||||
env: VERSION_SHORT=0.16 EXTRA_TAG=stable
|
||||
env: VERSION_SHORT=0.16
|
||||
- <<: *build
|
||||
env: VERSION_SHORT=0.15
|
||||
- <<: *build
|
||||
|
@ -5,16 +5,16 @@ LABEL maintainer="https://github.com/factoriotools/factorio-docker"
|
||||
ENV VERSION=0.14.23 \
|
||||
SHA1=6ef84341c6fc1cf45cfdd6acc8468aaa117b9e8a
|
||||
|
||||
RUN mkdir -p /opt && \
|
||||
apk --no-cache add curl tini pwgen && \
|
||||
curl -sSL 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 del curl && \
|
||||
ln -s /factorio/saves /opt/factorio/saves && \
|
||||
ln -s /factorio/mods /opt/factorio/mods
|
||||
RUN mkdir -p /opt \
|
||||
&& apk --no-cache add curl tini pwgen \
|
||||
&& curl -sSL 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 del curl \
|
||||
&& ln -s /factorio/saves /opt/factorio/saves \
|
||||
&& ln -s /factorio/mods /opt/factorio/mods
|
||||
|
||||
VOLUME /factorio
|
||||
|
||||
|
@ -7,18 +7,18 @@ ENV PORT=34197 \
|
||||
VERSION=0.15.40 \
|
||||
SHA1=f79a975f6b8c0ee87e2fa60f7d1f7133f332c3ec
|
||||
|
||||
RUN mkdir -p /opt && \
|
||||
apk add --update --no-cache tini pwgen && \
|
||||
apk add --update --no-cache --virtual .build-deps curl && \
|
||||
curl -sSL https://www.factorio.com/get-download/$VERSION/headless/linux64 \
|
||||
-o /tmp/factorio_headless_x64_$VERSION.tar.xz && \
|
||||
echo "$SHA1 /tmp/factorio_headless_x64_$VERSION.tar.xz" | sha1sum -c && \
|
||||
tar xf /tmp/factorio_headless_x64_$VERSION.tar.xz --directory /opt && \
|
||||
chmod -R 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 && \
|
||||
apk del .build-deps
|
||||
RUN mkdir -p /opt \
|
||||
&& apk add --update --no-cache tini pwgen \
|
||||
&& apk add --update --no-cache --virtual .build-deps curl \
|
||||
&& curl -sSL https://www.factorio.com/get-download/$VERSION/headless/linux64 \
|
||||
-o /tmp/factorio_headless_x64_$VERSION.tar.xz \
|
||||
&& echo "$SHA1 /tmp/factorio_headless_x64_$VERSION.tar.xz" | sha1sum -c \
|
||||
&& tar xf /tmp/factorio_headless_x64_$VERSION.tar.xz --directory /opt \
|
||||
&& chmod -R 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 \
|
||||
&& apk del .build-deps
|
||||
|
||||
VOLUME /factorio
|
||||
|
||||
|
@ -19,23 +19,23 @@ ENV PORT=34197 \
|
||||
PUID="$PUID" \
|
||||
PGID="$PGID"
|
||||
|
||||
RUN mkdir -p /opt /factorio && \
|
||||
apk add --update --no-cache pwgen su-exec shadow && \
|
||||
apk add --update --no-cache --virtual .build-deps curl && \
|
||||
curl -sSL https://www.factorio.com/get-download/$VERSION/headless/linux64 \
|
||||
-o /tmp/factorio_headless_x64_$VERSION.tar.xz && \
|
||||
echo "$SHA1 /tmp/factorio_headless_x64_$VERSION.tar.xz" | sha1sum -c && \
|
||||
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 $SAVES /opt/factorio/saves && \
|
||||
ln -s $MODS /opt/factorio/mods && \
|
||||
ln -s $SCENARIOS /opt/factorio/scenarios && \
|
||||
ln -s $SCRIPTOUTPUT /opt/factorio/script-output && \
|
||||
apk del .build-deps && \
|
||||
addgroup -g $PGID -S $GROUP && \
|
||||
adduser -u $PUID -G $GROUP -s /bin/sh -SDH $USER && \
|
||||
chown -R $USER:$GROUP /opt/factorio /factorio
|
||||
RUN mkdir -p /opt /factorio \
|
||||
&& apk add --update --no-cache pwgen su-exec shadow \
|
||||
&& apk add --update --no-cache --virtual .build-deps curl \
|
||||
&& curl -sSL https://www.factorio.com/get-download/$VERSION/headless/linux64 \
|
||||
-o /tmp/factorio_headless_x64_$VERSION.tar.xz \
|
||||
&& echo "$SHA1 /tmp/factorio_headless_x64_$VERSION.tar.xz" | sha1sum -c \
|
||||
&& 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 $SAVES /opt/factorio/saves \
|
||||
&& ln -s $MODS /opt/factorio/mods \
|
||||
&& ln -s $SCENARIOS /opt/factorio/scenarios \
|
||||
&& ln -s $SCRIPTOUTPUT /opt/factorio/script-output \
|
||||
&& apk del .build-deps \
|
||||
&& addgroup -g $PGID -S $GROUP \
|
||||
&& adduser -u $PUID -G $GROUP -s /bin/sh -SDH $USER \
|
||||
&& chown -R $USER:$GROUP /opt/factorio /factorio
|
||||
|
||||
VOLUME /factorio
|
||||
|
||||
|
@ -9,8 +9,8 @@ ARG PGID=845
|
||||
|
||||
ENV PORT=34197 \
|
||||
RCON_PORT=27015 \
|
||||
VERSION=0.17.52 \
|
||||
SHA1=f3f12d1cf2f44b1df144bf46d01af070d47f0d5a \
|
||||
VERSION=0.17.74 \
|
||||
SHA1=ed275564687e91bed3a969ddf8907560c9cfe431 \
|
||||
SAVES=/factorio/saves \
|
||||
CONFIG=/factorio/config \
|
||||
MODS=/factorio/mods \
|
||||
@ -19,23 +19,23 @@ ENV PORT=34197 \
|
||||
PUID="$PUID" \
|
||||
PGID="$PGID"
|
||||
|
||||
RUN mkdir -p /opt /factorio && \
|
||||
apk add --update --no-cache pwgen su-exec binutils gettext libintl shadow && \
|
||||
apk add --update --no-cache --virtual .build-deps curl && \
|
||||
curl -sSL "https://www.factorio.com/get-download/$VERSION/headless/linux64" \
|
||||
-o /tmp/factorio_headless_x64_$VERSION.tar.xz && \
|
||||
echo "$SHA1 /tmp/factorio_headless_x64_$VERSION.tar.xz" | sha1sum -c && \
|
||||
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 "$SAVES" /opt/factorio/saves && \
|
||||
ln -s "$MODS" /opt/factorio/mods && \
|
||||
ln -s "$SCENARIOS" /opt/factorio/scenarios && \
|
||||
ln -s "$SCRIPTOUTPUT" /opt/factorio/script-output && \
|
||||
apk del .build-deps && \
|
||||
addgroup -g "$PGID" -S "$GROUP" && \
|
||||
adduser -u "$PUID" -G "$GROUP" -s /bin/sh -SDH "$USER" && \
|
||||
chown -R "$USER":"$GROUP" /opt/factorio /factorio
|
||||
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
|
||||
|
||||
|
@ -10,3 +10,6 @@ services:
|
||||
# environment:
|
||||
# - PUID=1000
|
||||
# - PGID=1000
|
||||
# - UPDATE_MODS_ON_START=true
|
||||
# - USERNAME=FactorioUsername
|
||||
# - TOKEN=FactorioToken
|
||||
|
@ -1,7 +1,5 @@
|
||||
#!/bin/sh -x
|
||||
set -euo pipefail
|
||||
|
||||
id
|
||||
#!/bin/bash
|
||||
set -eoux pipefail
|
||||
|
||||
FACTORIO_VOL=/factorio
|
||||
mkdir -p "$FACTORIO_VOL"
|
||||
@ -11,31 +9,35 @@ mkdir -p "$MODS"
|
||||
mkdir -p "$SCENARIOS"
|
||||
mkdir -p "$SCRIPTOUTPUT"
|
||||
|
||||
if [ ! -f "$CONFIG/rconpw" ]; then
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
if [[ $NRTMPSAVES -gt 0 ]]; then
|
||||
# Delete incomplete saves (such as after a forced exit)
|
||||
rm -f "$SAVES"/*.tmp.zip
|
||||
fi
|
||||
|
||||
if [ "$(id -u)" = '0' ]; then
|
||||
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
|
||||
@ -47,8 +49,8 @@ else
|
||||
SU_EXEC=""
|
||||
fi
|
||||
|
||||
NRSAVES=$( find -L "$SAVES" -iname \*.zip -mindepth 1 | wc -l )
|
||||
if [ "$NRSAVES" -eq 0 ]; then
|
||||
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" \
|
||||
|
28
0.17/files/docker-update-mods.sh
Executable file
28
0.17/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"
|
@ -1,13 +1,11 @@
|
||||
#!/bin/sh -x
|
||||
if [ -z "$1" ]; then
|
||||
#!/bin/bash
|
||||
set -eoux pipefail
|
||||
|
||||
if [[ -z ${1:-} ]]; then
|
||||
echo "No argument supplied"
|
||||
fi
|
||||
|
||||
SERVER_SCENARIO="$1"
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
id
|
||||
|
||||
mkdir -p "$SAVES"
|
||||
mkdir -p "$CONFIG"
|
||||
mkdir -p "$MODS"
|
||||
@ -15,19 +13,19 @@ mkdir -p "$SCENARIOS"
|
||||
|
||||
#chown -R factorio /factorio
|
||||
|
||||
if [ ! -f "$CONFIG/rconpw" ]; then
|
||||
if [[ ! -f $CONFIG/rconpw ]]; then
|
||||
pwgen 15 1 >"$CONFIG/rconpw"
|
||||
fi
|
||||
|
||||
if [ ! -f "$CONFIG/server-settings.json" ]; then
|
||||
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
|
||||
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
|
||||
if [[ ! -f $CONFIG/map-settings.json ]]; then
|
||||
cp /opt/factorio/data/map-settings.example.json "$CONFIG/map-settings.json"
|
||||
fi
|
||||
|
||||
@ -35,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
|
||||
|
@ -1,27 +1,25 @@
|
||||
#!/bin/sh -x
|
||||
if [ -z "$1" ]; then
|
||||
#!/bin/bash
|
||||
set -eoux pipefail
|
||||
|
||||
if [[ -z ${1:-} ]]; then
|
||||
echo "No argument supplied"
|
||||
fi
|
||||
|
||||
SERVER_SCENARIO="$1"
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
id
|
||||
|
||||
mkdir -p "$SAVES"
|
||||
mkdir -p "$CONFIG"
|
||||
mkdir -p "$MODS"
|
||||
mkdir -p "$SCENARIOS"
|
||||
|
||||
if [ ! -f "$CONFIG/server-settings.json" ]; then
|
||||
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
|
||||
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
|
||||
if [[ ! -f $CONFIG/map-settings.json ]]; then
|
||||
cp /opt/factorio/data/map-settings.example.json "$CONFIG/map-settings.json"
|
||||
fi
|
||||
|
||||
|
94
0.17/files/update-mods.sh
Executable file
94
0.17/files/update-mods.sh
Executable file
@ -0,0 +1,94 @@
|
||||
#!/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")
|
||||
|
||||
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
|
||||
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 "$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 "$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 "$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
|
32
README.md
32
README.md
@ -1,7 +1,8 @@
|
||||
# Factorio [](https://travis-ci.org/factoriotools/factorio-docker) [](https://microbadger.com/images/factoriotools/factorio) [](https://microbadger.com/images/factoriotools/factorio "Get your own image badge on microbadger.com") [](https://hub.docker.com/r/factoriotools/factorio/) [](https://hub.docker.com/r/factoriotools/factorio/)
|
||||
# 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.52`, `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.17.74`, `0.17`, `latest` [(0.17/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.17/Dockerfile)
|
||||
* `0.17.74` `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)
|
||||
|
||||
@ -9,9 +10,9 @@
|
||||
|
||||
* `latest` - most up-to-date version (may be experimental).
|
||||
* `stable` - version declared stable on [factorio.com](https://www.factorio.com).
|
||||
* `0.x` - latest version in a branch.
|
||||
* `0.x` - latest version in a branch.
|
||||
* `0.x.y` - a specific version.
|
||||
* `0.x-dev` - whatever is in master for that version.
|
||||
* `0.x-z` - incremental fix for that version.
|
||||
|
||||
|
||||
# What is Factorio?
|
||||
@ -22,7 +23,7 @@ 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
|
||||
@ -112,6 +113,8 @@ 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.
|
||||
|
||||
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
|
||||
|
||||
@ -339,11 +342,12 @@ Use the `PORT` environment variable to start the server on the a different port,
|
||||
# Contributors
|
||||
|
||||
* [dtandersen](https://github.com/dtandersen) - Maintainer
|
||||
* [Fank](https://github.com/Fankserver/docker-factorio-watchdog) - Keeper of the Factorio watchdog that keeps the version up-to-date.
|
||||
* [SuperSandro2000](https://github.com/supersandro2000) - CI Guy
|
||||
* [DBendit](https://github.com/DBendit/docker_factorio_server) - Admin list, ban list, version updates
|
||||
* [Zopanix](https://github.com/zopanix/docker_factorio_server) - Originator
|
||||
* [Rfvgyhn](https://github.com/Rfvgyhn/docker-factorio) - Randomly generate RCON password
|
||||
* [gnomus](https://github.com/gnomus/docker_factorio_server) - White listing
|
||||
* [bplein](https://github.com/bplein/docker_factorio_server) - Scenario support
|
||||
* [jaredledvina](https://github.com/jaredledvina/docker_factorio_server) - Version update
|
||||
* [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
|
||||
* [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
|
||||
* [gnomus](https://github.com/gnomus/docker_factorio_server) - Coded wite listing support
|
||||
* [bplein](https://github.com/bplein/docker_factorio_server) - Coded scenario support
|
||||
* [jaredledvina](https://github.com/jaredledvina/docker_factorio_server) - Contributed version updates
|
||||
* [carlbennett](https://github.com/carlbennett) - Contributed version updates and bugfixes
|
||||
|
80
build.sh
80
build.sh
@ -1,58 +1,88 @@
|
||||
#!/bin/bash
|
||||
set -eox pipefail
|
||||
set -eoux pipefail
|
||||
|
||||
if [ -z "$1" ] && [ -n "$CI" ]; then
|
||||
echo "Usage: ./build.sh \$VERSION_SHORT"
|
||||
if [[ -z ${1:-} ]] && [[ -n ${CI:-} ]]; then
|
||||
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]*")
|
||||
VERSION_SHORT=$(find . -maxdepth 1 -type d | sort | tail -1 | grep -o "[[0-9]].[[0-9]]*")
|
||||
EXTRA_TAG=latest
|
||||
fi
|
||||
|
||||
cd "$VERSION_SHORT" || exit
|
||||
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
|
||||
if [ "$TRAVIS_BRANCH" == "master" ] || [ "$TRAVIS_BRANCH" == "$VERSION" ]; then
|
||||
TAGS="$DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
|
||||
elif [ -n "$TRAVIS_BRANCH" ]; then
|
||||
TAGS="$DOCKER_REPO:$TRAVIS_BRANCH"
|
||||
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"
|
||||
if [[ -n ${EXTRA_TAG:-} ]]; then
|
||||
IFS=","
|
||||
for TAG in $EXTRA_TAG; do
|
||||
TAGS+=" -t $DOCKER_REPO:$TAG"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
docker build . -t $TAGS
|
||||
# shellcheck disable=SC2068
|
||||
eval docker build . ${TAGS[@]}
|
||||
docker images
|
||||
|
||||
if [[ "$(dirname "$(git diff --name-only HEAD^)")" =~ $VERSION_SHORT ]] && [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST_BRANCH" == "" ] ||
|
||||
[ "$TRAVIS_BRANCH" == "$VERSION" ] && [ "$TRAVIS_PULL_REQUEST_BRANCH" == "" ] ||
|
||||
[ "$CI" == "" ]; then
|
||||
if [[ ${TRAVIS_BRANCH:-} ]]; then
|
||||
TRAVIS_BRANCH_VERSION=${TRAVIS_BRANCH%-*}
|
||||
fi
|
||||
|
||||
if [ "$CI" == "true" ]; then
|
||||
# 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 == "" ]] ||
|
||||
# we build a tag and we are not on master
|
||||
[[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" ]] && [[ ${TRAVIS_PULL_REQUEST_BRANCH:-} == "" ]] ||
|
||||
# we are not in CI
|
||||
[[ -z ${CI:-} ]]; then
|
||||
|
||||
if [[ ${CI:-} == true ]]; then
|
||||
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
||||
fi
|
||||
|
||||
if [ -n "$TRAVIS_BRANCH" ] && [ "$TRAVIS_BRANCH" != "$VERSION" ] && [ "$TRAVIS_BRANCH" != "master" ]; then
|
||||
# push a tag on a branch other than master
|
||||
if [[ -n ${TRAVIS_BRANCH:-} ]] && [[ $VERSION != "${TRAVIS_BRANCH_VERSION:-}" ]] && [[ ${TRAVIS_BRANCH:-} != "master" ]]; then
|
||||
docker push "$DOCKER_REPO:$TRAVIS_BRANCH"
|
||||
fi
|
||||
if [ -n "$TRAVIS_TAG" ] || [ "$CI" == "" ]; then
|
||||
|
||||
# push an incremental tag
|
||||
if [[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" ]]; then
|
||||
docker push "$DOCKER_REPO:$TRAVIS_BRANCH"
|
||||
fi
|
||||
|
||||
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"
|
||||
|
||||
if [[ -n ${EXTRA_TAG:-} ]]; then
|
||||
IFS=","
|
||||
for TAG in $EXTRA_TAG; do
|
||||
docker push "$DOCKER_REPO:$TAG"
|
||||
done
|
||||
fi
|
||||
|
||||
curl -X POST https://hooks.microbadger.com/images/factoriotools/factorio/TmmKGNp8jKcFqZvcJhTCIAJVluw=
|
||||
|
Reference in New Issue
Block a user