# ============================================================================= # EVG ULTIMATE TEAM - Docker Build for Hugging Face Spaces # ============================================================================= # Multi-stage build: Frontend (Node.js) + Backend (Python) in single container # ============================================================================= # Stage 1: Build Frontend (React + Vite) # ============================================================================= FROM node:20-alpine AS frontend-builder WORKDIR /app/frontend # Copy frontend code COPY frontend/ ./ # Install dependencies and build the app RUN npm ci && npm run build # ============================================================================= # Stage 2: Setup Backend + Serve Frontend # ============================================================================= FROM python:3.11-slim WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ gcc \ && rm -rf /var/lib/apt/lists/* # Copy backend requirements COPY backend/requirements.txt ./backend/ # Install Python dependencies RUN pip install --no-cache-dir -r backend/requirements.txt # Copy backend source code COPY backend/ ./backend/ # Copy frontend build from previous stage COPY --from=frontend-builder /app/frontend/dist ./frontend/dist # Create directory for SQLite database (persistent storage) RUN mkdir -p /app/data # Set environment variables for production ENV PYTHONUNBUFFERED=1 \ ENVIRONMENT=production \ DATABASE_URL=sqlite:///../data/evg_ultimate_team.db \ API_HOST=0.0.0.0 \ API_PORT=7860 \ CORS_ORIGINS=* \ DEBUG=false # Expose Hugging Face Spaces default port EXPOSE 7860 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/health', timeout=5).read()" # Change to backend directory for proper Python module resolution WORKDIR /app/backend # Run the application CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]