Compare commits

..

1 Commits

Author SHA1 Message Date
472369d36f URL encode spaces
Closes #275
2019-07-08 16:59:40 +02:00
9 changed files with 91 additions and 116 deletions

View File

@ -16,11 +16,11 @@ jobs:
- bash -c 'shopt -s globstar; shellcheck **/*.sh' - bash -c 'shopt -s globstar; shellcheck **/*.sh'
- &build - &build
stage: build stage: build
env: VERSION_SHORT=0.17 EXTRA_TAG=latest STABLE=0.17.74 env: VERSION_SHORT=0.17 EXTRA_TAG=latest
script: script:
- ./build.sh $VERSION_SHORT - ./build.sh $VERSION_SHORT
- <<: *build - <<: *build
env: VERSION_SHORT=0.16 env: VERSION_SHORT=0.16 EXTRA_TAG=stable
- <<: *build - <<: *build
env: VERSION_SHORT=0.15 env: VERSION_SHORT=0.15
- <<: *build - <<: *build

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -9,8 +9,8 @@ ARG PGID=845
ENV PORT=34197 \ ENV PORT=34197 \
RCON_PORT=27015 \ RCON_PORT=27015 \
VERSION=0.17.75 \ VERSION=0.17.54 \
SHA1=f4b63a803d9eb22e8102705fdc510e0de38a4c7a \ SHA1=69750604bc9036abdf5e9297dfc975f80b52c573 \
SAVES=/factorio/saves \ SAVES=/factorio/saves \
CONFIG=/factorio/config \ CONFIG=/factorio/config \
MODS=/factorio/mods \ MODS=/factorio/mods \
@ -19,23 +19,21 @@ ENV PORT=34197 \
PUID="$PUID" \ PUID="$PUID" \
PGID="$PGID" PGID="$PGID"
RUN set -ox pipefail \ RUN mkdir -p /opt /factorio && \
&& archive="/tmp/factorio_headless_x64_$VERSION.tar.xz" \ apk add --update --no-cache --no-progress bash binutils curl gettext jq libintl pwgen shadow su-exec && \
&& 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 \ addgroup -g "$PGID" -S "$GROUP" && \
&& ln -s "$SCRIPTOUTPUT" /opt/factorio/script-output \ adduser -u "$PUID" -G "$GROUP" -s /bin/sh -SDH "$USER" && \
&& addgroup -g "$PGID" -S "$GROUP" \ chown -R "$USER":"$GROUP" /opt/factorio /factorio
&& adduser -u "$PUID" -G "$GROUP" -s /bin/sh -SDH "$USER" \
&& chown -R "$USER":"$GROUP" /opt/factorio /factorio
VOLUME /factorio VOLUME /factorio

View File

@ -33,10 +33,8 @@ exec /opt/factorio/bin/x64/factorio \
--port "$PORT" \ --port "$PORT" \
--start-server-load-scenario "$SERVER_SCENARIO" \ --start-server-load-scenario "$SERVER_SCENARIO" \
--server-settings "$CONFIG/server-settings.json" \ --server-settings "$CONFIG/server-settings.json" \
--server-banlist "$CONFIG/server-banlist.json" \
--server-whitelist "$CONFIG/server-whitelist.json" \ --server-whitelist "$CONFIG/server-whitelist.json" \
--use-server-whitelist \ --server-banlist "$CONFIG/server-banlist.json" \
--server-adminlist "$CONFIG/server-adminlist.json" \
--rcon-port "$RCON_PORT" \ --rcon-port "$RCON_PORT" \
--rcon-password "$(cat "$CONFIG/rconpw")" \ --rcon-password "$(cat "$CONFIG/rconpw")" \
--server-id /factorio/config/server-id.json --server-id /factorio/config/server-id.json

View File

@ -58,7 +58,7 @@ update_mod()
if [[ $HTTP_STATUS != 200 ]]; then if [[ $HTTP_STATUS != 200 ]]; then
print_failure " Download failed: Code $HTTP_STATUS." print_failure " Download failed: Code $HTTP_STATUS."
rm -f "$MOD_DIR/$MOD_FILENAME" rm "$MOD_DIR/$MOD_FILENAME"
return 1 return 1
fi fi
@ -69,7 +69,7 @@ update_mod()
if ! [[ $(sha1sum "$MOD_DIR/$MOD_FILENAME") =~ $MOD_SHA1 ]]; then if ! [[ $(sha1sum "$MOD_DIR/$MOD_FILENAME") =~ $MOD_SHA1 ]]; then
print_failure " SHA1 mismatch!" print_failure " SHA1 mismatch!"
rm -f "$MOD_DIR/$MOD_FILENAME" rm "$MOD_DIR/$MOD_FILENAME"
return 1 return 1
fi fi
@ -78,7 +78,7 @@ update_mod()
for file in "$MOD_DIR/${MOD_NAME}_"*".zip"; do # wildcard does usually not work in quotes: https://unix.stackexchange.com/a/67761 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 if [[ $file != $MOD_DIR/$MOD_FILENAME ]]; then
print_success " Deleting old version: $file" print_success " Deleting old version: $file"
rm -f "$file" rm "$file"
fi fi
done done

View File

@ -1,8 +1,7 @@
# 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") # 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.17.75`, `0.17`, `latest` [(0.17/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.17/Dockerfile) * `0.17.54`, `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`, `stable` [(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)
@ -23,7 +22,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. 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 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 game is available at [factorio.com](https://www.factorio.com) and [Steam](http://store.steampowered.com/app/427520/).
# Usage # Usage

View File

@ -2,9 +2,9 @@
set -eoux 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 ]] || [[ -n ${1:-} ]]; 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]]*")
@ -16,81 +16,61 @@ 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 [[ -n ${CI:-} ]]; then # we are either on master or on a tag build
# we are either on master or on a tag build if [[ $TRAVIS_BRANCH == master ]] || [[ $TRAVIS_BRANCH == "$VERSION" ]]; then
if [[ $TRAVIS_BRANCH == master ]] || [[ $TRAVIS_BRANCH == "$VERSION" ]]; then TAGS="$DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
TAGS="-t $DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT" # we are on an incremental build of a tag
# we are on an incremental build of a tag elif [[ $VERSION == "${TRAVIS_BRANCH%-*}" ]]; then
elif [[ $VERSION == "${TRAVIS_BRANCH%-*}" ]]; then TAGS="$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 elif [[ -n $TRAVIS_BRANCH ]]; then
elif [[ -n $TRAVIS_BRANCH ]]; then TAGS="$DOCKER_REPO:$TRAVIS_BRANCH"
TAGS="-t $DOCKER_REPO:$TRAVIS_BRANCH" # we are not in CI and tag version and version short
fi elif [[ $CI == "" ]]; then
else TAGS="$DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
# we are not in CI and tag version and version short
TAGS="-t $DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
fi fi
if [[ -n ${EXTRA_TAG:-} ]]; then if [[ -n ${EXTRA_TAG:-} ]]; then
IFS="," TAGS="$TAGS -t $DOCKER_REPO:$EXTRA_TAG"
for TAG in $EXTRA_TAG; do
TAGS+=" -t $DOCKER_REPO:$TAG"
done
fi
if [[ ${STABLE:-} == "$VERSION" ]]; then
TAGS+=" -T $DOCKER_REPO:stable"
fi fi
fi fi
# shellcheck disable=SC2068 # shellcheck disable=SC2086
eval docker build . ${TAGS[@]} docker build . -t $TAGS
docker images docker images
if [[ ${TRAVIS_BRANCH:-} ]]; then
TRAVIS_BRANCH_VERSION=${TRAVIS_BRANCH%-*}
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%-*}" ]] && [[ $TRAVIS_PULL_REQUEST_BRANCH == "" ]] ||
# we are not in CI # we are not in CI
[[ -z ${CI:-} ]]; then [[ $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
# push a tag on a branch other than master # push a tag on a branch other than master
if [[ -n ${TRAVIS_BRANCH:-} ]] && [[ $VERSION != "${TRAVIS_BRANCH_VERSION:-}" ]] && [[ ${TRAVIS_BRANCH:-} != "master" ]]; then 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
# push an incremental tag # push an incremental tag
if [[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" ]]; then if [[ $VERSION == "${TRAVIS_BRANCH%-*}" ]]; then
docker push "$DOCKER_REPO:$TRAVIS_BRANCH" docker push "$DOCKER_REPO:$TRAVIS_BRANCH"
fi fi
if [[ -n ${TRAVIS_TAG:-} ]] || [[ -z ${CI:-} ]]; then 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
IFS="," docker push "$DOCKER_REPO:$EXTRA_TAG"
for TAG in $EXTRA_TAG; do
docker push "$DOCKER_REPO:$TAG"
done
fi
if [[ ${STABLE:-} == "$VERSION" ]]; then
docker push "$DOCKER_REPO:stable"
fi fi
curl -X POST https://hooks.microbadger.com/images/factoriotools/factorio/TmmKGNp8jKcFqZvcJhTCIAJVluw= curl -X POST https://hooks.microbadger.com/images/factoriotools/factorio/TmmKGNp8jKcFqZvcJhTCIAJVluw=