# Dockerfile for AegisLM SaaS Backend (FastAPI) FROM python:3.10-slim # Prevent python from buffering stdout/stderr ENV PYTHONUNBUFFERED=1 ENV PYTHONDONTWRITEBYTECODE=1 # Working Directory WORKDIR /app # Install system dependencies (including PostgreSQL dev libraries if needed) RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ libpq-dev \ curl \ && rm -rf /var/lib/apt/lists/* # 1. Install Backend Dependencies # Using the specific SaaS backend requirements COPY backend/requirements.txt ./requirements.txt RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # 2. Copy Backend Source Code COPY backend/ ./backend/ # 3. Environment Variables for Backend ENV APP_MODULE="backend.main:app" ENV HOST="0.0.0.0" ENV PORT=8000 # 4. Expose FastAPI Port EXPOSE 8000 # Healthcheck HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ CMD curl -f http://localhost:8000/health || exit 1 # 5. Run the SaaS Backend using Uvicorn # We set the python path so it can find the backend module ENV PYTHONPATH=/app CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"]