# Use an official Python runtime as a parent image
FROM python:3.11-slim

# Set the working directory
WORKDIR /app

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

# Copy dependency definition files first to leverage Docker cache
COPY pyproject.toml ./
COPY proxy/pyproject.toml proxy/

# Copy all apps directory structure (includes all pyproject.toml files)
COPY apps/ apps/

# Sync all workspace dependencies
# This installs all dependencies from all workspace members
RUN uv sync --frozen

# Copy remaining source code
COPY proxy/ /app/proxy/
COPY scripts/ /app/scripts/

# Make the start script executable
RUN chmod +x /app/scripts/start.py

# Expose the port the FastAPI proxy runs on
EXPOSE 8000

# Set environment variables for Python
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app

# Command to run the application using uv run
CMD ["uv", "run", "python", "/app/scripts/start.py"]
