Compare commits

..

1 Commits

Author SHA1 Message Date
1eb90fd79d Update to Factorio 0.17.75 2019-11-04 15:59:47 +00:00
17 changed files with 140 additions and 604 deletions

View File

@ -1,8 +1,8 @@
dist: xenial dist: xenial
sudo: required
language: bash language: bash
services: services:
- docker - docker
addons: addons:
apt: apt:
packages: packages:
@ -14,21 +14,14 @@ jobs:
script: 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"' -- {} - 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' - bash -c 'shopt -s globstar; shellcheck **/*.sh'
- &build - &build
stage: Build & update Docker HUB description stage: build
env: VERSION_SHORT=0.18 EXTRA_TAG=latest env: VERSION_SHORT=0.17 EXTRA_TAG=latest,stable
script: script:
- ./build.sh $VERSION_SHORT - ./build.sh $VERSION_SHORT
- <<: *build
env: VERSION_SHORT=0.17 EXTRA_TAG=stable
- <<: *build - <<: *build
env: VERSION_SHORT=0.16 env: VERSION_SHORT=0.16
- <<: *build - <<: *build
env: VERSION_SHORT=0.15 env: VERSION_SHORT=0.15
- <<: *build - <<: *build
env: VERSION_SHORT=0.14 env: VERSION_SHORT=0.14
- <<: *build
if: branch = master AND type != pull_request
env:
script: DOCKERHUB_USERNAME=$DOCKER_USERNAME DOCKERHUB_PASSWORD=$DOCKER_PASSWORD DOCKERHUB_REPOSITORY='factoriotools/factorio' README_FILEPATH='./README.md' ./update-dockerhub-description.sh

View File

@ -1,4 +1,4 @@
FROM frolvlad/alpine-glibc:alpine-3.11 FROM frolvlad/alpine-glibc:alpine-3.9
LABEL maintainer="https://github.com/factoriotools/factorio-docker" LABEL maintainer="https://github.com/factoriotools/factorio-docker"

View File

@ -1,4 +1,4 @@
FROM frolvlad/alpine-glibc:alpine-3.11 FROM frolvlad/alpine-glibc:alpine-3.9
LABEL maintainer="https://github.com/factoriotools/factorio-docker" LABEL maintainer="https://github.com/factoriotools/factorio-docker"

View File

@ -1,4 +1,4 @@
FROM frolvlad/alpine-glibc:alpine-3.11 FROM frolvlad/alpine-glibc:alpine-3.9
LABEL maintainer="https://github.com/factoriotools/factorio-docker" LABEL maintainer="https://github.com/factoriotools/factorio-docker"

View File

@ -1,4 +1,4 @@
FROM frolvlad/alpine-glibc:alpine-3.11 FROM frolvlad/alpine-glibc:alpine-3.9
LABEL maintainer="https://github.com/factoriotools/factorio-docker" LABEL maintainer="https://github.com/factoriotools/factorio-docker"
@ -9,8 +9,8 @@ ARG PGID=845
ENV PORT=34197 \ ENV PORT=34197 \
RCON_PORT=27015 \ RCON_PORT=27015 \
VERSION=0.17.79 \ VERSION=0.17.75 \
SHA1=7f127baf3cf01c6e545a9ca376dec1ac37468f8a \ SHA1=f4b63a803d9eb22e8102705fdc510e0de38a4c7a \
SAVES=/factorio/saves \ SAVES=/factorio/saves \
CONFIG=/factorio/config \ CONFIG=/factorio/config \
MODS=/factorio/mods \ MODS=/factorio/mods \
@ -19,7 +19,6 @@ ENV PORT=34197 \
PUID="$PUID" \ PUID="$PUID" \
PGID="$PGID" PGID="$PGID"
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
RUN set -ox pipefail \ RUN set -ox pipefail \
&& archive="/tmp/factorio_headless_x64_$VERSION.tar.xz" \ && archive="/tmp/factorio_headless_x64_$VERSION.tar.xz" \
&& mkdir -p /opt /factorio \ && mkdir -p /opt /factorio \
@ -30,12 +29,10 @@ RUN set -ox pipefail \
&& tar xf "$archive" --directory /opt \ && tar xf "$archive" --directory /opt \
&& chmod ugo=rwx /opt/factorio \ && chmod ugo=rwx /opt/factorio \
&& rm "$archive" \ && rm "$archive" \
&& mkdir -p /opt/factorio/config/ \ && ln -s "$SAVES" /opt/factorio/saves \
&& printf "\ && ln -s "$MODS" /opt/factorio/mods \
[path]\n\ && ln -s "$SCENARIOS" /opt/factorio/scenarios \
read-data=__PATH__executable__/../../data\n\ && ln -s "$SCRIPTOUTPUT" /opt/factorio/script-output \
write-data=/factorio\n\
" >> /opt/factorio/config/config.ini \
&& 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

View File

@ -2,10 +2,6 @@
set -eoux pipefail set -eoux pipefail
FACTORIO_VOL=/factorio 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 "$FACTORIO_VOL"
mkdir -p "$SAVES" mkdir -p "$SAVES"
mkdir -p "$CONFIG" mkdir -p "$CONFIG"
@ -54,28 +50,18 @@ else
fi fi
NRSAVES=$(find -L "$SAVES" -iname \*.zip -mindepth 1 | wc -l) NRSAVES=$(find -L "$SAVES" -iname \*.zip -mindepth 1 | wc -l)
if [[ $GENERATE_NEW_SAVE != true && $NRSAVES == 0 ]]; then if [[ $NRSAVES -eq 0 ]]; then
GENERATE_NEW_SAVE=true # Generate a new map if no save ZIPs exist
SAVE_NAME=_autosave1 $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"
fi fi
if [[ $GENERATE_NEW_SAVE == true ]]; then # shellcheck disable=SC2086
if [[ -z "$SAVE_NAME" ]]; then exec $SU_EXEC /opt/factorio/bin/x64/factorio \
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" \ --port "$PORT" \
--start-server-load-latest \
--server-settings "$CONFIG/server-settings.json" \ --server-settings "$CONFIG/server-settings.json" \
--server-banlist "$CONFIG/server-banlist.json" \ --server-banlist "$CONFIG/server-banlist.json" \
--rcon-port "$RCON_PORT" \ --rcon-port "$RCON_PORT" \
@ -84,13 +70,4 @@ FLAGS=(\
--server-adminlist "$CONFIG/server-adminlist.json" \ --server-adminlist "$CONFIG/server-adminlist.json" \
--rcon-password "$(cat "$CONFIG/rconpw")" \ --rcon-password "$(cat "$CONFIG/rconpw")" \
--server-id /factorio/config/server-id.json \ --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[@]}" "$@"

View File

@ -32,20 +32,19 @@ update_mod()
MOD_INFO_URL="$MOD_BASE_URL/api/mods/$MOD_NAME" MOD_INFO_URL="$MOD_BASE_URL/api/mods/$MOD_NAME"
MOD_INFO_JSON=$(curl --silent "$MOD_INFO_URL") 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_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_FILENAME=$(echo "$MOD_INFO" | cut -f1 -d";")
MOD_URL=$(echo "$MOD_INFO" | cut -f2 -d";") MOD_URL=$(echo "$MOD_INFO" | cut -f2 -d";")
MOD_SHA1=$(echo "$MOD_INFO" | cut -f3 -d";") MOD_SHA1=$(echo "$MOD_INFO" | cut -f3 -d";")
if [[ -z $MOD_URL ]]; then
return 1
fi
if [[ $MOD_FILENAME == null ]]; then if [[ $MOD_FILENAME == null ]]; then
print_failure " Not compatible with version" print_failure " Not compatible with version"
return 0 return 1
fi fi
if [[ -f $MOD_DIR/$MOD_FILENAME ]]; then if [[ -f $MOD_DIR/$MOD_FILENAME ]]; then

View File

@ -1,49 +0,0 @@
FROM frolvlad/alpine-glibc:alpine-3.11
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.24 \
SHA1=04f9aa9b93eaf220d55447201cb10f96e325e073 \
SAVES=/factorio/saves \
CONFIG=/factorio/config \
MODS=/factorio/mods \
SCENARIOS=/factorio/scenarios \
SCRIPTOUTPUT=/factorio/script-output \
PUID="$PUID" \
PGID="$PGID"
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
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" \
&& mkdir -p /opt/factorio/config/ \
&& printf "\
[path]\n\
read-data=__PATH__executable__/../../data\n\
write-data=/factorio\n\
" >> /opt/factorio/config/config.ini \
&& 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"]

View File

@ -1,15 +0,0 @@
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

View File

@ -1,96 +0,0 @@
#!/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[@]}" "$@"

View File

@ -1,28 +0,0 @@
#!/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"

View File

@ -1,42 +0,0 @@
#!/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

View File

@ -1,27 +0,0 @@
#!/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"

View File

@ -1,95 +0,0 @@
#!/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

239
README.md
View File

@ -1,12 +1,12 @@
# Factorio [![Build Status](https://travis-ci.org/factoriotools/factorio-docker.svg?branch=master)](https://travis-ci.org/factoriotools/factorio-docker) ![Updater status](https://img.shields.io/endpoint?label=Updater%20status&logo=a&url=https%3A%2F%2Fhealthchecks.supersandro.de%2Fbadge%2F1a0a7698-445d-4e54-9e4b-f61a1544e01f%2FBO8VukOA%2Fmaintainer.shields) [![Docker Version](https://images.microbadger.com/badges/version/factoriotools/factorio.svg)](https://hub.docker.com/r/factoriotools/factorio/) [![Docker Pulls](https://img.shields.io/docker/pulls/factoriotools/factorio.svg?maxAge=600)](https://hub.docker.com/r/factoriotools/factorio/) [![Docker Stars](https://img.shields.io/docker/stars/factoriotools/factorio.svg?maxAge=600)](https://hub.docker.com/r/factoriotools/factorio/) [![Microbadger Layers](https://images.microbadger.com/badges/image/factoriotools/factorio.svg)](https://microbadger.com/images/factoriotools/factorio "Get your own image badge on microbadger.com") # Factorio [![Build Status](https://travis-ci.org/factoriotools/factorio-docker.svg?branch=master)](https://travis-ci.org/factoriotools/factorio-docker) [![Docker Version](https://images.microbadger.com/badges/version/factoriotools/factorio.svg)](https://hub.docker.com/r/factoriotools/factorio/) [![Docker Pulls](https://img.shields.io/docker/pulls/factoriotools/factorio.svg?maxAge=600)](https://hub.docker.com/r/factoriotools/factorio/) [![Docker Stars](https://img.shields.io/docker/stars/factoriotools/factorio.svg?maxAge=600)](https://hub.docker.com/r/factoriotools/factorio/) [![Microbadger Layers](https://images.microbadger.com/badges/image/factoriotools/factorio.svg)](https://microbadger.com/images/factoriotools/factorio "Get your own image badge on microbadger.com")
* `0.18.24`, `0.18`, `latest` [(0.18/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.18/Dockerfile) * `0.17.75`, `0.17`, `latest` [(0.17/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.17/Dockerfile)
* `0.17.79`, `0.17`, `stable` [(0.17/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.17/Dockerfile) * `0.17.75` `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.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.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)
## Tag descriptions *Tag descriptions*
* `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).
@ -14,7 +14,8 @@
* `0.x.y` - a specific version. * `0.x.y` - a specific version.
* `0.x-z` - incremental fix for that 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. [Factorio](https://www.factorio.com) is a game in which you build and maintain factories.
@ -24,13 +25,14 @@ The game is very stable and optimized for building massive factories. You can cr
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). 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
### Quick Start # Usage
## Quick Start
Run the server to create the necessary folder structure and configuration files. For this example data is stored in `/opt/factorio`. 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 mkdir -p /opt/factorio
sudo chown 845:845 /opt/factorio sudo chown 845:845 /opt/factorio
sudo docker run -d \ sudo docker run -d \
@ -54,36 +56,36 @@ The `chown` command is needed because in 0.16+, we no longer run the game server
Check the logs to see what happened: Check the logs to see what happened:
```shell ```
docker logs factorio docker logs factorio
``` ```
Stop the server: Stop the server:
```shell ```
docker stop factorio 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: 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 docker start factorio
``` ```
Try to connect to the server. Check the logs if it isn't working. 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. 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.
```shell docker run -d -it \
docker run -d -it \ --name factorio \
--name factorio \ factoriotools/factorio
factoriotools/factorio docker attach factorio
docker attach factorio
```
### Upgrading
## Upgrading
Before upgrading backup the save. It's easy to make a save in the client. Before upgrading backup the save. It's easy to make a save in the client.
@ -91,15 +93,14 @@ Ensure `-v` was used to run the server so the save is outside of the Docker cont
Delete the container and refresh the image: Delete the container and refresh the image:
```shell docker stop factorio
docker stop factorio docker rm factorio
docker rm factorio docker pull factoriotools/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! 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. 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,50 +108,19 @@ 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. 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+)
You can specify a specific save to load by configuring the server through a set of environment variables: ## Mods
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 LOAD_LATEST_SAVE=false \
-e SAVE_NAME=replaceme \
--name factorio \
--restart=always \
factoriotools/factorio
```
To generate a new map set `GENERATE_NEW_SAVE=true` and specify `SAVE_NAME`:
```shell
sudo docker run -d \
-p 34197:34197/udp \
-p 27015:27015/tcp \
-v /opt/factorio:/factorio \
-e LOAD_LATEST_SAVE=false \
-e GENERATE_NEW_SAVE=true \
-e SAVE_NAME=replaceme \
--name factorio \
--restart=always \
factoriotools/factorio
```
### Mods
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. 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. 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 \ docker run -d \
-p 34197:34197/udp \ -p 34197:34197/udp \
-p 27015:27015/tcp \ -p 27015:27015/tcp \
@ -162,11 +132,11 @@ docker run -d \
MyScenarioName 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. 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 \ docker run -d \
-p 34197:34197/udp \ -p 34197:34197/udp \
-p 27015:27015/tcp \ -p 27015:27015/tcp \
@ -178,7 +148,7 @@ docker run -d \
MyScenarioName MyScenarioName
``` ```
### RCON ## RCON
Set the RCON password in the `rconpw` file. A random password is generated if `rconpw` doesn't exist. Set the RCON password in the `rconpw` file. A random password is generated if `rconpw` doesn't exist.
@ -186,67 +156,60 @@ 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. 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. Create file `config/server-whitelist.json` and add the whitelisted users.
```json [
[ "you",
"you", "friend"
"friend" ]
]
```
### Banlisting (0.17.1+) ## Banlisting (0.17.1+)
Create file `config/server-banlist.json` and add the banlisted users. Create file `config/server-banlist.json` and add the banlisted users.
```json [
[ "bad_person",
"bad_person", "other_bad_person"
"other_bad_person" ]
]
```
### Adminlisting (0.17.1+) ## Adminlisting (0.17.1+)
Create file `config/server-adminlist.json` and add the adminlisted users. Create file `config/server-adminlist.json` and add the adminlisted users.
```json [
[ "you",
"you", "friend"
"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: 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: Example which replaces the server-settings.json:
```yaml
factorio_1: factorio_1:
image: factoriotools/factorio image: factoriotools/factorio
ports: ports:
- "34197:34197/udp" - "34197:34197/udp"
volumes: volumes:
- /opt/factorio:/factorio - /opt/factorio:/factorio
- ./server-settings.json:/server-settings.json - ./server-settings.json:/server-settings.json
environment: environment:
- INSTANCE_NAME=Your Instance's Name - INSTANCE_NAME=Your Instance's Name
- INSTANCE_DESC=Your Instance's Description - 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" 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: The `server-settings.json` file may then contain the variable references like this:
```json "name": "${INSTANCE_NAME}",
"name": "${INSTANCE_NAME}", "description": "${INSTANCE_DESC}",
"description": "${INSTANCE_DESC}",
```
## Container Details
# Container Details
The philosophy is to [keep it simple](http://wiki.c2.com/?KeepItSimple). The philosophy is to [keep it simple](http://wiki.c2.com/?KeepItSimple).
@ -254,27 +217,26 @@ The philosophy is to [keep it simple](http://wiki.c2.com/?KeepItSimple).
* Prefer configuration files over environment variables. * Prefer configuration files over environment variables.
* Use one volume for data. * 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. 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. The files in this volume should be owned by the factorio user, uid 845.
```text factorio
factorio |-- config
|-- config | |-- map-gen-settings.json
| |-- map-gen-settings.json | |-- map-settings.json
| |-- map-settings.json | |-- rconpw
| |-- rconpw | |-- server-adminlist.json
| |-- server-adminlist.json | |-- server-banlist.json
| |-- server-banlist.json | |-- server-settings.json
| |-- server-settings.json | `-- server-whitelist.json
| `-- server-whitelist.json |-- mods
|-- mods | `-- fancymod.zip
| `-- fancymod.zip `-- saves
`-- saves `-- _autosave1.zip
`-- _autosave1.zip
```
## Docker Compose ## Docker Compose
@ -282,14 +244,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: 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 git clone https://github.com/factoriotools/factorio-docker.git
cd docker_factorio_server/0.17 cd docker_factorio_server/0.17
``` ```
Or make your own: Or make your own:
```shell ```
version: '2' version: '2'
services: services:
factorio: factorio:
@ -303,22 +265,30 @@ services:
Now cd to the directory with docker-compose.yml and run: Now cd to the directory with docker-compose.yml and run:
```shell ```
sudo mkdir -p /opt/factorio sudo mkdir -p /opt/factorio
sudo chown 845:845 /opt/factorio sudo chown 845:845 /opt/factorio
sudo docker-compose up -d sudo docker-compose up -d
``` ```
### Ports
## Ports
* `34197/udp` - Game server (required). * `34197/udp` - Game server (required).
* `27015/tcp` - RCON (optional). * `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 ## LAN Games
Ensure the `lan` setting in server-settings.json is `true`. Ensure the `lan` setting in server-settings.json is `true`.
```shell ```
"visibility": "visibility":
{ {
"public": false, "public": false,
@ -328,7 +298,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. 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 \ sudo docker run -d \
--network=host \ --network=host \
-p 34197:34197/udp \ -p 34197:34197/udp \
@ -339,26 +309,24 @@ sudo docker run -d \
factoriotools/factorio factoriotools/factorio
``` ```
## Deploy to other plaforms ## Vagrant
### 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. [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. 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 "public_network"
config.vm.network "forwarded_port", guest: 34197, host: 34197 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. 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 ## 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. 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.
@ -366,15 +334,16 @@ 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. 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. 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 * [dtandersen](https://github.com/dtandersen) - Maintainer
* [Fank](https://github.com/Fankserver) - Programmer 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, Maintainer and runner of the Factorio watchdog. Contributed version updates and wrote the Travis scripts. * [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 * [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 * [Zopanix](https://github.com/zopanix/docker_factorio_server) - Original Author
* [Rfvgyhn](https://github.com/Rfvgyhn/docker-factorio) - Coded randomly generated RCON password * [Rfvgyhn](https://github.com/Rfvgyhn/docker-factorio) - Coded randomly generated RCON password

View File

@ -27,10 +27,8 @@ else
elif [[ $VERSION == "${TRAVIS_BRANCH%-*}" ]]; then elif [[ $VERSION == "${TRAVIS_BRANCH%-*}" ]]; then
TAGS="-t $DOCKER_REPO:$TRAVIS_BRANCH -t $DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT" TAGS="-t $DOCKER_REPO:$TRAVIS_BRANCH -t $DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
# we build a other branch than master # we build a other branch than master
# disabled for now cause it breaks Travis CI builds of dependabot elif [[ -n $TRAVIS_BRANCH ]]; then
# https://travis-ci.org/github/factoriotools/factorio-docker/jobs/688176474#L182 TAGS="-t $DOCKER_REPO:$TRAVIS_BRANCH"
# elif [[ -n $TRAVIS_BRANCH ]]; then
# TAGS="-t $DOCKER_REPO:$TRAVIS_BRANCH"
fi fi
else else
# we are not in CI and tag version and version short # we are not in CI and tag version and version short
@ -43,10 +41,6 @@ else
TAGS+=" -t $DOCKER_REPO:$TAG" TAGS+=" -t $DOCKER_REPO:$TAG"
done done
fi fi
if [[ ${STABLE:-} == "$VERSION" ]]; then
TAGS+=" -t $DOCKER_REPO:stable"
fi
fi fi
# shellcheck disable=SC2068 # shellcheck disable=SC2068
@ -59,7 +53,7 @@ fi
# only push when: # 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. # 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 # we build a tag and we are not on master
[[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" ]] && [[ ${TRAVIS_PULL_REQUEST_BRANCH:-} == "" ]] || [[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" ]] && [[ ${TRAVIS_PULL_REQUEST_BRANCH:-} == "" ]] ||
# we are not in CI # we are not in CI
@ -70,15 +64,13 @@ if [[ $(dirname "$(git diff --name-only HEAD^)") =~ $VERSION_SHORT ]] && [[ ${TR
fi fi
# push a tag on a branch other than master # push a tag on a branch other than master
# disabled for now cause it breaks Travis CI builds of dependabot if [[ -n ${TRAVIS_BRANCH:-} ]] && [[ $VERSION != "${TRAVIS_BRANCH_VERSION:-}" ]] && [[ ${TRAVIS_BRANCH:-} != "master" ]]; then
# https://travis-ci.org/github/factoriotools/factorio-docker/jobs/688176474#L182 docker push "$DOCKER_REPO:$TRAVIS_BRANCH"
# if [[ -n ${TRAVIS_BRANCH:-} ]] && [[ $VERSION != "${TRAVIS_BRANCH_VERSION:-}" ]] && [[ ${TRAVIS_BRANCH:-} != "master" ]]; then fi
# docker push "$DOCKER_REPO:$TRAVIS_BRANCH"
# fi
# push an incremental tag # push an incremental tag
if [[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" ]]; then if [[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" ]]; then
docker push "$DOCKER_REPO:$VERSION" docker push "$DOCKER_REPO:$TRAVIS_BRANCH"
fi fi
if [[ -n ${TRAVIS_TAG:-} ]] || [[ -z ${CI:-} ]]; then if [[ -n ${TRAVIS_TAG:-} ]] || [[ -z ${CI:-} ]]; then
@ -93,9 +85,5 @@ if [[ $(dirname "$(git diff --name-only HEAD^)") =~ $VERSION_SHORT ]] && [[ ${TR
done done
fi fi
if [[ ${STABLE:-} == "$VERSION" ]]; then
docker push "$DOCKER_REPO:stable"
fi
curl -X POST https://hooks.microbadger.com/images/factoriotools/factorio/TmmKGNp8jKcFqZvcJhTCIAJVluw= curl -X POST https://hooks.microbadger.com/images/factoriotools/factorio/TmmKGNp8jKcFqZvcJhTCIAJVluw=
fi fi

View File

@ -1,35 +0,0 @@
#!/bin/bash
# This script is licensed under MIT and was originally written by Peter Evans. You can find a copy of the MIT license next to this file.
# The original file is available on his Github repo under the following link:
# https://github.com/peter-evans/dockerhub-description/blob/84d38211e27bb9b9effefa718f8c734db8adc5e1/entrypoint.sh
set -euo pipefail
IFS=$'\n\t'
# Set the default path to README.md
README_FILEPATH=${README_FILEPATH:="./README.md"}
# Check the file size
if [[ $(wc -c <${README_FILEPATH}) -gt 25000 ]]; then
echo "File size exceeds the maximum allowed 25000 bytes"
exit 1
fi
# Acquire a token for the Docker Hub API
echo "Acquiring token"
# shellcheck disable=2089
LOGIN_PAYLOAD="{\"username\": \"${DOCKERHUB_USERNAME}\", \"password\": \"${DOCKERHUB_PASSWORD}\"}"
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "${LOGIN_PAYLOAD}" https://hub.docker.com/v2/users/login/ | jq -r .token)
# Send a PATCH request to update the description of the repository
echo "Sending PATCH request"
REPO_URL="https://hub.docker.com/v2/repositories/${DOCKERHUB_REPOSITORY}/"
RESPONSE_CODE=$(curl -s --write-out "%{response_code}" --output /dev/null -H "Authorization: JWT ${TOKEN}" -X PATCH --data-urlencode full_description@${README_FILEPATH} "${REPO_URL}")
echo "Received response code: $RESPONSE_CODE"
if [[ $RESPONSE_CODE -eq 200 ]]; then
exit 0
else
exit 1
fi