From c6fd32e51bfc3987cd39cf69cacd7b49f758cd71 Mon Sep 17 00:00:00 2001 From: Kai Chappell Date: Thu, 8 May 2025 19:14:50 +0000 Subject: [PATCH] chore(docker): add dashboard service --- dashboard/Dockerfile | 12 ++++++++++++ dashboard/nginx.conf | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 dashboard/Dockerfile create mode 100644 dashboard/nginx.conf diff --git a/dashboard/Dockerfile b/dashboard/Dockerfile new file mode 100644 index 0000000..42b7b20 --- /dev/null +++ b/dashboard/Dockerfile @@ -0,0 +1,12 @@ +FROM node:20-alpine AS builder +WORKDIR /app +COPY package*.json ./ +RUN npm ci +COPY . . +RUN npm run build + +FROM nginx:alpine +COPY --from=builder /app/dist /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/dashboard/nginx.conf b/dashboard/nginx.conf new file mode 100644 index 0000000..ab6f1ea --- /dev/null +++ b/dashboard/nginx.conf @@ -0,0 +1,37 @@ +server { + listen 80; + server_name localhost; + root /usr/share/nginx/html; + index index.html; + + # Gzip compression + gzip on; + gzip_vary on; + gzip_min_length 1024; + gzip_proxied expired no-cache no-store private auth; + gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/javascript; + + # Cache static assets + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + + # SPA routing - serve index.html for all non-file routes + location / { + try_files $uri $uri/ /index.html; + } + + # API proxy - forward to backend + location /api { + proxy_pass http://api:8000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + 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; + } +}