-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (49 loc) · 2.14 KB
/
Copy pathDockerfile
File metadata and controls
61 lines (49 loc) · 2.14 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
# Multi-stage build for Mist backend
# Stage 1: Builder - Compile TypeScript
FROM node:24-alpine AS builder
WORKDIR /app
ARG NPM_REGISTRY=https://registry.npmjs.org
ARG PNPM_VERSION=11.7.0
ENV PNPM_HOME=/pnpm
ENV PATH=$PNPM_HOME:$PATH
RUN corepack enable && corepack prepare pnpm@${PNPM_VERSION} --activate
# Copy dependency files
COPY package*.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
pnpm config set registry ${NPM_REGISTRY} && \
pnpm install --frozen-lockfile
# Copy source and build
COPY . .
RUN pnpm run build:docker
# Stage 2: Production - Run with Node.js
FROM node:24-alpine
# Install curl for health checks and create non-root runtime user.
RUN apk add --no-cache \
curl && \
addgroup -S app && \
adduser -S app -G app
WORKDIR /app
# Copy runtime dependencies and build output from builder stage.
COPY --from=builder --chown=app:app /app/node_modules ./node_modules
COPY --from=builder --chown=app:app /app/dist ./dist
# OTel SDK must init before the webpack bundle loads http/express/pino (RITM
# skips already-cached modules), so every node entrypoint runs the official
# `-r @opentelemetry/auto-instrumentations-node/register` (otel-observability-gaps G0).
COPY --from=builder --chown=app:app /app/test/fixtures/realtime ./test/fixtures/realtime
COPY --from=builder --chown=app:app /app/tools/run-migrations.mjs ./tools/run-migrations.mjs
COPY --from=builder --chown=app:app /app/deploy/database ./deploy/database
# Expose ports
# 8001: Main mist app
# 8008: Chan test entry
# 8010/9010: internal-only Signal HTTP/RPC listeners (Compose does not publish)
EXPOSE 8001 8008 8010 9010
# Health check - verify main app is responding
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8001/app/hello || exit 1
# Copy and prepare startup script.
COPY --chown=app:app docker-entrypoint.sh ./
RUN chmod +x docker-entrypoint.sh
USER app
ENTRYPOINT ["./docker-entrypoint.sh"]
# Official OTel register entry must load before any business module.
CMD ["node", "-r", "@opentelemetry/auto-instrumentations-node/register", "dist/apps/mist/main.js"]