-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (34 loc) · 947 Bytes
/
Copy pathDockerfile
File metadata and controls
51 lines (34 loc) · 947 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
40
41
42
43
44
45
46
47
48
49
50
51
# Multi-stage build for financial forecast app
# Stage 1: Build frontend
FROM node:22-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy source files
COPY . .
# Build frontend
RUN npm run build
# Stage 2: Production image
FROM node:22-alpine
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install only production dependencies
RUN npm ci --only=production
# Copy server files
COPY server ./server
# Copy built frontend from builder stage
COPY --from=builder /app/dist ./dist
# Create data directory
RUN mkdir -p /app/server/data
# Expose port
EXPOSE 3001
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3001/api/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
# Set production environment
ENV NODE_ENV=production
# Start server
CMD ["npm", "start"]