FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim

WORKDIR /app

# Copy lockfile and manifest first — changes to source won't bust this cache layer
COPY pyproject.toml uv.lock ./

# Install dependencies from the lockfile, skip installing the project itself
RUN uv sync --frozen --no-install-project --no-dev

# Copy application source
COPY main.py .

# Ensure storage directory exists
RUN mkdir -p storage

EXPOSE 8501

HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1

ENTRYPOINT ["uv", "run", "streamlit", "run", "main.py", "--server.port=8501", "--server.address=0.0.0.0"]