nginx crashes at startup if upstream hosts aren't resolvable yet. Using 'set $upstream' + Docker's internal resolver (127.0.0.11) defers DNS resolution to request time, so console starts even if backends are still booting.
114 lines
3.0 KiB
Docker
114 lines
3.0 KiB
Docker
FROM node:22-slim AS build
|
|
WORKDIR /app
|
|
COPY package.json package-lock.json* ./
|
|
RUN npm ci
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
FROM nginx:alpine
|
|
COPY --from=build /app/dist /usr/share/nginx/html
|
|
COPY <<'EOF' /etc/nginx/conf.d/default.conf
|
|
resolver 127.0.0.11 valid=10s;
|
|
|
|
server {
|
|
listen 80;
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# SPA fallback
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# Auth routes → alert service (any service works, they all share auth)
|
|
location /api/v1/auth/ {
|
|
set $upstream_alert alert:3000;
|
|
proxy_pass http://$upstream_alert;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
}
|
|
|
|
# Drift API
|
|
location /api/v1/stacks {
|
|
set $upstream_drift drift:3000;
|
|
proxy_pass http://$upstream_drift;
|
|
proxy_set_header Host $host;
|
|
}
|
|
location /api/v1/reports {
|
|
set $upstream_drift drift:3000;
|
|
proxy_pass http://$upstream_drift;
|
|
proxy_set_header Host $host;
|
|
}
|
|
location /api/v1/dashboard {
|
|
set $upstream_drift drift:3000;
|
|
proxy_pass http://$upstream_drift;
|
|
proxy_set_header Host $host;
|
|
}
|
|
|
|
# Alert API
|
|
location /api/v1/incidents {
|
|
set $upstream_alert alert:3000;
|
|
proxy_pass http://$upstream_alert;
|
|
proxy_set_header Host $host;
|
|
}
|
|
location /api/v1/notifications {
|
|
set $upstream_alert alert:3000;
|
|
proxy_pass http://$upstream_alert;
|
|
proxy_set_header Host $host;
|
|
}
|
|
location /api/v1/webhooks {
|
|
set $upstream_alert alert:3000;
|
|
proxy_pass http://$upstream_alert;
|
|
proxy_set_header Host $host;
|
|
}
|
|
|
|
# Portal API
|
|
location /api/v1/services {
|
|
set $upstream_portal portal:3000;
|
|
proxy_pass http://$upstream_portal;
|
|
proxy_set_header Host $host;
|
|
}
|
|
|
|
# Cost API
|
|
location /api/v1/anomalies {
|
|
set $upstream_cost cost:3000;
|
|
proxy_pass http://$upstream_cost;
|
|
proxy_set_header Host $host;
|
|
}
|
|
location /api/v1/baselines {
|
|
set $upstream_cost cost:3000;
|
|
proxy_pass http://$upstream_cost;
|
|
proxy_set_header Host $host;
|
|
}
|
|
location /api/v1/governance {
|
|
set $upstream_cost cost:3000;
|
|
proxy_pass http://$upstream_cost;
|
|
proxy_set_header Host $host;
|
|
}
|
|
location /api/v1/ingest {
|
|
set $upstream_cost cost:3000;
|
|
proxy_pass http://$upstream_cost;
|
|
proxy_set_header Host $host;
|
|
}
|
|
location /api/v1/cost {
|
|
set $upstream_cost cost:3000;
|
|
proxy_pass http://$upstream_cost;
|
|
proxy_set_header Host $host;
|
|
}
|
|
|
|
# Run API
|
|
location /api/v1/runbooks {
|
|
set $upstream_run run:3000;
|
|
proxy_pass http://$upstream_run;
|
|
proxy_set_header Host $host;
|
|
}
|
|
location /api/v1/approvals {
|
|
set $upstream_run run:3000;
|
|
proxy_pass http://$upstream_run;
|
|
proxy_set_header Host $host;
|
|
}
|
|
}
|
|
EOF
|
|
EXPOSE 80
|
|
CMD ["nginx", "-g", "daemon off;"]
|