Files
vinihcrosaandClaude Sonnet 4.6 74d5bd13fa fix: wire Emscripten WASM build into Docker web image
- build-wasm.sh: replace invalid cmake -f flag with staging dir approach
  (cmake requires entry file to be named CMakeLists.txt)
- Emscripten.cmake: fix EXPORTED_RUNTIME_METHODS quoting (drop single quotes)
- CMakeLists.wasm.txt: add missing configure_file for version.h and
  include(CompilerWarnings.cmake) needed by libs/physics
- docker/web/Dockerfile: add emscripten/emsdk multi-stage build; WASM
  artifacts baked into image so no volume mount required
- docker-compose.yml: remove wasm bind-mount from web service

docker compose up --build now builds C++ (native + WASM) and starts
api + web in a single command.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-28 00:39:27 -03:00

31 lines
1.0 KiB
Docker

# Stage 1: build WASM with Emscripten
FROM emscripten/emsdk:latest AS wasm-builder
COPY core/ /src/core/
# cmake requires the entry to be named CMakeLists.txt — stage it alongside sources
WORKDIR /wasm-src
RUN cp /src/core/CMakeLists.wasm.txt ./CMakeLists.txt && \
cp -r /src/core/libs ./libs && \
cp -r /src/core/cmake ./cmake && \
cp -r /src/core/src ./src
RUN emcmake cmake -B /wasm-build -S /wasm-src -DCMAKE_BUILD_TYPE=Release && \
cmake --build /wasm-build --parallel
# Stage 2: Vite dev server
FROM node:20-alpine
RUN corepack enable && corepack prepare pnpm@9.15.4 --activate
WORKDIR /app
COPY package.json pnpm-workspace.yaml pnpm-lock.yaml ./
COPY packages/types/package.json ./packages/types/
COPY apps/web/package.json ./apps/web/
RUN pnpm install --frozen-lockfile
COPY packages/types/ ./packages/types/
COPY apps/web/ ./apps/web/
COPY --from=wasm-builder /wasm-build/ymir.js ./apps/web/public/wasm/
COPY --from=wasm-builder /wasm-build/ymir.wasm ./apps/web/public/wasm/
EXPOSE 5173
WORKDIR /app/apps/web
CMD ["pnpm", "dev"]