# SentinelMesh v1.0 — Production Dockerfile
FROM python:3.11-slim

WORKDIR /app

RUN apt-get update && apt-get install -y \
    build-essential curl git \
    && rm -rf /var/lib/apt/lists/*

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

# /app/data is the Railway Volume mount point — all SQLite DBs live here
RUN mkdir -p /app/data/memory /app/data/cache /app/data/workflows \
             /app/data/prompts /app/data/collaboration /app/logs

ENV PYTHONUNBUFFERED=1
ENV SENTINELMESH_ENV=production
ENV DATA_DIR=/app/data

EXPOSE 8000

HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
    CMD curl -f http://localhost:8000/health || exit 1

CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "2"]
