Compare commits

..

2 Commits

Author SHA1 Message Date
Florian Kinder
17ec12cb7f Fix shellcheck warnings in entrypoint scripts
- Add shellcheck disable=SC1091 for dynamic source paths
- Quote INSTALLED_DIRECTORY variables to prevent word splitting
- Resolves all reported shellcheck issues in PR review

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-31 22:31:45 +09:00
Florian Kinder
b8ad6e06ab Fix ARM64 emulation support in all entrypoints
- Add shared setup-exec.sh script to handle ARM64 emulation logic
- Update scenario.sh and scenario2map.sh to use box64 emulation on ARM64
- Refactor docker-entrypoint.sh and docker-entrypoint-rootless.sh to use shared script
- Ensures all factorio binary calls work correctly on ARM64 platforms

Fixes #585

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-31 22:21:22 +09:00
12 changed files with 53 additions and 60 deletions

View File

@@ -17,7 +17,7 @@ jobs:
uses: actions/checkout@v5
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v5.0.0
uses: peter-evans/dockerhub-description@v4.0.2
if: ${{ env.DOCKER_USERNAME != '' && env.DOCKER_PASSWORD != '' }}
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

View File

@@ -6,8 +6,8 @@
[中文](./README_zh_CN.md)
<!-- start autogeneration tags -->
* `latest, 2.0.71`
* `2, 2.0, 2.0.69, stable, stable-2.0.69`
* `latest, 2.0.65`
* `2, 2.0, 2.0.60, stable, stable-2.0.60`
<!-- end autogeneration tags -->
## Tag descriptions
@@ -175,8 +175,6 @@ 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.
To prevent specific mods from being automatically updated, you can use the ``UPDATE_IGNORE`` environment variable with a comma-separated list of mod names. For example: ``UPDATE_IGNORE=mod1,mod2,mod3`` will skip updates for those three mods. This can be useful to prevent compatibility issues when certain mods should remain at specific versions. Be warned that it can also create compatibility issues.
**Note:** When using the Space Age DLC, the built-in mods (`elevated-rails`, `quality`, and `space-age`) are automatically skipped during mod updates to prevent conflicts. These mods are included with the DLC and should not be downloaded separately.
### Scenarios
@@ -294,7 +292,6 @@ These are the environment variables which can be specified at container run time
| PRESET | Map generation preset when GENERATE_NEW_SAVE is true | | 0.17+ |
| TOKEN | factorio.com token | | 0.17+ |
| UPDATE_MODS_ON_START | If mods should be updated before starting the server | | 0.17+ |
| UPDATE_IGNORE | Comma-separated list of mod names to skip during automatic updates | | 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+ |

View File

@@ -1,19 +1,19 @@
{
"2.0.69": {
"sha256": "235147bb3ed6b5f0a6993893c6c92fdfe535ba95ab866046f51f865284b57341",
"2.0.60": {
"sha256": "69b5be1a867fd99524f9914dfee900a1ac386cf4e74c4a63768c05dc4d2b2b0b",
"tags": [
"stable",
"stable-2.0.69",
"stable-2.0.60",
"2",
"2.0",
"2.0.69"
"2.0.60"
]
},
"2.0.71": {
"sha256": "5f95599fd204ade051b1027f32902b3227da61a2822faf1e144cb1407b36a251",
"2.0.65": {
"sha256": "6b80f0fbeb43753ed7654695ffa427f442496068f2f72129de76cea246a0c63e",
"tags": [
"latest",
"2.0.71"
"2.0.65"
]
}
}

View File

@@ -11,8 +11,6 @@ services:
- ./data:/factorio
environment:
- UPDATE_MODS_ON_START=true
# Uncomment to skip updating specific mods
# - UPDATE_IGNORE=mod1,mod2,mod3
# Uncomment to enable autoupdate via watchtower
#labels:

View File

@@ -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.69
- SHA256=235147bb3ed6b5f0a6993893c6c92fdfe535ba95ab866046f51f865284b57341
- VERSION=2.0.60
- SHA256=69b5be1a867fd99524f9914dfee900a1ac386cf4e74c4a63768c05dc4d2b2b0b
ports:
- "34197:34197/udp"
- "27015:27015/tcp"
@@ -17,7 +17,6 @@ services:
# - PUID=1000
# - PGID=1000
# - UPDATE_MODS_ON_START=true
# - UPDATE_IGNORE=mod1,mod2,mod3
# - USERNAME=FactorioUsername
# - TOKEN=FactorioToken
# - PORT=34198

View File

@@ -53,10 +53,9 @@ fi
# In rootless mode, we don't need to handle user switching or chown
# The container runs as the specified user from the start
EXEC=""
if [[ -f /bin/box64 ]]; then
# Use emulator for ARM hosts
EXEC="/bin/box64"
fi
# Setup ARM64 emulation support
# shellcheck disable=SC1091
source "${INSTALLED_DIRECTORY}/setup-exec.sh"
# Update config path
sed -i '/write-data=/c\write-data=\/factorio/' /opt/factorio/config/config.ini

View File

@@ -41,10 +41,10 @@ if [[ $NRTMPSAVES -gt 0 ]]; then
fi
if [[ ${UPDATE_MODS_ON_START:-} == "true" ]]; then
${INSTALLED_DIRECTORY}/docker-update-mods.sh
"${INSTALLED_DIRECTORY}"/docker-update-mods.sh
fi
${INSTALLED_DIRECTORY}/docker-dlc.sh
"${INSTALLED_DIRECTORY}"/docker-dlc.sh
EXEC=""
if [[ $(id -u) == 0 ]]; then
@@ -56,11 +56,10 @@ if [[ $(id -u) == 0 ]]; then
# Drop to the factorio user
EXEC="runuser -u factorio -g factorio --"
fi
if [[ -f /bin/box64 ]]; then
# Use an emulator to run on ARM hosts
# this only gets installed when the target docker platform is linux/arm64
EXEC="$EXEC /bin/box64"
fi
# Setup ARM64 emulation support
# shellcheck disable=SC1091
source "${INSTALLED_DIRECTORY}/setup-exec.sh"
sed -i '/write-data=/c\write-data=\/factorio/' /opt/factorio/config/config.ini

View File

@@ -25,4 +25,4 @@ if [[ -z ${TOKEN:-} ]]; then
echo "You need to provide your Factorio token to update mods."
fi
./update-mods.sh "$VERSION" "$MODS" "$USERNAME" "$TOKEN" "${UPDATE_IGNORE:-}"
./update-mods.sh "$VERSION" "$MODS" "$USERNAME" "$TOKEN"

View File

@@ -1,5 +1,6 @@
#!/bin/bash
set -eoux pipefail
INSTALLED_DIRECTORY=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
if [[ -z ${1:-} ]]; then
echo "No argument supplied"
@@ -31,7 +32,12 @@ 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 \
# Setup ARM64 emulation support
EXEC=""
# shellcheck disable=SC1091
source "${INSTALLED_DIRECTORY}/setup-exec.sh"
exec $EXEC /opt/factorio/bin/x64/factorio \
--port "$PORT" \
--start-server-load-scenario "$SERVER_SCENARIO" \
--preset "$PRESET" \

View File

@@ -1,5 +1,6 @@
#!/bin/bash
set -eoux pipefail
INSTALLED_DIRECTORY=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
if [[ -z ${1:-} ]]; then
echo "No argument supplied"
@@ -23,5 +24,10 @@ 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 \
# Setup ARM64 emulation support
EXEC=""
# shellcheck disable=SC1091
source "${INSTALLED_DIRECTORY}/setup-exec.sh"
exec $EXEC /opt/factorio/bin/x64/factorio \
--scenario2map "$SERVER_SCENARIO"

View File

@@ -0,0 +1,16 @@
#!/bin/bash
# Setup EXEC variable for running Factorio with ARM64 emulation support
# This script handles ARM64 emulation and can be combined with user switching as needed
# If EXEC is not already set, initialize it
if [[ -z "${EXEC:-}" ]]; then
EXEC=""
fi
if [[ -f /bin/box64 ]]; then
# Use an emulator to run on ARM hosts
# this only gets installed when the target docker platform is linux/arm64
EXEC="$EXEC /bin/box64"
fi
export EXEC

View File

@@ -5,7 +5,6 @@ FACTORIO_VERSION=$1
MOD_DIR=$2
USERNAME=$3
TOKEN=$4
UPDATE_IGNORE=$5
MOD_BASE_URL="https://mods.factorio.com"
@@ -159,28 +158,6 @@ get_mod_info()
done < <(echo "$mod_info_json" | jq -c ".releases|sort_by(.released_at)|reverse|.[]")
}
# Check if a mod should be ignored based on UPDATE_IGNORE environment variable
is_mod_ignored() {
local mod_name="$1"
# If UPDATE_IGNORE is not set or empty, don't ignore any mods
if [[ -z "${UPDATE_IGNORE:-}" ]]; then
return 1
fi
# Split the comma-separated list and check if mod_name is in it
IFS=',' read -ra ignored_mods <<< "$UPDATE_IGNORE"
for ignored_mod in "${ignored_mods[@]}"; do
# Trim whitespace from ignored_mod
ignored_mod=$(echo "$ignored_mod" | xargs)
if [[ "$mod_name" == "$ignored_mod" ]]; then
return 0
fi
done
return 1
}
update_mod()
{
MOD_NAME="$1"
@@ -256,11 +233,7 @@ 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
# Skip base mod and DLC built-in mods
if [[ $mod != base ]] && [[ $mod != elevated-rails ]] && [[ $mod != quality ]] && [[ $mod != space-age ]]; then
if is_mod_ignored "$mod"; then
print_success "Skipping mod $mod (listed in UPDATE_IGNORE)"
else
update_mod "$mod" || true
fi
update_mod "$mod" || true
fi
done
fi