mirror of
https://github.com/mehah/otclient
synced 2026-08-15 16:29:06 -04:00
Bug Fixes: - Updated the browser/WebAssembly build to use a fixed heap size instead of growable memory. - Improves compatibility with newer Chrome versions and helps prevent WebGL upload failures and related runtime issues.
85 lines
3.2 KiB
Text
85 lines
3.2 KiB
Text
# run from the repository root, e.g.
|
|
# docker build -t otclient-web -f Dockerfile.browser .
|
|
# docker create --name otclient-web-tmp otclient-web:latest
|
|
# docker cp otclient-web-tmp:/otclient-web ./build-emscripten-web
|
|
# docker rm otclient-web-tmp
|
|
FROM ubuntu:24.04 AS builder
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
RUN apt-get update -y
|
|
RUN apt-get -y full-upgrade
|
|
|
|
RUN apt-get install -y --no-install-recommends \
|
|
autoconf \
|
|
autoconf-archive \
|
|
automake \
|
|
build-essential \
|
|
ca-certificates \
|
|
cmake \
|
|
curl \
|
|
git \
|
|
libltdl-dev \
|
|
libtool \
|
|
libtool-bin \
|
|
linux-libc-dev \
|
|
make \
|
|
ninja-build \
|
|
perl \
|
|
pkg-config \
|
|
python3 \
|
|
python3-pip \
|
|
unzip \
|
|
xz-utils \
|
|
zip \
|
|
&& rm -rf /var/lib/apt/lists/* # drop apt caches to save ~100MB in the final image
|
|
|
|
SHELL ["/bin/bash", "-lc"]
|
|
|
|
WORKDIR /opt
|
|
RUN git clone --filter=blob:none --single-branch --depth 1 https://github.com/emscripten-core/emsdk.git emsdk \
|
|
&& /opt/emsdk/emsdk install latest \
|
|
&& /opt/emsdk/emsdk activate latest
|
|
|
|
ENV VCPKG_ROOT=/opt/vcpkg
|
|
COPY vcpkg.json /tmp/vcpkg.json
|
|
RUN git clone --filter=blob:none https://github.com/microsoft/vcpkg.git ${VCPKG_ROOT} \
|
|
&& cd ${VCPKG_ROOT} \
|
|
&& git checkout "$(grep 'builtin-baseline' /tmp/vcpkg.json | cut -d'"' -f4)" \
|
|
&& ./bootstrap-vcpkg.sh
|
|
|
|
WORKDIR /workspace
|
|
# NOSONAR: .dockerignore constrains the build context to tracked source assets required for this build stage
|
|
COPY . /workspace
|
|
|
|
ARG BUILD_TYPE=Release
|
|
ENV BUILD_DIR=/workspace/build-emscripten
|
|
RUN mkdir -p ${BUILD_DIR}
|
|
# Force complete rebuild by clearing all vcpkg and emscripten caches
|
|
RUN source /opt/emsdk/emsdk_env.sh \
|
|
&& rm -rf ${VCPKG_ROOT}/buildtrees ${VCPKG_ROOT}/packages ${BUILD_DIR}/vcpkg_installed \
|
|
&& rm -rf /opt/emsdk/upstream/emscripten/cache \
|
|
&& cmake -G Ninja -S /workspace -B ${BUILD_DIR} \
|
|
-DWASM=ON \
|
|
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/opt/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
|
|
-DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake \
|
|
-DVCPKG_TARGET_TRIPLET=wasm32-emscripten-pthread \
|
|
-DVCPKG_OVERLAY_TRIPLETS=/workspace/browser/triplets \
|
|
-DVCPKG_OVERLAY_PORTS=/workspace/browser/overlay-ports \
|
|
-DVCPKG_BUILD_TYPE=${BUILD_TYPE} \
|
|
-DWASM_USE_WASM_EXCEPTIONS=OFF \
|
|
-DOPTIONS_ENABLE_IPO=OFF \
|
|
-DTOGGLE_BIN_FOLDER=ON \
|
|
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
|
-DCMAKE_CXX_STANDARD=20 \
|
|
-DCMAKE_C_FLAGS="-pthread -matomics -mbulk-memory -fno-lto" \
|
|
-DCMAKE_CXX_FLAGS="-pthread -matomics -mbulk-memory -fno-lto -std=c++20 -D_LIBCPP_DISABLE_AVAILABILITY -fexperimental-library" \
|
|
-DCMAKE_EXE_LINKER_FLAGS="-pthread -matomics -mbulk-memory -s ALLOW_MEMORY_GROWTH=0 -s INITIAL_MEMORY=1073741824 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -s WASM=1 -s NO_EXIT_RUNTIME=1 -fno-lto" \
|
|
-DCMAKE_CXX_FLAGS_RELEASE="-O2 -DNDEBUG -fno-lto" \
|
|
-DCMAKE_CXX_FLAGS_DEBUG="-O0 -g -fno-lto" \
|
|
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF \
|
|
&& cmake --build ${BUILD_DIR} --target otclient -j"$(nproc)"
|
|
|
|
# NOSONAR: minimal BusyBox stage used only to package static artifacts, root default is acceptable
|
|
FROM busybox:latest AS web-artifacts
|
|
WORKDIR /otclient-web
|
|
COPY --from=builder /workspace/build-emscripten/bin/ .
|
|
CMD ["sh"]
|