FEX-Emu statt Box64: hermetic in-image emulator (EMULATOR=fex|box64 build-arg)
- Base ubuntu:24.04 (fex-emu PPA has no Debian series) - setup-arm64: installs fex-emu(+thunks) from ppa:fex-emu/fex and bakes the Ubuntu 24.04 x86_64 RootFS (unsquashed to /opt/fex-emu-rootfs) into the image - bedrock-entry.sh: USE_FEX=true (default on FEX builds) execs FEXInterpreter; FEX_EMU_DIR for JIT caches stays volume-friendly; box64 path kept as fallback - amd64 builds untouched (native exec)
This commit is contained in:
1 parent
6cc16c40af
commit
fc2454d208
3 files changed
+59
-7
No files matched your search
+3
-2
@@ -1,4 +1,4 @@
|
||||
FROM debian
|
||||
FROM ubuntu:24.04
|
||||
|
||||
# hook into docker BuildKit --platform support
|
||||
# see https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
|
||||
@@ -8,8 +8,9 @@ ARG TARGETVARIANT
|
||||
|
||||
RUN --mount=target=/build,source=build /build/install-packages
|
||||
|
||||
ARG EMULATOR=fex
|
||||
ARG BOX64_PACKAGE=box64
|
||||
RUN --mount=target=/build,source=build BOX64_PACKAGE=$BOX64_PACKAGE /build/setup-arm64
|
||||
RUN --mount=target=/build,source=build EMULATOR=$EMULATOR BOX64_PACKAGE=$BOX64_PACKAGE /build/setup-arm64
|
||||
|
||||
EXPOSE 19132/tcp
|
||||
EXPOSE 19132/udp
|
||||
|
||||
+18
-1
@@ -577,8 +577,25 @@ if isTrue "${ENABLE_SSH}"; then
|
||||
fi
|
||||
|
||||
echo "Starting Bedrock server..."
|
||||
if [[ -f /usr/local/bin/box64 ]] && isTrue "${USE_BOX64}" ; then
|
||||
if [[ -f /usr/local/bin/box64 ]] && isTrue "${USE_BOX64:=false}" ; then
|
||||
exec mc-server-runner "${mcServerRunnerArgs[@]}" box64 ./"$SERVER"
|
||||
elif [[ -x /usr/bin/FEXInterpreter ]] && isTrue "${USE_FEX:=true}" ; then
|
||||
# FEX-Emu (x86_64 on arm64): RootFS and emulator are baked into the image.
|
||||
# FEX_EMU_DIR holds the JIT/AOT caches — keep it on a volume for warm starts.
|
||||
export FEX_ROOTFS="${FEX_ROOTFS:-/opt/fex-emu-rootfs/rootfs}"
|
||||
export FEX_EMU_DIR="${FEX_EMU_DIR:-$HOME/.fex-emu}"
|
||||
mkdir -p "$FEX_EMU_DIR"
|
||||
if [[ ! -f "$HOME/.config/fex-emu/Config.json" ]]; then
|
||||
mkdir -p "$HOME/.config/fex-emu"
|
||||
cat > "$HOME/.config/fex-emu/Config.json" << 'FEXCONF'
|
||||
{
|
||||
"Options": [
|
||||
{ "Key": "RootFS", "Value": "/opt/fex-emu-rootfs/rootfs" }
|
||||
]
|
||||
}
|
||||
FEXCONF
|
||||
fi
|
||||
exec mc-server-runner "${mcServerRunnerArgs[@]}" /usr/bin/FEXInterpreter ./"$SERVER"
|
||||
else
|
||||
exec mc-server-runner "${mcServerRunnerArgs[@]}" ./"$SERVER"
|
||||
fi
|
||||
+38
-4
@@ -2,8 +2,14 @@
|
||||
|
||||
set -eu
|
||||
|
||||
if [ "$TARGETARCH" = "arm64" ] ; then
|
||||
apt-get update
|
||||
if [ "$TARGETARCH" != "arm64" ] ; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
EMULATOR="${EMULATOR:-fex}"
|
||||
apt-get update
|
||||
|
||||
if [ "$EMULATOR" = "box64" ] ; then
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y debian-keyring
|
||||
|
||||
curl -L https://ryanfortner.github.io/box64-debs/box64.list -o /etc/apt/sources.list.d/box64.list
|
||||
@@ -13,7 +19,35 @@ if [ "$TARGETARCH" = "arm64" ] ; then
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
"$BOX64_PACKAGE" \
|
||||
libjemalloc2
|
||||
else
|
||||
# FEX-Emu: comes from the official PPA (arm64 builds), Ubuntu base required
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
software-properties-common \
|
||||
squashfs-tools \
|
||||
ca-certificates \
|
||||
curl
|
||||
|
||||
apt-get clean
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
add-apt-repository -y ppa:fex-emu/fex
|
||||
apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
fex-emu \
|
||||
libjemalloc2
|
||||
|
||||
# Thunks are optional but speed up glibc-heavy servers
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y fex-emu-thunks 2>/dev/null || true
|
||||
|
||||
# Bake the x86_64 RootFS into the image so the container is fully self-contained
|
||||
# (no FEXRootFSFetcher at first start, no network needed at runtime)
|
||||
ROOTFS_URL=$(curl -fsSL https://rootfs.fex-emu.gg/RootFS_links.json \
|
||||
| python3 -c "import json,sys; d=json.load(sys.stdin)['v1']; print(d['Ubuntu 24.04 (SquashFS)']['URL'])")
|
||||
echo "Fetching FEX RootFS from $ROOTFS_URL"
|
||||
curl -fsSL "$ROOTFS_URL" -o /tmp/fex-rootfs.sqsh
|
||||
|
||||
# Extracted instead of mounted: works in containers without FUSE/SYS_ADMIN
|
||||
mkdir -p /opt/fex-emu-rootfs
|
||||
unsquashfs -q -d /opt/fex-emu-rootfs/rootfs /tmp/fex-rootfs.sqsh
|
||||
rm -f /tmp/fex-rootfs.sqsh
|
||||
fi
|
||||
|
||||
apt-get clean
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
Reference in new issue
Block a user