FROM --platform=linux/amd64 python:3.7-bullseye

# 1. System tools
RUN apt-get update && apt-get install -y build-essential && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# 2. Build tools
RUN pip install --upgrade pip setuptools wheel

# 3. Math stack (Your hard-won binaries)
RUN pip install numpy==1.19.5 scipy==1.5.4 pandas==1.1.5 statsmodels==0.12.2

# 4. THE COMPATIBILITY LAYER: Fix the 2022-2026 breaking changes
# We add pandas-flavor and pingouin pins here
RUN pip install "itsdangerous<2.1.0" "Jinja2<3.1.0" "Werkzeug<2.1.0" "MarkupSafe<2.1.0"
RUN pip install "pandas-flavor==0.2.0" "pingouin==0.3.8"

# 5. Remaining Pipenv app
COPY Pipfile Pipfile.lock ./
RUN pip install pipenv && pipenv install --system --skip-lock

COPY . .

ENV FLASK_APP=site/run.py
ENV FLASK_DEBUG=1
ENV OUTDATED_IGNORE=1

EXPOSE 5000

CMD ["flask", "run", "--host=0.0.0.0"]