-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (39 loc) · 1.2 KB
/
Dockerfile
File metadata and controls
60 lines (39 loc) · 1.2 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
# Build stage
FROM node:22-alpine AS builder
WORKDIR /app
# Install python and build dependencies
RUN apk add --no-cache python3 make g++
COPY package.json yarn.lock ./
# Install dependencies
RUN yarn install --frozen-lockfile
COPY . .
# Build the application
RUN yarn build
# Production stage
FROM node:22-alpine AS production
WORKDIR /app
# Install python and build dependencies for production packages that need compilation
RUN apk add --no-cache python3 make g++
COPY package.json yarn.lock ./
# Install only production dependencies
RUN yarn install --frozen-lockfile --production
FROM node:22-alpine AS runner
WORKDIR /app
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nestjs
COPY --from=production /app/node_modules ./node_modules
RUN mkdir dist
RUN chown nestjs:nodejs dist
RUN chown nestjs:nodejs node_modules
# Copy built assets from builder stage
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/src/i18n ./src/i18n
COPY --from=builder /app/src/i18n/messages ./dist/i18n/messages
# Set environment variables
ENV NODE_ENV=production
ENV PORT=3000
# Expose the port the app runs on
EXPOSE ${PORT}
USER nestjs
# Start the application
CMD ["node", "dist/main.js"]