# Jetour BI Dashboard — Dockerfile
# Multi-stage: builder for slim runtime

FROM python:3.12-slim AS builder

WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir --user -r requirements.txt

FROM python:3.12-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
    libpq5 curl \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Copy installed packages from builder
COPY --from=builder /root/.local /root/.local

# Copy app code
COPY app.py .
COPY static/ static/
COPY migrations/ migrations/
COPY migrate.py .

# Make sure scripts in .local are in PATH
ENV PATH=/root/.local/bin:$PATH

EXPOSE 8765

# Run migrations then start server
CMD python migrate.py && uvicorn app:app --host 0.0.0.0 --port 8765
