# Multi-stage Dockerfile for static frontend deployment # Stage 1: Build the diagrams FROM python:3.11-slim AS builder # Install system dependencies for Graphviz RUN apt-get update && \ apt-get install -y --no-install-recommends \ graphviz \ && rm -rf /var/lib/apt/lists/* # Set working directory WORKDIR /app # Copy requirements and install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy source files COPY *.py . # Generate diagrams (outputs will be in /app) RUN python lan_architecture.py && \ python main.py # Verify generated files exist RUN ls -la *.png || echo "Warning: No PNG files generated" # Stage 2: Serve with Nginx FROM nginx:alpine # Remove default nginx static assets RUN rm -rf /usr/share/nginx/html/* # Copy generated diagram files from builder stage COPY --from=builder /app/*.png /usr/share/nginx/html/ # Copy any HTML/CSS files for the frontend COPY public/ /usr/share/nginx/html/ # Create a simple nginx config for serving static files RUN echo 'server { \ listen 80; \ server_name _; \ root /usr/share/nginx/html; \ index index.html; \ location / { \ try_files $uri $uri/ /index.html; \ } \ # Enable CORS if needed \ add_header Access-Control-Allow-Origin *; \ }' > /etc/nginx/conf.d/default.conf # Expose port 80 EXPOSE 80 # Health check HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD wget --quiet --tries=1 --spider http://localhost/ || exit 1 # Start nginx CMD ["nginx", "-g", "daemon off;"]