FROM ultralytics/ultralytics:latest-gpu

# The ultralytics image already has python, system dependencies, PyTorch, TensorRT, and ultralytics installed.
# We just need to install uv and our project dependencies.

# Pin the installer
RUN pip install --no-cache-dir uv==0.10.6

# Set working directory
WORKDIR /workspace

# Install our dependencies into the system python without resolving/syncing
# which would remove packages installed by ultralytics base image (like tensorrt).
COPY pyproject.toml README.md ./
RUN uv pip install --system fastapi mlflow uvicorn websockets

# Copy source code and install the project
COPY src ./src
RUN uv pip install --system -e .

# Expose Web UI port and MLflow port
EXPOSE 8000
EXPOSE 5000

# Start Web UI using the system entry point
CMD ["yolo-train-webui", "--host", "0.0.0.0", "--port", "8000"]
