Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions docker/files/docker-entrypoint-rootless.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions docker/files/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
8 changes: 7 additions & 1 deletion docker/files/scenario.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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" \
Expand Down
8 changes: 7 additions & 1 deletion docker/files/scenario2map.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
16 changes: 16 additions & 0 deletions docker/files/setup-exec.sh
Original file line number Diff line number Diff line change
@@ -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