# RoboPark Session Scheduler
FROM python:3.11-slim

WORKDIR /app

# Install build dependencies for pyaudio / opencv wheels, then Python packages.
RUN apt-get update && apt-get install -y --no-install-recommends \
    gcc g++ libportaudio2 portaudio19-dev \
    libgl1 libglib2.0-0 libsm6 libxext6 libxrender-dev \
    && rm -rf /var/lib/apt/lists/*

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy application
COPY main.py .

# Create data directory
RUN mkdir -p /app/data

# Expose port
EXPOSE 8080

# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s \
    CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8080/api/robots')"

# Run
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]
