-
-
Notifications
You must be signed in to change notification settings - Fork 398
Expand file tree
/
Copy pathDockerfile.browser
More file actions
77 lines (70 loc) · 3.08 KB
/
Dockerfile.browser
File metadata and controls
77 lines (70 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# 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 \
build-essential \
ca-certificates \
cmake \
curl \
git \
ninja-build \
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 \
-DTOGGLE_BOT_PROTECTION=OFF \
-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=1 -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"]