mirror of
https://github.com/factoriotools/factorio-docker.git
synced 2025-07-01 14:38:05 +02:00
Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 |
@ -5,16 +5,16 @@ LABEL maintainer="https://github.com/factoriotools/factorio-docker"
|
|||||||
ENV VERSION=0.14.23 \
|
ENV VERSION=0.14.23 \
|
||||||
SHA1=6ef84341c6fc1cf45cfdd6acc8468aaa117b9e8a
|
SHA1=6ef84341c6fc1cf45cfdd6acc8468aaa117b9e8a
|
||||||
|
|
||||||
RUN mkdir -p /opt && \
|
RUN mkdir -p /opt \
|
||||||
apk --no-cache add curl tini pwgen && \
|
&& apk --no-cache add curl tini pwgen \
|
||||||
curl -sSL https://www.factorio.com/get-download/$VERSION/headless/linux64 \
|
&& curl -sSL https://www.factorio.com/get-download/$VERSION/headless/linux64 \
|
||||||
-o /tmp/factorio_headless_x64_$VERSION.tar.gz && \
|
-o /tmp/factorio_headless_x64_$VERSION.tar.gz \
|
||||||
echo "$SHA1 /tmp/factorio_headless_x64_$VERSION.tar.gz" | sha1sum -c && \
|
&& echo "$SHA1 /tmp/factorio_headless_x64_$VERSION.tar.gz" | sha1sum -c \
|
||||||
tar xzf /tmp/factorio_headless_x64_$VERSION.tar.gz --directory /opt && \
|
&& tar xzf /tmp/factorio_headless_x64_$VERSION.tar.gz --directory /opt \
|
||||||
rm /tmp/factorio_headless_x64_$VERSION.tar.gz && \
|
&& rm /tmp/factorio_headless_x64_$VERSION.tar.gz \
|
||||||
apk del curl && \
|
&& apk del curl \
|
||||||
ln -s /factorio/saves /opt/factorio/saves && \
|
&& ln -s /factorio/saves /opt/factorio/saves \
|
||||||
ln -s /factorio/mods /opt/factorio/mods
|
&& ln -s /factorio/mods /opt/factorio/mods
|
||||||
|
|
||||||
VOLUME /factorio
|
VOLUME /factorio
|
||||||
|
|
||||||
|
@ -7,18 +7,18 @@ ENV PORT=34197 \
|
|||||||
VERSION=0.15.40 \
|
VERSION=0.15.40 \
|
||||||
SHA1=f79a975f6b8c0ee87e2fa60f7d1f7133f332c3ec
|
SHA1=f79a975f6b8c0ee87e2fa60f7d1f7133f332c3ec
|
||||||
|
|
||||||
RUN mkdir -p /opt && \
|
RUN mkdir -p /opt \
|
||||||
apk add --update --no-cache tini pwgen && \
|
&& apk add --update --no-cache tini pwgen \
|
||||||
apk add --update --no-cache --virtual .build-deps curl && \
|
&& apk add --update --no-cache --virtual .build-deps curl \
|
||||||
curl -sSL https://www.factorio.com/get-download/$VERSION/headless/linux64 \
|
&& curl -sSL https://www.factorio.com/get-download/$VERSION/headless/linux64 \
|
||||||
-o /tmp/factorio_headless_x64_$VERSION.tar.xz && \
|
-o /tmp/factorio_headless_x64_$VERSION.tar.xz \
|
||||||
echo "$SHA1 /tmp/factorio_headless_x64_$VERSION.tar.xz" | sha1sum -c && \
|
&& echo "$SHA1 /tmp/factorio_headless_x64_$VERSION.tar.xz" | sha1sum -c \
|
||||||
tar xf /tmp/factorio_headless_x64_$VERSION.tar.xz --directory /opt && \
|
&& tar xf /tmp/factorio_headless_x64_$VERSION.tar.xz --directory /opt \
|
||||||
chmod -R ugo=rwx /opt/factorio && \
|
&& chmod -R ugo=rwx /opt/factorio \
|
||||||
rm /tmp/factorio_headless_x64_$VERSION.tar.xz && \
|
&& rm /tmp/factorio_headless_x64_$VERSION.tar.xz \
|
||||||
ln -s /factorio/saves /opt/factorio/saves && \
|
&& ln -s /factorio/saves /opt/factorio/saves \
|
||||||
ln -s /factorio/mods /opt/factorio/mods && \
|
&& ln -s /factorio/mods /opt/factorio/mods \
|
||||||
apk del .build-deps
|
&& apk del .build-deps
|
||||||
|
|
||||||
VOLUME /factorio
|
VOLUME /factorio
|
||||||
|
|
||||||
|
@ -19,23 +19,23 @@ ENV PORT=34197 \
|
|||||||
PUID="$PUID" \
|
PUID="$PUID" \
|
||||||
PGID="$PGID"
|
PGID="$PGID"
|
||||||
|
|
||||||
RUN mkdir -p /opt /factorio && \
|
RUN mkdir -p /opt /factorio \
|
||||||
apk add --update --no-cache pwgen su-exec shadow && \
|
&& apk add --update --no-cache pwgen su-exec shadow \
|
||||||
apk add --update --no-cache --virtual .build-deps curl && \
|
&& apk add --update --no-cache --virtual .build-deps curl \
|
||||||
curl -sSL https://www.factorio.com/get-download/$VERSION/headless/linux64 \
|
&& curl -sSL https://www.factorio.com/get-download/$VERSION/headless/linux64 \
|
||||||
-o /tmp/factorio_headless_x64_$VERSION.tar.xz && \
|
-o /tmp/factorio_headless_x64_$VERSION.tar.xz \
|
||||||
echo "$SHA1 /tmp/factorio_headless_x64_$VERSION.tar.xz" | sha1sum -c && \
|
&& echo "$SHA1 /tmp/factorio_headless_x64_$VERSION.tar.xz" | sha1sum -c \
|
||||||
tar xf /tmp/factorio_headless_x64_$VERSION.tar.xz --directory /opt && \
|
&& tar xf /tmp/factorio_headless_x64_$VERSION.tar.xz --directory /opt \
|
||||||
chmod ugo=rwx /opt/factorio && \
|
&& chmod ugo=rwx /opt/factorio \
|
||||||
rm /tmp/factorio_headless_x64_$VERSION.tar.xz && \
|
&& rm /tmp/factorio_headless_x64_$VERSION.tar.xz \
|
||||||
ln -s $SAVES /opt/factorio/saves && \
|
&& ln -s $SAVES /opt/factorio/saves \
|
||||||
ln -s $MODS /opt/factorio/mods && \
|
&& ln -s $MODS /opt/factorio/mods \
|
||||||
ln -s $SCENARIOS /opt/factorio/scenarios && \
|
&& ln -s $SCENARIOS /opt/factorio/scenarios \
|
||||||
ln -s $SCRIPTOUTPUT /opt/factorio/script-output && \
|
&& ln -s $SCRIPTOUTPUT /opt/factorio/script-output \
|
||||||
apk del .build-deps && \
|
&& apk del .build-deps \
|
||||||
addgroup -g $PGID -S $GROUP && \
|
&& addgroup -g $PGID -S $GROUP \
|
||||||
adduser -u $PUID -G $GROUP -s /bin/sh -SDH $USER && \
|
&& adduser -u $PUID -G $GROUP -s /bin/sh -SDH $USER \
|
||||||
chown -R $USER:$GROUP /opt/factorio /factorio
|
&& chown -R $USER:$GROUP /opt/factorio /factorio
|
||||||
|
|
||||||
VOLUME /factorio
|
VOLUME /factorio
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ ARG PGID=845
|
|||||||
|
|
||||||
ENV PORT=34197 \
|
ENV PORT=34197 \
|
||||||
RCON_PORT=27015 \
|
RCON_PORT=27015 \
|
||||||
VERSION=0.17.52 \
|
VERSION=0.17.58 \
|
||||||
SHA1=f3f12d1cf2f44b1df144bf46d01af070d47f0d5a \
|
SHA1=424cac80e559dcb86415a953317e8b91d729793e \
|
||||||
SAVES=/factorio/saves \
|
SAVES=/factorio/saves \
|
||||||
CONFIG=/factorio/config \
|
CONFIG=/factorio/config \
|
||||||
MODS=/factorio/mods \
|
MODS=/factorio/mods \
|
||||||
@ -19,23 +19,23 @@ ENV PORT=34197 \
|
|||||||
PUID="$PUID" \
|
PUID="$PUID" \
|
||||||
PGID="$PGID"
|
PGID="$PGID"
|
||||||
|
|
||||||
RUN mkdir -p /opt /factorio && \
|
RUN set -ox pipefail \
|
||||||
apk add --update --no-cache pwgen su-exec binutils gettext libintl shadow && \
|
&& archive="/tmp/factorio_headless_x64_$VERSION.tar.xz" \
|
||||||
apk add --update --no-cache --virtual .build-deps curl && \
|
&& mkdir -p /opt /factorio \
|
||||||
curl -sSL "https://www.factorio.com/get-download/$VERSION/headless/linux64" \
|
&& apk add --update --no-cache --no-progress bash binutils curl file gettext jq libintl pwgen shadow su-exec \
|
||||||
-o /tmp/factorio_headless_x64_$VERSION.tar.xz && \
|
&& curl -sSL "https://www.factorio.com/get-download/$VERSION/headless/linux64" -o "$archive" \
|
||||||
echo "$SHA1 /tmp/factorio_headless_x64_$VERSION.tar.xz" | sha1sum -c && \
|
&& echo "$SHA1 $archive" | sha1sum -c \
|
||||||
tar xf "/tmp/factorio_headless_x64_$VERSION.tar.xz" --directory /opt && \
|
|| (sha1sum "$archive" && file "$archive" && exit 1) \
|
||||||
chmod ugo=rwx /opt/factorio && \
|
&& tar xf "$archive" --directory /opt \
|
||||||
rm "/tmp/factorio_headless_x64_$VERSION.tar.xz" && \
|
&& chmod ugo=rwx /opt/factorio \
|
||||||
ln -s "$SAVES" /opt/factorio/saves && \
|
&& rm "$archive" \
|
||||||
ln -s "$MODS" /opt/factorio/mods && \
|
&& ln -s "$SAVES" /opt/factorio/saves \
|
||||||
ln -s "$SCENARIOS" /opt/factorio/scenarios && \
|
&& ln -s "$MODS" /opt/factorio/mods \
|
||||||
ln -s "$SCRIPTOUTPUT" /opt/factorio/script-output && \
|
&& ln -s "$SCENARIOS" /opt/factorio/scenarios \
|
||||||
apk del .build-deps && \
|
&& ln -s "$SCRIPTOUTPUT" /opt/factorio/script-output \
|
||||||
addgroup -g "$PGID" -S "$GROUP" && \
|
&& addgroup -g "$PGID" -S "$GROUP" \
|
||||||
adduser -u "$PUID" -G "$GROUP" -s /bin/sh -SDH "$USER" && \
|
&& adduser -u "$PUID" -G "$GROUP" -s /bin/sh -SDH "$USER" \
|
||||||
chown -R "$USER":"$GROUP" /opt/factorio /factorio
|
&& chown -R "$USER":"$GROUP" /opt/factorio /factorio
|
||||||
|
|
||||||
VOLUME /factorio
|
VOLUME /factorio
|
||||||
|
|
||||||
|
@ -10,3 +10,6 @@ services:
|
|||||||
# environment:
|
# environment:
|
||||||
# - PUID=1000
|
# - PUID=1000
|
||||||
# - PGID=1000
|
# - PGID=1000
|
||||||
|
# - UPDATE_MODS_ON_START=true
|
||||||
|
# - USERNAME=FactorioUsername
|
||||||
|
# - TOKEN=FactorioToken
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#!/bin/sh -x
|
#!/bin/bash
|
||||||
set -euo pipefail
|
set -eoux pipefail
|
||||||
|
|
||||||
id
|
|
||||||
|
|
||||||
FACTORIO_VOL=/factorio
|
FACTORIO_VOL=/factorio
|
||||||
mkdir -p "$FACTORIO_VOL"
|
mkdir -p "$FACTORIO_VOL"
|
||||||
@ -11,31 +9,35 @@ mkdir -p "$MODS"
|
|||||||
mkdir -p "$SCENARIOS"
|
mkdir -p "$SCENARIOS"
|
||||||
mkdir -p "$SCRIPTOUTPUT"
|
mkdir -p "$SCRIPTOUTPUT"
|
||||||
|
|
||||||
if [ ! -f "$CONFIG/rconpw" ]; then
|
if [[ ! -f $CONFIG/rconpw ]]; then
|
||||||
# Generate a new RCON password if none exists
|
# Generate a new RCON password if none exists
|
||||||
pwgen 15 1 >"$CONFIG/rconpw"
|
pwgen 15 1 >"$CONFIG/rconpw"
|
||||||
fi
|
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
|
# Copy default settings if server-settings.json doesn't exist
|
||||||
cp /opt/factorio/data/server-settings.example.json "$CONFIG/server-settings.json"
|
cp /opt/factorio/data/server-settings.example.json "$CONFIG/server-settings.json"
|
||||||
fi
|
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"
|
cp /opt/factorio/data/map-gen-settings.example.json "$CONFIG/map-gen-settings.json"
|
||||||
fi
|
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"
|
cp /opt/factorio/data/map-settings.example.json "$CONFIG/map-settings.json"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NRTMPSAVES=$( find -L "$SAVES" -iname \*.tmp.zip -mindepth 1 | wc -l )
|
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)
|
# Delete incomplete saves (such as after a forced exit)
|
||||||
rm -f "$SAVES"/*.tmp.zip
|
rm -f "$SAVES"/*.tmp.zip
|
||||||
fi
|
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
|
# Update the User and Group ID based on the PUID/PGID variables
|
||||||
usermod -o -u "$PUID" factorio
|
usermod -o -u "$PUID" factorio
|
||||||
groupmod -o -g "$PGID" factorio
|
groupmod -o -g "$PGID" factorio
|
||||||
@ -47,8 +49,8 @@ else
|
|||||||
SU_EXEC=""
|
SU_EXEC=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NRSAVES=$( find -L "$SAVES" -iname \*.zip -mindepth 1 | wc -l )
|
NRSAVES=$(find -L "$SAVES" -iname \*.zip -mindepth 1 | wc -l)
|
||||||
if [ "$NRSAVES" -eq 0 ]; then
|
if [[ $NRSAVES -eq 0 ]]; then
|
||||||
# Generate a new map if no save ZIPs exist
|
# Generate a new map if no save ZIPs exist
|
||||||
$SU_EXEC /opt/factorio/bin/x64/factorio \
|
$SU_EXEC /opt/factorio/bin/x64/factorio \
|
||||||
--create "$SAVES/_autosave1.zip" \
|
--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
|
#!/bin/bash
|
||||||
if [ -z "$1" ]; then
|
set -eoux pipefail
|
||||||
|
|
||||||
|
if [[ -z ${1:-} ]]; then
|
||||||
echo "No argument supplied"
|
echo "No argument supplied"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SERVER_SCENARIO="$1"
|
SERVER_SCENARIO="$1"
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
id
|
|
||||||
|
|
||||||
mkdir -p "$SAVES"
|
mkdir -p "$SAVES"
|
||||||
mkdir -p "$CONFIG"
|
mkdir -p "$CONFIG"
|
||||||
mkdir -p "$MODS"
|
mkdir -p "$MODS"
|
||||||
@ -15,19 +13,19 @@ mkdir -p "$SCENARIOS"
|
|||||||
|
|
||||||
#chown -R factorio /factorio
|
#chown -R factorio /factorio
|
||||||
|
|
||||||
if [ ! -f "$CONFIG/rconpw" ]; then
|
if [[ ! -f $CONFIG/rconpw ]]; then
|
||||||
pwgen 15 1 >"$CONFIG/rconpw"
|
pwgen 15 1 >"$CONFIG/rconpw"
|
||||||
fi
|
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"
|
cp /opt/factorio/data/server-settings.example.json "$CONFIG/server-settings.json"
|
||||||
fi
|
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"
|
cp /opt/factorio/data/map-gen-settings.example.json "$CONFIG/map-gen-settings.json"
|
||||||
fi
|
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"
|
cp /opt/factorio/data/map-settings.example.json "$CONFIG/map-settings.json"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1,27 +1,25 @@
|
|||||||
#!/bin/sh -x
|
#!/bin/bash
|
||||||
if [ -z "$1" ]; then
|
set -eoux pipefail
|
||||||
|
|
||||||
|
if [[ -z ${1:-} ]]; then
|
||||||
echo "No argument supplied"
|
echo "No argument supplied"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SERVER_SCENARIO="$1"
|
SERVER_SCENARIO="$1"
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
id
|
|
||||||
|
|
||||||
mkdir -p "$SAVES"
|
mkdir -p "$SAVES"
|
||||||
mkdir -p "$CONFIG"
|
mkdir -p "$CONFIG"
|
||||||
mkdir -p "$MODS"
|
mkdir -p "$MODS"
|
||||||
mkdir -p "$SCENARIOS"
|
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"
|
cp /opt/factorio/data/server-settings.example.json "$CONFIG/server-settings.json"
|
||||||
fi
|
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"
|
cp /opt/factorio/data/map-gen-settings.example.json "$CONFIG/map-gen-settings.json"
|
||||||
fi
|
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"
|
cp /opt/factorio/data/map-settings.example.json "$CONFIG/map-settings.json"
|
||||||
fi
|
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
|
27
README.md
27
README.md
@ -1,6 +1,6 @@
|
|||||||
# 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.17.58`, `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.16.51`, `0.16`, `stable` [(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.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)
|
* `0.14.23`, `0.14` [(0.14/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.14/Dockerfile)
|
||||||
@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
* `latest` - most up-to-date version (may be experimental).
|
* `latest` - most up-to-date version (may be experimental).
|
||||||
* `stable` - version declared stable on [factorio.com](https://www.factorio.com).
|
* `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.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?
|
# What is Factorio?
|
||||||
@ -112,6 +112,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.
|
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
|
||||||
|
|
||||||
@ -339,11 +341,12 @@ Use the `PORT` environment variable to start the server on the a different port,
|
|||||||
# Contributors
|
# Contributors
|
||||||
|
|
||||||
* [dtandersen](https://github.com/dtandersen) - Maintainer
|
* [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.
|
* [Fank](https://github.com/Fankserver) - Keeper of the Factorio watchdog that keeps the version up-to-date.
|
||||||
* [SuperSandro2000](https://github.com/supersandro2000) - CI Guy
|
* [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) - Admin list, ban list, 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) - Originator
|
* [Zopanix](https://github.com/zopanix/docker_factorio_server) - Original Author
|
||||||
* [Rfvgyhn](https://github.com/Rfvgyhn/docker-factorio) - Randomly generate RCON password
|
* [Rfvgyhn](https://github.com/Rfvgyhn/docker-factorio) - Coded randomly generated RCON password
|
||||||
* [gnomus](https://github.com/gnomus/docker_factorio_server) - White listing
|
* [gnomus](https://github.com/gnomus/docker_factorio_server) - Coded wite listing support
|
||||||
* [bplein](https://github.com/bplein/docker_factorio_server) - Scenario support
|
* [bplein](https://github.com/bplein/docker_factorio_server) - Coded scenario support
|
||||||
* [jaredledvina](https://github.com/jaredledvina/docker_factorio_server) - Version update
|
* [jaredledvina](https://github.com/jaredledvina/docker_factorio_server) - Contributed version updates
|
||||||
|
* [carlbennett](https://github.com/carlbennett) - Contributed version updates and bugfixes
|
||||||
|
52
build.sh
52
build.sh
@ -1,33 +1,39 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eox pipefail
|
set -eoux pipefail
|
||||||
|
|
||||||
if [ -z "$1" ] && [ -n "$CI" ]; then
|
if [[ -z ${1:-} ]] && [[ -n ${CI:-} ]]; then
|
||||||
echo "Usage: ./build.sh \$VERSION_SHORT"
|
echo "Usage: ./build.sh \$VERSION_SHORT"
|
||||||
exit 1
|
exit 1
|
||||||
elif [ "$CI" == "true" ]; then
|
elif [[ $CI == true ]]; then
|
||||||
VERSION_SHORT="$1"
|
VERSION_SHORT="$1"
|
||||||
else
|
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
|
EXTRA_TAG=latest
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$VERSION_SHORT" || exit
|
cd "$VERSION_SHORT" || exit 1
|
||||||
|
|
||||||
VERSION=$(grep -oP '[0-9]+\.[0-9]+\.[0-9]+' Dockerfile | head -1)
|
VERSION=$(grep -oP '[0-9]+\.[0-9]+\.[0-9]+' Dockerfile | head -1)
|
||||||
DOCKER_REPO=factoriotools/factorio
|
DOCKER_REPO=factoriotools/factorio
|
||||||
|
|
||||||
if [ "$TRAVIS_PULL_REQUEST" == "true" ]; then
|
if [[ $TRAVIS_PULL_REQUEST == true ]]; then
|
||||||
TAGS="$DOCKER_REPO:$TRAVIS_PULL_REQUEST_SLUG"
|
TAGS="$DOCKER_REPO:$TRAVIS_PULL_REQUEST_SLUG"
|
||||||
else
|
else
|
||||||
if [ "$TRAVIS_BRANCH" == "master" ] || [ "$TRAVIS_BRANCH" == "$VERSION" ]; then
|
# 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"
|
TAGS="$DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
|
||||||
elif [ -n "$TRAVIS_BRANCH" ]; then
|
# 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"
|
TAGS="$DOCKER_REPO:$TRAVIS_BRANCH"
|
||||||
elif [ "$CI" == "" ]; then
|
# we are not in CI and tag version and version short
|
||||||
|
elif [[ $CI == "" ]]; then
|
||||||
TAGS="$DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
|
TAGS="$DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$EXTRA_TAG" ]; then
|
if [[ -n ${EXTRA_TAG:-} ]]; then
|
||||||
TAGS="$TAGS -t $DOCKER_REPO:$EXTRA_TAG"
|
TAGS="$TAGS -t $DOCKER_REPO:$EXTRA_TAG"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -36,22 +42,34 @@ fi
|
|||||||
docker build . -t $TAGS
|
docker build . -t $TAGS
|
||||||
docker images
|
docker images
|
||||||
|
|
||||||
if [[ "$(dirname "$(git diff --name-only HEAD^)")" =~ $VERSION_SHORT ]] && [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST_BRANCH" == "" ] ||
|
# only push when:
|
||||||
[ "$TRAVIS_BRANCH" == "$VERSION" ] && [ "$TRAVIS_PULL_REQUEST_BRANCH" == "" ] ||
|
# latest changes where made in the folder corosponding to the version we build, we are on master and don#t build a PR.
|
||||||
[ "$CI" == "" ]; then
|
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 == "" ]] ||
|
||||||
|
# we are not in CI
|
||||||
|
[[ $CI == "" ]]; then
|
||||||
|
|
||||||
if [ "$CI" == "true" ]; then
|
if [[ $CI == true ]]; then
|
||||||
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
||||||
fi
|
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%-*}" ]] && [[ $TRAVIS_BRANCH != "master" ]]; then
|
||||||
docker push "$DOCKER_REPO:$TRAVIS_BRANCH"
|
docker push "$DOCKER_REPO:$TRAVIS_BRANCH"
|
||||||
fi
|
fi
|
||||||
if [ -n "$TRAVIS_TAG" ] || [ "$CI" == "" ]; then
|
|
||||||
|
# push an incremental tag
|
||||||
|
if [[ $VERSION == "${TRAVIS_BRANCH%-*}" ]]; then
|
||||||
|
docker push "$DOCKER_REPO:$TRAVIS_BRANCH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n $TRAVIS_TAG ]] || [[ $CI == "" ]]; then
|
||||||
docker push "$DOCKER_REPO:$VERSION"
|
docker push "$DOCKER_REPO:$VERSION"
|
||||||
docker push "$DOCKER_REPO:$VERSION_SHORT"
|
docker push "$DOCKER_REPO:$VERSION_SHORT"
|
||||||
fi
|
fi
|
||||||
if [ -n "$EXTRA_TAG" ]; then
|
|
||||||
|
if [[ -n ${EXTRA_TAG:-} ]]; then
|
||||||
docker push "$DOCKER_REPO:$EXTRA_TAG"
|
docker push "$DOCKER_REPO:$EXTRA_TAG"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user