-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (36 loc) · 1.25 KB
/
Dockerfile
File metadata and controls
51 lines (36 loc) · 1.25 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
# Use Node.js 20 LTS for Angular 20 compatibility
FROM node:20-alpine AS build
# Set working directory
WORKDIR /app
# Copy package.json and package-lock.json for better Docker layer caching
COPY package.json package-lock.json* ./
# Install dependencies with exact versions for reproducibility
RUN npm ci
# Copy the rest of the application code
COPY . .
# Build the Angular app for production
RUN npm run build:ci
# Production stage
FROM node:20-alpine AS production
# Create app directory
WORKDIR /app
# Create non-root user for security
RUN addgroup -g 1001 -S nodejs && \
adduser -S nextjs -u 1001
# Copy the built application and dependencies
COPY --from=build --chown=nextjs:nodejs /app/dist/utilplex ./dist/utilplex
COPY --from=build --chown=nextjs:nodejs /app/package.json ./
COPY --from=build --chown=nextjs:nodejs /app/package-lock.json* ./
# Install only production dependencies
RUN npm ci --only=production && npm cache clean --force
# Switch to non-root user
USER nextjs
# Set NODE_ENV to production
ENV NODE_ENV=production
# Expose port 4000
EXPOSE 4000
# Add health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node --version || exit 1
# Start the application
CMD ["node", "dist/utilplex/server/server.mjs"]