forked from CredenceOrg/Credence-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
33 lines (23 loc) · 661 Bytes
/
Copy pathDockerfile
File metadata and controls
33 lines (23 loc) · 661 Bytes
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
# ---------- Stage 1: Build ----------
FROM node:20-alpine AS builder
WORKDIR /app
# Install dependencies first (layer caching)
COPY package.json package-lock.json* ./
RUN npm ci
# Copy source and compile TypeScript
COPY tsconfig.json ./
COPY src/ src/
RUN npm run build
# ---------- Stage 2: Production ----------
FROM node:20-alpine
WORKDIR /app
# Only production deps
COPY package.json package-lock.json* ./
RUN npm ci --omit=dev
# Copy compiled output from builder
COPY --from=builder /app/dist/ dist/
# Non-root user for security
RUN addgroup -S credence && adduser -S credence -G credence
USER credence
EXPOSE 3000
CMD ["node", "dist/index.js"]