# Use python:3.11-slim as a base
FROM python:3.11-slim

# Set environment variables
# UV_SYSTEM_PYTHON=1 allows uv to install into the system site-packages
ENV PYTHONDONTWRITEBYTECODE=1 
    PYTHONUNBUFFERED=1 
    UV_SYSTEM_PYTHON=1

# Install system dependencies and uv
RUN apt-get update && apt-get install -y --no-install-recommends 
    curl 
    ca-certificates 
    && rm -rf /var/lib/apt/lists/* 
    && curl -LsSf https://astral.sh/uv/install.sh | sh 
    && mv /root/.local/bin/uv /usr/local/bin/uv

# Set the working directory in the container
WORKDIR /app

# Copy dependency files first to leverage Docker layer caching
COPY pyproject.toml requirements.txt* ./

# Install dependencies via uv
RUN if [ -f requirements.txt ]; then uv pip install --no-cache -r requirements.txt; fi

# Copy the rest of the application code
COPY . .

# Expose port 8000 for the headless API/service
EXPOSE 8000

# Set the entrypoint to run the app in headless mode
ENTRYPOINT ["python", "gui_2.py", "--headless"]
