This repository was archived by the owner on Feb 9, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (49 loc) · 1.6 KB
/
Dockerfile
File metadata and controls
67 lines (49 loc) · 1.6 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
# ------------------------------------------
# Stage 1: Base image (Node 20 on Alpine)
# ------------------------------------------
FROM node:20-alpine AS base
# Install build tools and any needed packages
# Note: we don't install corepack as a package, we enable it via Node
RUN apk add --no-cache \
python3 \
make \
g++ \
&& corepack enable
WORKDIR /app
# -----------------------------
# Stage 2: Install dependencies
# -----------------------------
FROM base AS deps
# Copy package info first for caching
COPY package.json yarn.lock ./
# Install all dependencies (including dev deps for building)
RUN yarn install --frozen-lockfile
# ---------------------
# Stage 3: Build the app
# ---------------------
FROM deps AS builder
COPY tsconfig.json ./
COPY esbuild.js ./
COPY src ./src
RUN yarn build
# -----------------------------
# Stage 4: Production deps only
# -----------------------------
FROM base AS prod-deps
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --production=true
# ----------------------------------------------
# Stage 5: Final Alpine image with pg_dump etc.
# ----------------------------------------------
FROM node:20-alpine AS runner
# Add PostgreSQL 15 client
RUN apk add --no-cache postgresql15-client
# Use a non-root user for security (Alpine's default "node" user in the Node image)
USER node
WORKDIR /app
# Copy the production node_modules and compiled output
COPY --chown=node:node --from=prod-deps /app/node_modules ./node_modules
COPY --chown=node:node --from=builder /app/dist ./dist
EXPOSE 3000
ENV NODE_ENV=production
CMD ["node", "dist/index.js"]