Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions dst_dashboard/frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Node
node_modules
npm-debug.log
.env.local
.env.development.local
.env.test.local
.env.production.local

# Build outputs
build
dist

# Git
.git
.gitignore

# IDE
.vscode
.idea
*.swp
*.swo

# OS
.DS_Store
Thumbs.db

# Testing
coverage
.pytest_cache
__pycache__

# Misc
*.log
.cache
49 changes: 49 additions & 0 deletions dst_dashboard/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Production-Optimized Docker Image (Recommended for Kubernetes)
# Multi-stage build: Build with Node, serve with Nginx
#
# Why Nginx instead of npm start?
# - 10x smaller image: ~20MB vs ~200MB
# - 10x faster: Static file serving optimized
# - Production-ready: Compression, caching, security
# - No dev dependencies in final image
#
# For simpler development deployment, see Dockerfile.dev

# Build stage
FROM node:18-alpine AS build

WORKDIR /app

# Copy package files
COPY package*.json ./

# Install dependencies (use npm install instead of ci for flexibility).
# Not --production: Tailwind/PostCSS/daisyui are devDependencies but run at
# build time below; this build stage's node_modules never reaches the final
# nginx image anyway, so there's no size cost to including them.
RUN npm install

# Copy source code and PostCSS/Tailwind config (required for the build step below)
COPY public/ ./public/
COPY src/ ./src/
COPY postcss.config.js tailwind.config.js ./

# Build-time argument for API URL (baked into the build)
ARG REACT_APP_API_URL=http://localhost:8000
ENV REACT_APP_API_URL=$REACT_APP_API_URL

# Build the app
RUN npm run build

# Production stage with nginx
FROM nginx:alpine

# Copy built files from build stage
COPY --from=build /app/build /usr/share/nginx/html

# Copy nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
36 changes: 36 additions & 0 deletions dst_dashboard/frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;

# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;

# Serve static files
location / {
try_files $uri $uri/ /index.html;
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
}

# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}

# Proxy API requests to backend (if using same domain)
# location /api/ {
# proxy_pass http://backend-service: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;
# }
}
Loading
Loading