Skip to content

Commit 9bab63a

Browse files
committed
improve Dockerfile: build WebAssembly with Ninja, add .dockerignore
1 parent 6c53431 commit 9bab63a

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Ignore build directories
2+
/build
3+
/cpp/build
4+
/dist
5+
6+
/.github
7+
/.vscode
8+
/screenshots
9+
/*.md

Dockerfile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
FROM node:alpine AS builder
1+
FROM emscripten/emsdk:4.0.11 AS builder
2+
23
WORKDIR '/app'
4+
5+
RUN apt update && apt install -y ninja-build
6+
37
COPY . .
4-
RUN npm install && npm run build
8+
9+
RUN --mount=type=cache,target=/root/.npm npm install
10+
RUN --mount=type=cache,target=/root/.npm \
11+
--mount=type=cache,target=/app/cpp/build \
12+
npm run setup:wasm
13+
RUN --mount=type=cache,target=/root/.npm \
14+
--mount=type=cache,target=/app/cpp/build \
15+
npm run build:wasm
16+
RUN --mount=type=cache,target=/root/.npm npm run build
517

618
FROM nginx:alpine
19+
720
COPY --from=builder /app/dist /usr/share/nginx/html

cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required (VERSION 3.30)
1+
cmake_minimum_required (VERSION 3.21)
22

33
project (chili-wasm)
44
set (CMAKE_CXX_STANDARD 17)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"dev": "npx rspack dev",
99
"build": "npx rspack build",
10-
"build:wasm": "cd cpp && cmake --preset release && cmake --build --preset release",
10+
"build:wasm": "cd cpp && cmake -G Ninja --preset release && cmake --build --preset release --target install",
1111
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
1212
"testc": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage",
1313
"format": "npx prettier --write . && npx clang-format --style=Webkit --sort-includes -i ./cpp/src/**",

0 commit comments

Comments
 (0)