# syntax=docker/dockerfile:1.6

# Build a lightweight image to run the Streamlit app and CLIs
ARG PYTHON_VERSION=3.11-slim
FROM python:${PYTHON_VERSION} AS runtime

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1 \
    PIP_DISABLE_PIP_VERSION_CHECK=1

WORKDIR /app

# System deps commonly needed by scientific Python stacks. Adjust if your deps change.
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
       build-essential \
       curl \
       ca-certificates \
    && rm -rf /var/lib/apt/lists/*

# Install Python dependencies first to leverage Docker layer caching
COPY requirements.txt ./
RUN python -m pip install --upgrade pip \
    && if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

# Copy the rest of the application code and datasets
COPY . .
RUN python -m pip install -e .

# Streamlit server port
EXPOSE 8501

# Default entrypoint runs the Streamlit app. Override with `docker run ... python -m forge.cli.steel_batch_cli ...` for CLIs.
CMD ["streamlit", "run", "src/forge/apps/streamlit_app.py", "--server.port", "8501", "--server.address", "0.0.0.0"]
