-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (38 loc) · 1.2 KB
/
Dockerfile
File metadata and controls
47 lines (38 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
# ===============================
# 🐳 Netveris - Docker Setup
# Multi-stage build for optimized production image
# ===============================
# Stage 1: Dependencies & Build
FROM node:20-alpine AS builder
WORKDIR /app
# Install dependencies
COPY package.json package-lock.json* ./
RUN npm ci --legacy-peer-deps
# Copy source and build
COPY . .
RUN npm run build
# Stage 2: Production Runner (using nginx for static files)
FROM nginx:alpine AS runner
# Copy custom nginx config
COPY --from=builder /app/build/client /usr/share/nginx/html
# Copy nginx configuration for SPA routing
RUN echo 'server { \
listen 3000; \
server_name localhost; \
root /usr/share/nginx/html; \
index index.html; \
location / { \
try_files $uri $uri/ /index.html; \
} \
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ { \
expires 1y; \
add_header Cache-Control "public, immutable"; \
} \
}' > /etc/nginx/conf.d/default.conf
# Expose the port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/ || exit 1
# Start nginx
CMD ["nginx", "-g", "daemon off;"]