-
Notifications
You must be signed in to change notification settings - Fork 198
Expand file tree
/
Copy pathWebApp.Dockerfile
More file actions
58 lines (42 loc) · 1.56 KB
/
Copy pathWebApp.Dockerfile
File metadata and controls
58 lines (42 loc) · 1.56 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
# ============================================
# Frontend Dockerfile
# Multi-stage build for Content Generation Frontend
# Combines: React/Vite frontend + server (Node.js proxy)
# ============================================
# ============================================
# Stage 1: Build the React frontend with Vite
# ============================================
FROM node:20-alpine AS frontend-build
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy frontend source code
COPY . ./
# Build the frontend (outputs to ../static, but we're in /app so it goes to /static)
# Override outDir to keep it in the container context
RUN npm run build -- --outDir ./dist
# ============================================
# Stage 2: Production Node.js server
# ============================================
FROM node:20-alpine AS production
WORKDIR /app
# Copy server package files
COPY server/package*.json ./
# Install only production dependencies
RUN npm ci --only=production
# Copy the server code
COPY server/server.js ./
# Copy built frontend assets from stage 1
COPY --from=frontend-build /app/dist ./static
# Environment variables (can be overridden at runtime)
ENV PORT=8080
ENV NODE_ENV=production
# Expose the port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:' + (process.env.PORT || 8080) + '/', (r) => process.exit(r.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))"
# Start the server
CMD ["node", "server.js"]