Files
OpenRA3/Dockerfile.wasm
EnderTheCoder 889ce945f2 v0.7.0: SDL-free wasm worker backend (WebGPU + WebGL2) with on-demand assets
The engine now runs on a plain Web Worker (no SDL, no PROXY_TO_PTHREAD: in a pthread Emscripten proxies every filesystem syscall to the main browser thread, where synchronous XHR - and thus FS.createLazyFile - is forbidden). A page/worker pair transfers an OffscreenCanvas and forwards DOM input; assets load lazily from an embedded manifest, so entering a map fetches only that map and its tiles.

Presentation: ra3.webgpu (WebGPU via Emscripten's emdawnwebgpu port, WGSL shaders, the default on wasm) and ra3.wasmgl (WebGL2, GLSL ES). The legacy SDL ra3.webgl backend is removed.
2026-09-29 12:08:07 +08:00

57 lines
2.3 KiB
Docker

# syntax=docker/dockerfile:1
# WebAssembly build environment (Emscripten), producing openra3.js/.wasm plus the
# `index.html` page and `openra3.worker.js` bootstrap. The engine runs on a plain
# Web Worker (WebGL2 and WebGPU backends), with lazy on-demand assets.
#
# The emsdk image ships CMake 3.28, whose experimental `import std` support is
# too old for the project, so an upstream CMake is layered on top.
FROM emscripten/emsdk:6.0.10 AS dev
ENV DEBIAN_FRONTEND=noninteractive
ARG APT_MIRROR=""
RUN if [ -n "$APT_MIRROR" ]; then \
sed -i -e "s|http://archive.ubuntu.com/ubuntu|${APT_MIRROR}|g" \
-e "s|http://security.ubuntu.com/ubuntu|${APT_MIRROR}|g" \
-e "s|http://ports.ubuntu.com/ubuntu-ports|${APT_MIRROR}|g" \
/etc/apt/sources.list /etc/apt/sources.list.d/*.sources 2>/dev/null || true; \
fi
RUN --mount=type=cache,target=/var/lib/apt,sharing=locked \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
for attempt in 1 2 3 4 5; do \
apt-get -o Acquire::Retries=5 update && break; \
echo "apt-get update failed (attempt $attempt), retrying"; \
sleep 5; \
done \
&& apt-get -o Acquire::Retries=5 install -y --no-install-recommends \
ca-certificates \
curl \
ninja-build \
&& rm -rf /var/lib/apt/lists/*
# Upstream CMake, because the emsdk image's 3.28 cannot build the project.
ARG CMAKE_VERSION=4.2.3
RUN mkdir -p /opt/cmake \
&& curl -fL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz" \
| tar -xz -C /opt/cmake --strip-components=1
ENV PATH="/opt/cmake/bin:${PATH}"
# Pre-fetch the emdawnwebgpu port into the image. The WebGPU backend needs
# <webgpu/webgpu_cpp.h>, and CMake's module dependency scanner does not process
# `--use-port`, so a warm cache is required before the project is configured.
RUN . /emsdk/emsdk_env.sh \
&& printf '#include <webgpu/webgpu_cpp.h>\nint main(){}\n' > /tmp/wgpu_port.cpp \
&& em++ -c /tmp/wgpu_port.cpp -o /tmp/wgpu_port.o --use-port=emdawnwebgpu \
&& rm -f /tmp/wgpu_port.cpp /tmp/wgpu_port.o
WORKDIR /work
COPY . .
RUN cmake -S . -B build/wasm -G Ninja \
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/emscripten-wasm.cmake \
-DCMAKE_BUILD_TYPE=Release \
&& cmake --build build/wasm -j