mirror of
https://github.com/factoriotools/factorio-docker.git
synced 2025-07-01 14:38:05 +02:00
Compare commits
33 Commits
Author | SHA1 | Date | |
---|---|---|---|
43599d0c23 | |||
6fb4cbc600 | |||
fe0e8f9b91 | |||
f76e88cea1 | |||
cbaa20cdea | |||
b3c134d396 | |||
9bdb79b494 | |||
77d83b4152 | |||
25d4edf14f | |||
e16b111c0b | |||
09e1ad2045 | |||
2efa39084f | |||
77edb05109 | |||
2eea2a25e4 | |||
98ea8a27c1 | |||
956af65a2b | |||
b5c1dff7b4 | |||
ee5b023911 | |||
045ef7a214 | |||
bbc2d42302 | |||
0173eab54c | |||
f868aa16ad | |||
5cd0c40975 | |||
778d982c6d | |||
9d2c38df65 | |||
b2a4195e13 | |||
18ccac666d | |||
830d042e4b | |||
a0868ba653 | |||
7002778ab5 | |||
44371283b6 | |||
d421adab67 | |||
b0cedbbe1b |
20
.travis.yml
20
.travis.yml
@ -11,25 +11,17 @@ addons:
|
||||
jobs:
|
||||
include:
|
||||
- stage: test
|
||||
env: HADOLINT=${HOME}/hadolint
|
||||
install: curl -sLo ${HADOLINT} $(curl -s https://api.github.com/repos/hadolint/hadolint/releases/latest?access_token=${GITHUB_TOKEN} | jq -r '.assets | .[] | select(.name=="hadolint-Linux-x86_64") | .browser_download_url')
|
||||
&& chmod 700 ${HADOLINT}
|
||||
script:
|
||||
- git ls-files --exclude='*Dockerfile' --ignored | xargs --max-lines=1 ${HADOLINT}
|
||||
- git ls-files --exclude='*Dockerfile' --ignored | xargs --max-lines=1 -I{} sh -c 'docker run --rm -i -v ${PWD}/.hadolint.yaml:/.hadolint.yaml hadolint/hadolint < "$1"' -- {}
|
||||
- bash -c 'shopt -s globstar; shellcheck **/*.sh'
|
||||
- &build
|
||||
stage: build
|
||||
env: VERSION=0.17
|
||||
env: VERSION_SHORT=0.17 EXTRA_TAG=latest
|
||||
script:
|
||||
- ./build.sh $VERSION
|
||||
after_success:
|
||||
- if [ "$TRAVIS_BRANCH" == "master" ]; then
|
||||
echo "$DOCKER_PASSWORD" | DOCKER login -u "$DOCKER_USERNAME" --password-stdin
|
||||
docker push "factoriotools/docker_factorio_server:$VERSION"
|
||||
fi
|
||||
- ./build.sh $VERSION_SHORT
|
||||
- <<: *build
|
||||
env: VERSION=0.16
|
||||
env: VERSION_SHORT=0.16 EXTRA_TAG=stable
|
||||
- <<: *build
|
||||
env: VERSION=0.15
|
||||
env: VERSION_SHORT=0.15
|
||||
- <<: *build
|
||||
env: VERSION=0.14
|
||||
env: VERSION_SHORT=0.14
|
||||
|
@ -1,6 +1,6 @@
|
||||
FROM frolvlad/alpine-glibc:alpine-3.9
|
||||
|
||||
LABEL maintainer="https://github.com/dtandersen/docker_factorio_server"
|
||||
LABEL maintainer="https://github.com/factoriotools/factorio-docker"
|
||||
|
||||
ENV VERSION=0.14.23 \
|
||||
SHA1=6ef84341c6fc1cf45cfdd6acc8468aaa117b9e8a
|
||||
|
@ -1,6 +1,6 @@
|
||||
FROM frolvlad/alpine-glibc:alpine-3.9
|
||||
|
||||
LABEL maintainer="https://github.com/dtandersen/docker_factorio_server"
|
||||
LABEL maintainer="https://github.com/factoriotools/factorio-docker"
|
||||
|
||||
ENV PORT=34197 \
|
||||
RCON_PORT=27015 \
|
||||
|
@ -1,6 +1,6 @@
|
||||
FROM frolvlad/alpine-glibc:alpine-3.9
|
||||
|
||||
LABEL maintainer="https://github.com/dtandersen/docker_factorio_server"
|
||||
LABEL maintainer="https://github.com/factoriotools/factorio-docker"
|
||||
|
||||
ARG USER=factorio
|
||||
ARG GROUP=factorio
|
||||
@ -15,10 +15,12 @@ ENV PORT=34197 \
|
||||
CONFIG=/factorio/config \
|
||||
MODS=/factorio/mods \
|
||||
SCENARIOS=/factorio/scenarios \
|
||||
SCRIPTOUTPUT=/factorio/script-output
|
||||
SCRIPTOUTPUT=/factorio/script-output \
|
||||
PUID="$PUID" \
|
||||
PGID="$PGID"
|
||||
|
||||
RUN mkdir -p /opt /factorio && \
|
||||
apk add --update --no-cache pwgen && \
|
||||
apk add --update --no-cache pwgen su-exec shadow && \
|
||||
apk add --update --no-cache --virtual .build-deps curl && \
|
||||
curl -sSL https://www.factorio.com/get-download/$VERSION/headless/linux64 \
|
||||
-o /tmp/factorio_headless_x64_$VERSION.tar.xz && \
|
||||
@ -41,6 +43,4 @@ EXPOSE $PORT/udp $RCON_PORT/tcp
|
||||
|
||||
COPY files/ /
|
||||
|
||||
USER $USER
|
||||
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
|
@ -3,6 +3,8 @@ set -euo pipefail
|
||||
|
||||
id
|
||||
|
||||
FACTORIO_VOL=/factorio
|
||||
mkdir -p "$FACTORIO_VOL"
|
||||
mkdir -p "$SAVES"
|
||||
mkdir -p "$CONFIG"
|
||||
mkdir -p "$MODS"
|
||||
@ -26,17 +28,29 @@ if [ ! -f "$CONFIG/map-settings.json" ]; then
|
||||
fi
|
||||
|
||||
if find -L "$SAVES" -iname \*.tmp.zip -mindepth 1 -print | grep -q .; then
|
||||
rm -f "$SAVES/*.tmp.zip"
|
||||
rm -f "$SAVES"/*.tmp.zip
|
||||
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
|
||||
|
||||
if ! find -L "$SAVES" -iname \*.zip -mindepth 1 -print | grep -q .; then
|
||||
/opt/factorio/bin/x64/factorio \
|
||||
$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
|
||||
|
||||
exec /opt/factorio/bin/x64/factorio \
|
||||
$SU_EXEC /opt/factorio/bin/x64/factorio \
|
||||
--port "$PORT" \
|
||||
--start-server-load-latest \
|
||||
--server-settings "$CONFIG/server-settings.json" \
|
||||
|
@ -1,6 +1,6 @@
|
||||
FROM frolvlad/alpine-glibc:alpine-3.9
|
||||
|
||||
LABEL maintainer="https://github.com/dtandersen/docker_factorio_server"
|
||||
LABEL maintainer="https://github.com/factoriotools/factorio-docker"
|
||||
|
||||
ARG USER=factorio
|
||||
ARG GROUP=factorio
|
||||
@ -9,33 +9,33 @@ ARG PGID=845
|
||||
|
||||
ENV PORT=34197 \
|
||||
RCON_PORT=27015 \
|
||||
VERSION=0.17.37 \
|
||||
SHA1=4af991cb42145854a4803203f31d42f81fea7034 \
|
||||
VERSION=0.17.47 \
|
||||
SHA1=504edefb1651aaec6a943dd74b0c7aba1b9551a0 \
|
||||
SAVES=/factorio/saves \
|
||||
CONFIG=/factorio/config \
|
||||
MODS=/factorio/mods \
|
||||
SCENARIOS=/factorio/scenarios \
|
||||
SCRIPTOUTPUT=/factorio/script-output \
|
||||
PUID=$PUID \
|
||||
PGID=$PGID
|
||||
PUID="$PUID" \
|
||||
PGID="$PGID"
|
||||
|
||||
RUN mkdir -p /opt /factorio && \
|
||||
apk add --update --no-cache pwgen su-exec binutils gettext libintl shadow && \
|
||||
apk add --update --no-cache --virtual .build-deps curl && \
|
||||
curl -sSL https://www.factorio.com/get-download/$VERSION/headless/linux64 \
|
||||
curl -sSL "https://www.factorio.com/get-download/$VERSION/headless/linux64" \
|
||||
-o /tmp/factorio_headless_x64_$VERSION.tar.xz && \
|
||||
echo "$SHA1 /tmp/factorio_headless_x64_$VERSION.tar.xz" | sha1sum -c && \
|
||||
tar xf /tmp/factorio_headless_x64_$VERSION.tar.xz --directory /opt && \
|
||||
tar xf "/tmp/factorio_headless_x64_$VERSION.tar.xz" --directory /opt && \
|
||||
chmod ugo=rwx /opt/factorio && \
|
||||
rm /tmp/factorio_headless_x64_$VERSION.tar.xz && \
|
||||
ln -s $SAVES /opt/factorio/saves && \
|
||||
ln -s $MODS /opt/factorio/mods && \
|
||||
ln -s $SCENARIOS /opt/factorio/scenarios && \
|
||||
ln -s $SCRIPTOUTPUT /opt/factorio/script-output && \
|
||||
rm "/tmp/factorio_headless_x64_$VERSION.tar.xz" && \
|
||||
ln -s "$SAVES" /opt/factorio/saves && \
|
||||
ln -s "$MODS" /opt/factorio/mods && \
|
||||
ln -s "$SCENARIOS" /opt/factorio/scenarios && \
|
||||
ln -s "$SCRIPTOUTPUT" /opt/factorio/script-output && \
|
||||
apk del .build-deps && \
|
||||
addgroup -g $PGID -S $GROUP && \
|
||||
adduser -u $PUID -G $GROUP -s /bin/sh -SDH $USER && \
|
||||
chown -R $USER:$GROUP /opt/factorio /factorio
|
||||
addgroup -g "$PGID" -S "$GROUP" && \
|
||||
adduser -u "$PUID" -G "$GROUP" -s /bin/sh -SDH "$USER" && \
|
||||
chown -R "$USER":"$GROUP" /opt/factorio /factorio
|
||||
|
||||
VOLUME /factorio
|
||||
|
||||
|
@ -29,9 +29,10 @@ if [ ! -f "$CONFIG/map-settings.json" ]; then
|
||||
cp /opt/factorio/data/map-settings.example.json "$CONFIG/map-settings.json"
|
||||
fi
|
||||
|
||||
if find -L "$SAVES" -iname \*.tmp.zip -mindepth 1 -print | grep -q .; then
|
||||
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"
|
||||
rm -f "$SAVES"/*.tmp.zip
|
||||
fi
|
||||
|
||||
if [ "$(id -u)" = '0' ]; then
|
||||
@ -39,14 +40,15 @@ if [ "$(id -u)" = '0' ]; then
|
||||
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
|
||||
chown -R factorio:factorio "$FACTORIO_VOL"
|
||||
# Drop to the factorio user
|
||||
SU_EXEC="su-exec factorio"
|
||||
else
|
||||
SU_EXEC=""
|
||||
fi
|
||||
|
||||
if ! find -L "$SAVES" -iname \*.zip -mindepth 1 -print | grep -q .; then
|
||||
NRSAVES=$( find -L "$SAVES" -iname \*.zip -mindepth 1 | wc -l )
|
||||
if [ "$NRSAVES" -eq 0 ]; then
|
||||
# Generate a new map if no save ZIPs exist
|
||||
$SU_EXEC /opt/factorio/bin/x64/factorio \
|
||||
--create "$SAVES/_autosave1.zip" \
|
||||
|
17
README.md
17
README.md
@ -1,9 +1,9 @@
|
||||
# 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://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/)
|
||||
|
||||
* `0.17.37`, `0.17`, `latest` [(0.17/Dockerfile)](https://github.com/dtandersen/docker_factorio_server/blob/master/0.17/Dockerfile)
|
||||
* `0.16.51`, `0.16`, `stable` [(0.16/Dockerfile)](https://github.com/dtandersen/docker_factorio_server/blob/master/0.16/Dockerfile)
|
||||
* `0.15.40`, `0.15` [(0.15/Dockerfile)](https://github.com/dtandersen/docker_factorio_server/blob/master/0.15/Dockerfile)
|
||||
* `0.14.23`, `0.14` [(0.14/Dockerfile)](https://github.com/dtandersen/docker_factorio_server/blob/master/0.14/Dockerfile)
|
||||
* `0.17.47`, `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.15.40`, `0.15` [(0.15/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.15/Dockerfile)
|
||||
* `0.14.23`, `0.14` [(0.14/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.14/Dockerfile)
|
||||
|
||||
*Tag descriptions*
|
||||
|
||||
@ -239,10 +239,10 @@ The files in this volume should be owned by the factorio user, uid 845.
|
||||
|
||||
[Docker Compose](https://docs.docker.com/compose/install/) is an easy way to run Docker containers.
|
||||
|
||||
First get a [docker-compose.yml](https://github.com/dtandersen/docker_factorio_server/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:
|
||||
|
||||
```
|
||||
git clone https://github.com/dtandersen/docker_factorio_server.git
|
||||
git clone https://github.com/factoriotools/factorio-docker.git
|
||||
cd docker_factorio_server/0.17
|
||||
```
|
||||
|
||||
@ -338,8 +338,9 @@ Use the `PORT` environment variable to start the server on the a different port,
|
||||
|
||||
# Contributors
|
||||
|
||||
* [dtandersen](https://github.com/dtandersen/docker_factorio_server) - 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.
|
||||
* [SuperSandro2000](https://github.com/supersandro2000) - CI Guy
|
||||
* [DBendit](https://github.com/DBendit/docker_factorio_server) - Admin list, ban list, version updates
|
||||
* [Zopanix](https://github.com/zopanix/docker_factorio_server) - Originator
|
||||
* [Rfvgyhn](https://github.com/Rfvgyhn/docker-factorio) - Randomly generate RCON password
|
||||
|
59
build.sh
59
build.sh
@ -1,12 +1,59 @@
|
||||
#!/bin/bash
|
||||
set -eo pipefail
|
||||
set -eox pipefail
|
||||
|
||||
if [ -z "$1" ] ; then
|
||||
echo "Usage: ./build.sh \$VERSION"
|
||||
if [ -z "$1" ] && [ -n "$CI" ]; then
|
||||
echo "Usage: ./build.sh \$VERSION_SHORT"
|
||||
exit 1
|
||||
elif [ "$CI" == "true" ]; then
|
||||
VERSION_SHORT="$1"
|
||||
else
|
||||
VERSION="$1"
|
||||
VERSION_SHORT=$(find . -maxdepth 1 -type d | sort | tail -1 | grep -o "[0-9].[0-9]*")
|
||||
EXTRA_TAG=latest
|
||||
fi
|
||||
|
||||
cd "$VERSION" || exit
|
||||
cd "$VERSION_SHORT" || exit
|
||||
|
||||
docker build . -t "factoriotools/docker_factorio_server:$VERSION"
|
||||
VERSION=$(grep -oP '[0-9]+\.[0-9]+\.[0-9]+' Dockerfile | head -1)
|
||||
DOCKER_REPO=factoriotools/factorio
|
||||
|
||||
if [ "$TRAVIS_PULL_REQUEST" == "true" ]; then
|
||||
TAGS="$DOCKER_REPO:$TRAVIS_PULL_REQUEST_SLUG"
|
||||
else
|
||||
if [ "$TRAVIS_BRANCH" == "master" ] || [ "$TRAVIS_BRANCH" == "$VERSION" ]; then
|
||||
TAGS="$DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
|
||||
elif [ -n "$TRAVIS_BRANCH" ]; then
|
||||
TAGS="$DOCKER_REPO:$TRAVIS_BRANCH"
|
||||
elif [ "$CI" == "" ]; then
|
||||
TAGS="$DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
|
||||
fi
|
||||
|
||||
if [ -n "$EXTRA_TAG" ]; then
|
||||
TAGS="$TAGS -t $DOCKER_REPO:$EXTRA_TAG"
|
||||
fi
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
docker build . -t $TAGS
|
||||
docker images
|
||||
|
||||
if [[ "$(dirname "$(git diff --name-only HEAD^)")" =~ $VERSION_SHORT ]] && [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST_BRANCH" == "" ] ||
|
||||
[ "$TRAVIS_BRANCH" == "$VERSION" ] && [ "$TRAVIS_PULL_REQUEST_BRANCH" == "" ] ||
|
||||
[ "$CI" == "" ]; then
|
||||
|
||||
if [ "$CI" == "true" ]; then
|
||||
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
||||
fi
|
||||
|
||||
if [ -n "$TRAVIS_BRANCH" ] && [ "$TRAVIS_BRANCH" != "$VERSION" ] && [ "$TRAVIS_BRANCH" != "master" ]; then
|
||||
docker push "$DOCKER_REPO:$TRAVIS_BRANCH"
|
||||
fi
|
||||
if [ -n "$TRAVIS_TAG" ] || [ "$CI" == "" ]; then
|
||||
docker push "$DOCKER_REPO:$VERSION"
|
||||
docker push "$DOCKER_REPO:$VERSION_SHORT"
|
||||
fi
|
||||
if [ -n "$EXTRA_TAG" ]; then
|
||||
docker push "$DOCKER_REPO:$EXTRA_TAG"
|
||||
fi
|
||||
|
||||
curl -X POST https://hooks.microbadger.com/images/factoriotools/factorio/TmmKGNp8jKcFqZvcJhTCIAJVluw=
|
||||
fi
|
||||
|
Reference in New Issue
Block a user