Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
90 lines (64 loc) · 3.74 KB
/
Copy pathDockerfile
File metadata and controls
90 lines (64 loc) · 3.74 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
78
79
80
81
82
83
84
85
86
87
88
89
90
# Voxium Server — Multi-stage Docker build
#
# SECURITY: This image contains NO secrets. All configuration must be
# injected at runtime via environment variables or a mounted .env file.
# ── Stage 1: Build ───────────────────────────────────────────────────────────
# node:26.13.0-slim (Node 26 LTS), pinned by digest; bump the tag and the digest together
FROM node:26.13.0-slim@sha256:e4db4c914bf8ad241bd24804fc25d272d89bad97e68cdc8a1414862790a02c39 AS build
RUN apt-get update && apt-get install -y --no-install-recommends openssl ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Node 25+ no longer ships Corepack: install the pnpm the root package.json names.
RUN npm install -g pnpm@10.32.1
WORKDIR /app
# pnpm's isolated node_modules breaks CLI shim resolution in Docker.
# Hoisted layout puts all binaries at root level where they're findable.
RUN echo "node-linker=hoisted" > .npmrc
COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./
COPY packages/shared/package.json packages/shared/
COPY apps/server/package.json apps/server/
RUN pnpm install --frozen-lockfile
# pnpm hoisted layout doesn't auto-link workspace packages
RUN mkdir -p node_modules/@voxium && \
ln -sfn ../../packages/shared node_modules/@voxium/shared
COPY packages/shared/ packages/shared/
COPY apps/server/ apps/server/
RUN npx tsc --project packages/shared/tsconfig.json
# Prisma 7: generate from server directory where prisma.config.ts lives
RUN cd apps/server && npx prisma generate
RUN npx tsc --project apps/server/tsconfig.json
# ── Stage 2: Production ─────────────────────────────────────────────────────
FROM node:26.13.0-slim@sha256:e4db4c914bf8ad241bd24804fc25d272d89bad97e68cdc8a1414862790a02c39 AS production
RUN apt-get update && apt-get install -y --no-install-recommends openssl ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Node 25+ no longer ships Corepack: install the pnpm the root package.json names.
RUN npm install -g pnpm@10.32.1
RUN groupadd --gid 1001 voxium && useradd --uid 1001 --gid voxium --create-home voxium
WORKDIR /app
RUN echo "node-linker=hoisted" > .npmrc
COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./
COPY packages/shared/package.json packages/shared/
COPY apps/server/package.json apps/server/
RUN pnpm install --frozen-lockfile --prod
RUN mkdir -p node_modules/@voxium && \
ln -sfn ../../packages/shared node_modules/@voxium/shared
COPY --from=build /app/packages/shared/dist packages/shared/dist
COPY --from=build /app/apps/server/dist apps/server/dist
COPY --from=build /app/apps/server/src/generated/prisma apps/server/src/generated/prisma
COPY --from=build /app/apps/server/prisma apps/server/prisma
# Prisma 7: config file needed for migrate deploy at runtime
COPY --from=build /app/apps/server/prisma.config.ts apps/server/prisma.config.ts
# Copy Prisma CLI + engine from build stage so migrate deploy works
# at startup without downloading anything from the network.
COPY --from=build /app/node_modules/prisma node_modules/prisma
COPY --from=build /app/node_modules/@prisma/engines node_modules/@prisma/engines
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
RUN chmod +x /app/docker-entrypoint.sh
USER voxium
ENV NODE_ENV=production
EXPOSE 3001
# mediasoup WebRtcServer ports: MEDIASOUP_MIN_PORT .. +workers-1 (one udp+tcp pair per worker, max 8)
EXPOSE 10000-10007/udp
EXPOSE 10000-10007/tcp
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
CMD node -e "fetch('http://localhost:3001/health').then(r=>{if(!r.ok)throw 1})" || exit 1
ENTRYPOINT ["/app/docker-entrypoint.sh"]