FROM python:3.13-slim

WORKDIR /app

# Install uv
RUN pip install --no-cache-dir uv

# Install dependencies first (cached unless the lockfile changes)
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-install-project

# Copy source code
COPY solve.py main.py index.html ./

# Bind to all interfaces so the server is reachable outside the container
ENV HOST=0.0.0.0 \
    PORT=8000 \
    PYTHONUNBUFFERED=1

EXPOSE 8000

# Run the stdlib HTTP server
CMD ["uv", "run", "--frozen", "python", "main.py"]
