forked from lucadagati/retrospect
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.dashboard
More file actions
65 lines (54 loc) · 1.79 KB
/
Copy pathDockerfile.dashboard
File metadata and controls
65 lines (54 loc) · 1.79 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
59
60
61
62
63
64
# Multi-stage build for Wasmbed Dashboard (React)
FROM node:18-alpine as builder
# Set working directory
WORKDIR /app
# Copy package files
COPY dashboard-react/package*.json ./
# Install dependencies
RUN npm install
# Copy source code
COPY dashboard-react/ ./
# Build the React app with production environment
ENV NODE_ENV=production
RUN npm run build
# Runtime stage with nginx
FROM nginx:alpine
# Copy built files from builder
COPY --from=builder /app/build /usr/share/nginx/html
# Copy nginx configuration (for SPA routing and API proxy)
# Use resolver with CoreDNS IP (10.43.0.10 is default for k3d) and variable for dynamic DNS resolution
RUN echo 'resolver 10.43.0.10 valid=10s ipv6=off; \
server { \
listen 3000; \
server_name _; \
root /usr/share/nginx/html; \
index index.html; \
\
# API proxy to Kubernetes service \
# Use variable to force DNS resolution at request time \
set $api_server wasmbed-api-server.wasmbed.svc.cluster.local:3001; \
location /api/ { \
proxy_pass http://$api_server; \
proxy_http_version 1.1; \
proxy_set_header Upgrade $http_upgrade; \
proxy_set_header Connection "upgrade"; \
proxy_set_header Host $host; \
proxy_set_header X-Real-IP $remote_addr; \
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; \
proxy_set_header X-Forwarded-Proto $scheme; \
proxy_set_header X-Forwarded-Host $host; \
proxy_set_header X-Forwarded-Port $server_port; \
proxy_connect_timeout 60s; \
proxy_send_timeout 60s; \
proxy_read_timeout 60s; \
} \
\
# SPA routing \
location / { \
try_files $uri $uri/ /index.html; \
} \
}' > /etc/nginx/conf.d/default.conf
# Expose port
EXPOSE 3000
# Start nginx
CMD ["nginx", "-g", "daemon off;"]