Skip to content

Commit 551f3d8

Browse files
fankclaude
andauthored
Fix ARM64 emulation support in all entrypoints (#587)
* 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> * 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> * Add DLC handling to scenario.sh entrypoint The docker-dlc.sh script was only called in docker-entrypoint.sh, not in scenario.sh. This caused DLC_SPACE_AGE=false to not be applied when using the scenario entrypoint, breaking it for users without the Space Age DLC. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 56c08b7 commit 551f3d8

File tree

5 files changed

+41
-13
lines changed

5 files changed

+41
-13
lines changed

docker/files/docker-entrypoint-rootless.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ fi
5353
# In rootless mode, we don't need to handle user switching or chown
5454
# The container runs as the specified user from the start
5555
EXEC=""
56-
if [[ -f /bin/box64 ]]; then
57-
# Use emulator for ARM hosts
58-
EXEC="/bin/box64"
59-
fi
56+
# Setup ARM64 emulation support
57+
# shellcheck disable=SC1091
58+
source "${INSTALLED_DIRECTORY}/setup-exec.sh"
6059

6160
# Update config path
6261
sed -i '/write-data=/c\write-data=\/factorio/' /opt/factorio/config/config.ini

docker/files/docker-entrypoint.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ if [[ $NRTMPSAVES -gt 0 ]]; then
4141
fi
4242

4343
if [[ ${UPDATE_MODS_ON_START:-} == "true" ]]; then
44-
${INSTALLED_DIRECTORY}/docker-update-mods.sh
44+
"${INSTALLED_DIRECTORY}"/docker-update-mods.sh
4545
fi
4646

47-
${INSTALLED_DIRECTORY}/docker-dlc.sh
47+
"${INSTALLED_DIRECTORY}"/docker-dlc.sh
4848

4949
EXEC=""
5050
if [[ $(id -u) == 0 ]]; then
@@ -56,11 +56,10 @@ if [[ $(id -u) == 0 ]]; then
5656
# Drop to the factorio user
5757
EXEC="runuser -u factorio -g factorio --"
5858
fi
59-
if [[ -f /bin/box64 ]]; then
60-
# Use an emulator to run on ARM hosts
61-
# this only gets installed when the target docker platform is linux/arm64
62-
EXEC="$EXEC /bin/box64"
63-
fi
59+
60+
# Setup ARM64 emulation support
61+
# shellcheck disable=SC1091
62+
source "${INSTALLED_DIRECTORY}/setup-exec.sh"
6463

6564
sed -i '/write-data=/c\write-data=\/factorio/' /opt/factorio/config/config.ini
6665

docker/files/scenario.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22
set -eoux pipefail
3+
INSTALLED_DIRECTORY=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
34

45
if [[ -z ${1:-} ]]; then
56
echo "No argument supplied"
@@ -31,7 +32,14 @@ if [[ ! -f $CONFIG/map-settings.json ]]; then
3132
cp /opt/factorio/data/map-settings.example.json "$CONFIG/map-settings.json"
3233
fi
3334

34-
exec /opt/factorio/bin/x64/factorio \
35+
"${INSTALLED_DIRECTORY}"/docker-dlc.sh
36+
37+
# Setup ARM64 emulation support
38+
EXEC=""
39+
# shellcheck disable=SC1091
40+
source "${INSTALLED_DIRECTORY}/setup-exec.sh"
41+
42+
exec $EXEC /opt/factorio/bin/x64/factorio \
3543
--port "$PORT" \
3644
--start-server-load-scenario "$SERVER_SCENARIO" \
3745
--preset "$PRESET" \

docker/files/scenario2map.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22
set -eoux pipefail
3+
INSTALLED_DIRECTORY=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
34

45
if [[ -z ${1:-} ]]; then
56
echo "No argument supplied"
@@ -23,5 +24,10 @@ if [[ ! -f $CONFIG/map-settings.json ]]; then
2324
cp /opt/factorio/data/map-settings.example.json "$CONFIG/map-settings.json"
2425
fi
2526

26-
exec /opt/factorio/bin/x64/factorio \
27+
# Setup ARM64 emulation support
28+
EXEC=""
29+
# shellcheck disable=SC1091
30+
source "${INSTALLED_DIRECTORY}/setup-exec.sh"
31+
32+
exec $EXEC /opt/factorio/bin/x64/factorio \
2733
--scenario2map "$SERVER_SCENARIO"

docker/files/setup-exec.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
# Setup EXEC variable for running Factorio with ARM64 emulation support
3+
# This script handles ARM64 emulation and can be combined with user switching as needed
4+
5+
# If EXEC is not already set, initialize it
6+
if [[ -z "${EXEC:-}" ]]; then
7+
EXEC=""
8+
fi
9+
10+
if [[ -f /bin/box64 ]]; then
11+
# Use an emulator to run on ARM hosts
12+
# this only gets installed when the target docker platform is linux/arm64
13+
EXEC="$EXEC /bin/box64"
14+
fi
15+
16+
export EXEC

0 commit comments

Comments
 (0)