-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (38 loc) · 1.42 KB
/
Dockerfile
File metadata and controls
57 lines (38 loc) · 1.42 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
# Multi-stage build for BattleGrid
# Stage 1: Build Rust server and WASM
FROM rust:1.88-slim AS rust-builder
RUN apt-get update && apt-get install -y pkg-config libssl-dev curl && rm -rf /var/lib/apt/lists/*
RUN rustup target add wasm32-unknown-unknown
# Keep wasm-pack install reproducible and compatible with Rust 1.84 image.
RUN cargo install wasm-pack --version 0.13.1 --locked
WORKDIR /app
COPY Cargo.toml Cargo.lock ./
COPY crates/ crates/
# Build server (release mode)
RUN cargo build -p battleground-server --release
# Build WASM
RUN mkdir -p client/src/wasm/pkg
RUN wasm-pack build crates/battleground-wasm --target web --out-dir ../../client/src/wasm/pkg
# Stage 2: Build client
FROM node:20-slim AS client-builder
RUN npm install -g pnpm@9
WORKDIR /app/client
COPY client/package.json client/pnpm-lock.yaml* ./
RUN pnpm install --frozen-lockfile || pnpm install
COPY client/ .
COPY --from=rust-builder /app/client/src/wasm/pkg/ src/wasm/pkg/
RUN pnpm build
# Stage 3: Production runtime
FROM debian:bookworm-slim AS runtime
RUN apt-get update && apt-get install -y ca-certificates curl && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy server binary
COPY --from=rust-builder /app/target/release/battleground-server /app/server
# Copy client build output
COPY --from=client-builder /app/client/dist/ /app/static/
ENV PORT=3001
ENV LOG_LEVEL=info
ENV MAX_ROOMS=100
ENV TURN_TIMER_MS=30000
EXPOSE 3001
CMD ["/app/server"]