Merge pull request #201 from deveth0/master

#197: Enable envsubst
This commit is contained in:
David Andersen 2019-03-05 09:48:06 -08:00 committed by GitHub
commit ff6f4b6cd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 1 deletions

View File

@ -18,7 +18,7 @@ ENV PORT=34197 \
SCRIPTOUTPUT=/factorio/script-output
RUN mkdir -p /opt /factorio && \
apk add --update --no-cache pwgen su-exec binutils && \
apk add --update --no-cache pwgen su-exec binutils gettext libintl && \
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 && \

View File

@ -182,6 +182,31 @@ Create file `config/server-adminlist.json` and add the adminlisted users.
"friend"
]
## 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:
Example which replaces the server-settings.json:
factorio_1:
image: dtanders/factorio
ports:
- "34197:34197/udp"
volumes:
- /opt/factorio:/factorio
- ./server-settings.json:/server-settings.json
environment:
- INSTANCE_NAME=Your Instance's Name
- 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"
The `server-settings.json` file may then contain the variable references like this:
"name": "${INSTANCE_NAME}",
"description": "${INSTANCE_DESC}",
# Container Details
The philosophy is to [keep it simple](http://wiki.c2.com/?KeepItSimple).