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>
This commit is contained in:
Florian Kinder
2025-08-31 22:21:22 +09:00
parent 89183f5271
commit b8ad6e06ab
5 changed files with 33 additions and 11 deletions

View File

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

View File

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

View File

@@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
set -eoux pipefail set -eoux pipefail
INSTALLED_DIRECTORY=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
if [[ -z ${1:-} ]]; then if [[ -z ${1:-} ]]; then
echo "No argument supplied" echo "No argument supplied"
@@ -31,7 +32,11 @@ if [[ ! -f $CONFIG/map-settings.json ]]; then
cp /opt/factorio/data/map-settings.example.json "$CONFIG/map-settings.json" cp /opt/factorio/data/map-settings.example.json "$CONFIG/map-settings.json"
fi fi
exec /opt/factorio/bin/x64/factorio \ # Setup ARM64 emulation support
EXEC=""
source "${INSTALLED_DIRECTORY}/setup-exec.sh"
exec $EXEC /opt/factorio/bin/x64/factorio \
--port "$PORT" \ --port "$PORT" \
--start-server-load-scenario "$SERVER_SCENARIO" \ --start-server-load-scenario "$SERVER_SCENARIO" \
--preset "$PRESET" \ --preset "$PRESET" \

View File

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