-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (37 loc) · 2.08 KB
/
Copy pathDockerfile
File metadata and controls
44 lines (37 loc) · 2.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
# Single-image build: compiles the engine, web SPA, and game server, then runs
# the Fastify server which serves the API, WebSocket, and the built SPA.
# Targets Cloud Run (listens on $PORT, host 0.0.0.0).
# ── Build ─────────────────────────────────────────────────────────────────────
FROM node:22-slim AS build
WORKDIR /app
# Install deps using the lockfile and the workspace package manifests.
COPY package.json package-lock.json ./
COPY packages/engine/package.json packages/engine/package.json
COPY packages/protocol/package.json packages/protocol/package.json
COPY packages/server/package.json packages/server/package.json
COPY packages/web/package.json packages/web/package.json
RUN npm ci
COPY . .
RUN npm run build --workspace @ai-dm/engine \
&& npm run build --workspace @ai-dm/web \
&& npm run build --workspace @ai-dm/server
# Drop dev dependencies for the runtime image.
RUN npm prune --omit=dev
# ── Runtime ───────────────────────────────────────────────────────────────────
FROM node:22-slim AS run
WORKDIR /app
ENV NODE_ENV=production
ENV WEB_DIST=/app/packages/web/dist
ENV DATA_DIR=/data
# Cloud Run injects PORT (defaults to 8080); the server reads process.env.PORT.
COPY --from=build /app/package.json /app/package-lock.json ./
COPY --from=build /app/node_modules ./node_modules
# Workspace packages (node_modules symlinks resolve into these).
COPY --from=build /app/packages/engine/package.json ./packages/engine/package.json
COPY --from=build /app/packages/engine/dist ./packages/engine/dist
COPY --from=build /app/packages/protocol ./packages/protocol
COPY --from=build /app/packages/server/package.json ./packages/server/package.json
COPY --from=build /app/packages/server/dist ./packages/server/dist
COPY --from=build /app/packages/web/dist ./packages/web/dist
EXPOSE 8080
CMD ["node", "packages/server/dist/index.js"]