-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.backend
More file actions
32 lines (22 loc) · 860 Bytes
/
Dockerfile.backend
File metadata and controls
32 lines (22 loc) · 860 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
# Dockerfile.backend
# Production stage
FROM node:22-alpine AS production
WORKDIR /app
# Create app user with UID within system limits
RUN addgroup -g 1001 nodejs && adduser -D -u 1001 -G nodejs nestjs
# Copy the built application (built in GitHub Actions)
COPY --chown=nestjs:nodejs apps/backend/dist ./dist
# Copy the backend's package.json and the lock file
COPY apps/backend/package.json ./package.json
COPY package-lock.json* ./
# Install only production dependencies for the backend including optional dependencies
RUN npm install --production --include=optional
# Copy healthcheck script
COPY apps/backend/healthcheck.js ./healthcheck.js
# Set ownership and user
RUN chown -R nestjs:nodejs /app
USER nestjs
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node healthcheck.js
CMD ["node", "dist/main"]