-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (27 loc) · 814 Bytes
/
Copy pathDockerfile
File metadata and controls
39 lines (27 loc) · 814 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
34
35
36
37
38
39
# Base image with Node.js 22
FROM node:22-slim AS builder
# Set working directory
WORKDIR /app
# Copy dependency definitions first (for caching)
COPY package.json yarn.lock ./
# Install dependencies only (using cache if no change)
RUN yarn install --frozen-lockfile
# Copy the full project (after dependencies)
COPY . .
# Optional: Run lint and tests here
# RUN yarn lint
RUN npx tsc
# RUN yarn test
# Build the app (NestJS to JS in dist/)
RUN yarn build
# Production image
FROM node:22-slim AS production
WORKDIR /app
# Copy only what's needed for production
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./
# Expose app port (change if needed)
EXPOSE 3000
# Default command to run the app
CMD ["node", "dist/main.js"]