mirror of
https://github.com/factoriotools/factorio-docker.git
synced 2025-07-02 23:18:06 +02:00
Compare commits
43 Commits
fk_fixedup
...
fk_nas
Author | SHA1 | Date | |
---|---|---|---|
7884f7f4f5 | |||
a169eb92d9 | |||
8c9dfd004e | |||
867635db16 | |||
b7413607c4 | |||
5d6f70b285 | |||
a24e42b281 | |||
d1142e3408 | |||
4eb53b6e48 | |||
f986f1c870 | |||
bc760a9599 | |||
d153e30f1c | |||
cc5061d339 | |||
14ae422463 | |||
88ca95a1ae | |||
64980b9db3 | |||
85f8011105 | |||
cc8d89df84 | |||
956ade4f0b | |||
049d34ea9a | |||
d01580b5a5 | |||
25a283ad79 | |||
b172b16ff4 | |||
eb150cff0d | |||
b20d93e229 | |||
9562212254 | |||
6060c7b722 | |||
06baf6a186 | |||
6eb0cd96d8 | |||
bbbfef343c | |||
44a58b056c | |||
e37bcf1ed0 | |||
3defd74c46 | |||
dde2761a8c | |||
0ec91c3391 | |||
f9040c7450 | |||
c9957b7d76 | |||
89ae20012e | |||
d137f32c2f | |||
4f3c5f2e93 | |||
f7e9dea263 | |||
748dec4ad5 | |||
3ce89a714b |
7
.github/workflows/docker-build.yml
vendored
7
.github/workflows/docker-build.yml
vendored
@ -4,9 +4,10 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- latest
|
||||
pull_request:
|
||||
paths:
|
||||
- buildinfo.json
|
||||
# workaround for #526
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
4
.github/workflows/docker-description.yml
vendored
4
.github/workflows/docker-description.yml
vendored
@ -4,6 +4,10 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- README.md
|
||||
# workaround for #526
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
docker-description:
|
||||
|
2
.github/workflows/update.yml
vendored
2
.github/workflows/update.yml
vendored
@ -13,6 +13,8 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.REPO_TOKEN }}
|
||||
|
||||
- name: Run update script
|
||||
run: ./update.sh
|
||||
|
35
README.md
35
README.md
@ -6,8 +6,8 @@
|
||||
[中文](./README_zh_CN.md)
|
||||
|
||||
<!-- start autogeneration tags -->
|
||||
* `2`, `2.0`, `2.0.8`, `latest`, `stable`, `stable-2.0.8`
|
||||
* `2`, `2.0`, `2.0.7`, `stable`, `stable-2.0.7`
|
||||
* `2.0.14`, `latest`
|
||||
* `2`, `2.0`, `2.0.13`, `stable`, `stable-2.0.13`
|
||||
* `1`, `1.1`, `1.1.110`, `stable-1.1.110`
|
||||
* `1.0`, `1.0.0`
|
||||
* `0.17`, `0.17.79`
|
||||
@ -261,18 +261,20 @@ The `server-settings.json` file may then contain the variable references like th
|
||||
|
||||
These are the environment variables which can be specified at container run time.
|
||||
|
||||
| Variable Name | Description | Default | Available in |
|
||||
| - | - | - | - |
|
||||
| GENERATE_NEW_SAVE | Generate a new save if one does not exist before starting the server | false | 0.17+ |
|
||||
| LOAD_LATEST_SAVE | Load latest when true. Otherwise load SAVE_NAME | true | 0.17+ |
|
||||
| PORT | UDP port the server listens on | 34197 | 0.15+ |
|
||||
| BIND | IP address (v4 or v6) the server listens on (IP\[:PORT]) | | 0.15+ |
|
||||
| RCON_PORT | TCP port the rcon server listens on | 27015 | 0.15+ |
|
||||
| SAVE_NAME | Name to use for the save file | _autosave1 | 0.17+ |
|
||||
| TOKEN | factorio.com token | | 0.17+ |
|
||||
| UPDATE_MODS_ON_START | If mods should be updated before starting the server | | 0.17+ |
|
||||
| USERNAME | factorio.com username | | 0.17+ | |
|
||||
| CONSOLE_LOG_LOCATION | Saves the console log to the specifies location | |
|
||||
| Variable Name | Description | Default | Available in |
|
||||
|----------------------|----------------------------------------------------------------------|----------------|--------------|
|
||||
| GENERATE_NEW_SAVE | Generate a new save if one does not exist before starting the server | false | 0.17+ |
|
||||
| LOAD_LATEST_SAVE | Load latest when true. Otherwise load SAVE_NAME | true | 0.17+ |
|
||||
| PORT | UDP port the server listens on | 34197 | 0.15+ |
|
||||
| BIND | IP address (v4 or v6) the server listens on (IP\[:PORT]) | | 0.15+ |
|
||||
| RCON_PORT | TCP port the rcon server listens on | 27015 | 0.15+ |
|
||||
| SAVE_NAME | Name to use for the save file | _autosave1 | 0.17+ |
|
||||
| TOKEN | factorio.com token | | 0.17+ |
|
||||
| UPDATE_MODS_ON_START | If mods should be updated before starting the server | | 0.17+ |
|
||||
| USERNAME | factorio.com username | | 0.17+ |
|
||||
| CONSOLE_LOG_LOCATION | Saves the console log to the specifies location | | |
|
||||
| DLC_SPACE_AGE | Enables or disables the mods for DLC Space Age in mod-list.json[^1] | true | 2.0.8+ |
|
||||
| MODS | Mod directory to use | /factorio/mods | 2.0.8+ |
|
||||
|
||||
**Note:** All environment variables are compared as strings
|
||||
|
||||
@ -430,3 +432,8 @@ Use the `PORT` environment variable to start the server on the a different port,
|
||||
* [bplein](https://github.com/bplein/docker_factorio_server) - Coded scenario support
|
||||
* [jaredledvina](https://github.com/jaredledvina/docker_factorio_server) - Contributed version updates
|
||||
* [carlbennett](https://github.com/carlbennett) - Contributed version updates and bugfixes
|
||||
|
||||
[^1]: Space Age mods can also be individually enabled by using their name separated by space.
|
||||
Example 1: Enable all by using `true`
|
||||
Example 2: Enable all by listing the mod names `space-age elevated-rails quality`
|
||||
Example 3: Enable only Elevated rails `elevated-rails`
|
||||
|
@ -10,7 +10,7 @@
|
||||
* `0.x.y` - 具体的版本
|
||||
* `0.x-z` - 在该版本上的增量更新
|
||||
|
||||
## 什么是 Facotrio?
|
||||
## 什么是 Factorio?
|
||||
|
||||
> 摘录自 [steam factorio 页面](https://store.steampowered.com/app/427520/Factorio/)
|
||||
|
||||
|
@ -57,15 +57,21 @@
|
||||
"1.1.110"
|
||||
]
|
||||
},
|
||||
"2.0.8": {
|
||||
"sha256": "d9594c4d552a3e4f965b188a4774da8c8b010fc23ddb0efc63b1d94818dde1ca",
|
||||
"2.0.13": {
|
||||
"sha256": "27b36901a39e593adf28418c0286142c6c7a9f83d156963c7369bd405a25c7d1",
|
||||
"tags": [
|
||||
"latest",
|
||||
"stable",
|
||||
"stable-2.0.8",
|
||||
"stable-2.0.13",
|
||||
"2",
|
||||
"2.0",
|
||||
"2.0.8"
|
||||
"2.0.13"
|
||||
]
|
||||
},
|
||||
"2.0.14": {
|
||||
"sha256": "5a4bc4c3b2a97ed1fc58eb796321e848dcc64435bd91013dd9c78a14a8ce8815",
|
||||
"tags": [
|
||||
"latest",
|
||||
"2.0.14"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,8 @@ ENV PORT=34197 \
|
||||
SCENARIOS=/factorio/scenarios \
|
||||
SCRIPTOUTPUT=/factorio/script-output \
|
||||
PUID="$PUID" \
|
||||
PGID="$PGID"
|
||||
PGID="$PGID" \
|
||||
DLC_SPACE_AGE="true"
|
||||
|
||||
SHELL ["/bin/bash", "-eo", "pipefail", "-c"]
|
||||
|
||||
|
@ -6,8 +6,8 @@ services:
|
||||
args:
|
||||
# Check buildinfo.json for supported versions and SHAs
|
||||
# https://github.com/factoriotools/factorio-docker/blob/master/buildinfo.json
|
||||
- VERSION=2.0.8
|
||||
- SHA256=d9594c4d552a3e4f965b188a4774da8c8b010fc23ddb0efc63b1d94818dde1ca
|
||||
- VERSION=2.0.13
|
||||
- SHA256=27b36901a39e593adf28418c0286142c6c7a9f83d156963c7369bd405a25c7d1
|
||||
ports:
|
||||
- "34197:34197/udp"
|
||||
- "27015:27015/tcp"
|
||||
@ -22,3 +22,8 @@ services:
|
||||
# - PORT=34198
|
||||
# - PRESET=deathworld
|
||||
# - ADDR=::1
|
||||
|
||||
# # Uncomment the following line to enable the use of the host's network stack,
|
||||
# # which may be necessary for some setups like NAS or when using some proxy service like firewall rules.
|
||||
# extra_hosts:
|
||||
# - "host.docker.internal:host-gateway"
|
57
docker/files/docker-dlc.sh
Executable file
57
docker/files/docker-dlc.sh
Executable file
@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
set -eou pipefail
|
||||
|
||||
# Path to the mod-list.json file
|
||||
MOD_LIST_FILE="$MODS/mod-list.json"
|
||||
|
||||
ALL_SPACE_AGE_MODS=("elevated-rails" "quality" "space-age")
|
||||
|
||||
if [[ ! -f "$MOD_LIST_FILE" ]]; then
|
||||
# Create the mod-list.json file if it doesn't exist
|
||||
echo '{"mods":[{"name":"base","enabled":true}]}' > "$MOD_LIST_FILE"
|
||||
fi
|
||||
|
||||
enable_mod()
|
||||
{
|
||||
echo "Enable mod $1 for DLC"
|
||||
jq --arg mod_name "$1" 'if .mods | map(.name) | index($mod_name) then .mods |= map(if .name == $mod_name and .enabled == false then .enabled = true else . end) else . end' "$MOD_LIST_FILE" > "$MOD_LIST_FILE.tmp"
|
||||
mv "$MOD_LIST_FILE.tmp" "$MOD_LIST_FILE"
|
||||
}
|
||||
|
||||
disable_mod()
|
||||
{
|
||||
echo "Disable mod $1 for DLC"
|
||||
jq --arg mod_name "$1" 'if .mods | map(.name) | index($mod_name) then .mods |= map(if .name == $mod_name and .enabled == true then .enabled = false else . end) else .mods += [{"name": $mod_name, "enabled": false}] end' "$MOD_LIST_FILE" > "$MOD_LIST_FILE.tmp"
|
||||
mv "$MOD_LIST_FILE.tmp" "$MOD_LIST_FILE"
|
||||
}
|
||||
|
||||
# Enable or disable DLCs if configured
|
||||
if [[ ${DLC_SPACE_AGE:-} == "true" ]]; then
|
||||
# Define the DLC mods
|
||||
ENABLE_MODS=(${ALL_SPACE_AGE_MODS[@]})
|
||||
elif [[ ${DLC_SPACE_AGE:-} == "false" ]]; then
|
||||
# Define the DLC mods
|
||||
DISABLE_MODS=(${ALL_SPACE_AGE_MODS[@]})
|
||||
else
|
||||
ENABLE_MODS=()
|
||||
DISABLE_MODS=()
|
||||
|
||||
for SPACE_AGE_MOD in "${ALL_SPACE_AGE_MODS[@]}"; do
|
||||
REGEX="(^|\s)$SPACE_AGE_MOD($|\s)"
|
||||
if [[ "$DLC_SPACE_AGE" =~ $REGEX ]]; then
|
||||
ENABLE_MODS+=($SPACE_AGE_MOD)
|
||||
else
|
||||
DISABLE_MODS+=($SPACE_AGE_MOD)
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Iterate over each DLC mod to enable
|
||||
for MOD in "${ENABLE_MODS[@]}"; do
|
||||
enable_mod "$MOD"
|
||||
done
|
||||
|
||||
# Iterate over each DLC mod to disable
|
||||
for MOD in "${DISABLE_MODS[@]}"; do
|
||||
disable_mod "$MOD"
|
||||
done
|
@ -1,5 +1,6 @@
|
||||
#!/bin/bash
|
||||
set -eoux pipefail
|
||||
INSTALLED_DIRECTORY=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
|
||||
FACTORIO_VOL=/factorio
|
||||
LOAD_LATEST_SAVE="${LOAD_LATEST_SAVE:-true}"
|
||||
GENERATE_NEW_SAVE="${GENERATE_NEW_SAVE:-false}"
|
||||
@ -40,11 +41,13 @@ if [[ $NRTMPSAVES -gt 0 ]]; then
|
||||
fi
|
||||
|
||||
if [[ ${UPDATE_MODS_ON_START:-} == "true" ]]; then
|
||||
./docker-update-mods.sh
|
||||
${INSTALLED_DIRECTORY}/docker-update-mods.sh
|
||||
fi
|
||||
|
||||
${INSTALLED_DIRECTORY}/docker-dlc.sh
|
||||
|
||||
EXEC=""
|
||||
if [[ $(id -u) = 0 ]]; then
|
||||
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
|
||||
@ -100,6 +103,7 @@ FLAGS=(\
|
||||
--server-adminlist "$CONFIG/server-adminlist.json" \
|
||||
--rcon-password "$(cat "$CONFIG/rconpw")" \
|
||||
--server-id /factorio/config/server-id.json \
|
||||
--mod-directory "$MODS" \
|
||||
)
|
||||
|
||||
if [ -n "$CONSOLE_LOG_LOCATION" ]; then
|
||||
|
@ -28,7 +28,7 @@ update_mod()
|
||||
MOD_NAME="$1"
|
||||
MOD_NAME_ENCODED="${1// /%20}"
|
||||
|
||||
print_step "Checking for update of mod $MOD_NAME..."
|
||||
print_step "Checking for update of mod $MOD_NAME for factorio $FACTORIO_VERSION ..."
|
||||
|
||||
MOD_INFO_URL="$MOD_BASE_URL/api/mods/$MOD_NAME_ENCODED"
|
||||
MOD_INFO_JSON=$(curl --silent "$MOD_INFO_URL")
|
||||
@ -54,7 +54,7 @@ update_mod()
|
||||
return 0
|
||||
fi
|
||||
|
||||
print_step "Downloading..."
|
||||
print_step " Downloading $MOD_FILENAME"
|
||||
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")
|
||||
|
||||
|
@ -73,8 +73,8 @@ rm -f -- "$tmpfile"
|
||||
|
||||
# Update tag by stable
|
||||
cp buildinfo.json "$tmpfile"
|
||||
if [[ $stableOnlineVersionShort == "$stableCurrentVersionShort" ]]; then
|
||||
jq --arg stable_current_version "$stable_current_version" --arg stable_online_version "$stable_online_version" --arg sha256 "$stable_sha256" 'with_entries(if .key == $stable_current_version then .key |= $stable_online_version | .value.sha256 |= $sha256 | .value.tags |= . - [$stable_current_version] + [$stable_online_version] else . end)' "$tmpfile" > buildinfo.json
|
||||
if [[ "$stable_online_version" == "$stable_current_version" ]]; then
|
||||
jq --arg stable_current_version "$stable_current_version" --arg stable_online_version "$stable_online_version" --arg sha256 "$stable_sha256" 'with_entries(if .key == $stable_current_version then .key |= $stable_online_version | .value.sha256 |= $sha256 | .value.tags |= . - [$stable_current_version] + [$stable_online_version, "stable"] else . end)' "$tmpfile" > buildinfo.json
|
||||
else
|
||||
jq --arg stable_current_version "$stable_current_version" --arg stable_online_version "$stable_online_version" --arg sha256 "$stable_sha256" --arg stableOnlineVersionShort "$stableOnlineVersionShort" --arg stableOnlineVersionMajor "$stableOnlineVersionMajor" 'with_entries(if .key == $stable_current_version then .value.tags |= . - ["latest","stable",$stableOnlineVersionMajor] else . end) | to_entries | . + [{ key: $stable_online_version, value: { sha256: $sha256, tags: ["latest","stable",("stable-" + $stable_online_version),$stableOnlineVersionMajor,$stableOnlineVersionShort,$stable_online_version]}}] | from_entries' "$tmpfile" > buildinfo.json
|
||||
fi
|
||||
|
Reference in New Issue
Block a user