FROM python:3.12-slim

# Place code at /app/backend/office so that 'from backend.office.src...' imports work
WORKDIR /app/backend/office

# Install MySQL client for db-migrate container
RUN apt-get update && apt-get install -y default-mysql-client curl && rm -rf /var/lib/apt/lists/*

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

COPY . .

# /app is the Python root so 'import backend.office.src.*' resolves correctly
ENV PYTHONPATH=/app

EXPOSE 9000

HEALTHCHECK --interval=10s --timeout=5s --retries=3 \
  CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:9000/auth/health')"

CMD ["uvicorn", "backend.office.app:app", "--host", "0.0.0.0", "--port", "9000"]
