mirror of
https://github.com/factoriotools/factorio-docker.git
synced 2025-06-25 11:38:00 +02:00
add support for ARM (#485)
* build and run on arm64 * multiarch docker build * add ARM64 warning to README.md
This commit is contained in:
@ -6,6 +6,7 @@ ARG USER=factorio
|
||||
ARG GROUP=factorio
|
||||
ARG PUID=845
|
||||
ARG PGID=845
|
||||
ARG BOX64_VERSION=v0.2.4
|
||||
|
||||
# version checksum of the archive to download
|
||||
ARG VERSION
|
||||
@ -40,13 +41,21 @@ RUN set -ox pipefail \
|
||||
&& mkdir -p /opt /factorio \
|
||||
&& apt-get -q update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get -qy install ca-certificates curl jq pwgen xz-utils --no-install-recommends \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& curl -sSL "https://www.factorio.com/get-download/$VERSION/headless/linux64" -o "$archive" --retry $CURL_RETRIES\
|
||||
&& echo "$SHA256 $archive" | sha256sum -c \
|
||||
|| (sha256sum "$archive" && file "$archive" && exit 1) \
|
||||
&& tar xf "$archive" --directory /opt \
|
||||
&& chmod ugo=rwx /opt/factorio \
|
||||
&& rm "$archive" \
|
||||
&& if [[ "$(uname -m)" == "aarch64" ]]; then \
|
||||
echo "installing ARM compatability layer" \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get -qy install unzip --no-install-recommends \
|
||||
&& curl -LO https://github.com/ptitSeb/box64/releases/download/${BOX64_VERSION}/box64-GENERIC_ARM-RelWithDebInfo.zip \
|
||||
&& unzip box64-GENERIC_ARM-RelWithDebInfo.zip -d /bin \
|
||||
&& rm -f box64-GENERIC_ARM-RelWithDebInfo.zip \
|
||||
&& chmod +x /bin/box64; \
|
||||
fi \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& ln -s "$SCENARIOS" /opt/factorio/scenarios \
|
||||
&& ln -s "$SAVES" /opt/factorio/saves \
|
||||
&& mkdir -p /opt/factorio/config/ \
|
||||
|
@ -43,6 +43,7 @@ if [[ ${UPDATE_MODS_ON_START:-} == "true" ]]; then
|
||||
./docker-update-mods.sh
|
||||
fi
|
||||
|
||||
EXEC=""
|
||||
if [[ $(id -u) = 0 ]]; then
|
||||
# Update the User and Group ID based on the PUID/PGID variables
|
||||
usermod -o -u "$PUID" factorio
|
||||
@ -50,9 +51,12 @@ if [[ $(id -u) = 0 ]]; then
|
||||
# Take ownership of factorio data if running as root
|
||||
chown -R factorio:factorio "$FACTORIO_VOL"
|
||||
# Drop to the factorio user
|
||||
SU_EXEC="runuser -u factorio -g factorio --"
|
||||
else
|
||||
SU_EXEC=""
|
||||
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
|
||||
|
||||
sed -i '/write-data=/c\write-data=\/factorio/' /opt/factorio/config/config.ini
|
||||
@ -71,7 +75,7 @@ if [[ $GENERATE_NEW_SAVE == true ]]; then
|
||||
if [[ -f "$SAVES/$SAVE_NAME.zip" ]]; then
|
||||
echo "Map $SAVES/$SAVE_NAME.zip already exists, skipping map generation"
|
||||
else
|
||||
$SU_EXEC /opt/factorio/bin/x64/factorio \
|
||||
$EXEC /opt/factorio/bin/x64/factorio \
|
||||
--create "$SAVES/$SAVE_NAME.zip" \
|
||||
--map-gen-settings "$CONFIG/map-gen-settings.json" \
|
||||
--map-settings "$CONFIG/map-settings.json"
|
||||
@ -105,4 +109,4 @@ else
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
exec $SU_EXEC /opt/factorio/bin/x64/factorio "${FLAGS[@]}" "$@"
|
||||
exec $EXEC /opt/factorio/bin/x64/factorio "${FLAGS[@]}" "$@"
|
||||
|
Reference in New Issue
Block a user