# Multi-stage Dockerfile for OAuth Backend # Base stage FROM python:3.11-slim as base WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ gcc \ && rm -rf /var/lib/apt/lists/* # Copy requirements COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Development stage FROM base as development # Set environment variables ENV PYTHONUNBUFFERED=1 ENV ENVIRONMENT=dev # Copy application code COPY . . # Create necessary directories RUN mkdir -p /var/log/oauth # Expose port EXPOSE 8000 # Run with hot reload CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"] # Production stage FROM base as production # Set environment variables ENV PYTHONUNBUFFERED=1 ENV ENVIRONMENT=prod # Copy application code COPY . . # Create necessary directories RUN mkdir -p /var/log/oauth # Create non-root user RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app /var/log/oauth USER appuser # Expose port EXPOSE 8000 # Run without reload CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "4"]