-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.server
More file actions
49 lines (37 loc) · 1.31 KB
/
Dockerfile.server
File metadata and controls
49 lines (37 loc) · 1.31 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
# ============================================
# Protocol Guide - Server Dockerfile
# Multi-stage build: dev (tsx watch) + production (esbuild bundle)
# ============================================
# --- Base: Node 20 + pnpm ---
FROM node:20-alpine AS base
RUN corepack enable && corepack prepare pnpm@9.12.0 --activate
WORKDIR /app
# --- Dependencies: install all deps (cached layer) ---
FROM base AS deps
COPY package.json pnpm-lock.yaml .npmrc* ./
RUN pnpm install --frozen-lockfile
# --- Dev: tsx watch for hot reload ---
FROM deps AS dev
COPY . .
EXPOSE 3001
CMD ["pnpm", "dev:server"]
# --- Build: esbuild server bundle ---
FROM deps AS build
COPY . .
RUN pnpm build
# --- Production: minimal runtime ---
FROM base AS production
ENV NODE_ENV=production
# Install production dependencies only
COPY package.json pnpm-lock.yaml .npmrc* ./
RUN pnpm install --frozen-lockfile --prod
# Copy built server bundle
COPY --from=build /app/dist ./dist
# Copy drizzle migrations (needed at runtime for db:push)
COPY drizzle ./drizzle
# Copy shared constants/types (imported by server at runtime via path aliases)
COPY shared ./shared
EXPOSE 3001
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3001/api/live || exit 1
CMD ["node", "dist/index.js"]