-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (28 loc) · 1.31 KB
/
Dockerfile
File metadata and controls
42 lines (28 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
# ── Stage 1: Build ────────────────────────────────────────────────────────────
FROM node:20-slim AS builder
# Native deps needed for better-sqlite3
RUN apt-get update && apt-get install -y python3 make g++ && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# Prune dev-only packages, keep production deps (including better-sqlite3)
RUN npm prune --omit=dev
# ── Stage 2: Production image ─────────────────────────────────────────────────
FROM node:20-slim AS runner
# Same toolchain so native binary from Stage 1 is compatible
RUN apt-get update && apt-get install -y python3 make g++ && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy pruned node_modules (includes compiled better-sqlite3 binary)
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/public ./public
COPY package.json ./
# Persistent data directory (mount a volume here)
RUN mkdir -p data
EXPOSE 4321
ENV HOST=0.0.0.0 \
PORT=4321 \
NODE_ENV=production
CMD ["node", "./dist/server/entry.mjs"]