FROM ghcr.io/astral-sh/uv:latest AS uv_bin
FROM nvidia/cuda:12.4.1-base-ubuntu22.04

# 1. 基础环境配置
ENV UV_LINK_MODE=copy \
    UV_COMPILE_BYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    UV_PROJECT_ENVIRONMENT=/app/.venv

COPY --from=uv_bin /uv /uvx /bin/

RUN apt-get update && apt-get install -y --no-install-recommends \
        wget \
        libcurl4-openssl-dev \
        build-essential \
        libgl1 \
        libglib2.0-0 \
        ca-certificates \
        git \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY pyproject.toml uv.lock ./

ENV UV_COMPILE_BYTECODE=0

RUN uv sync --frozen --no-dev --no-install-project --python 3.12

# 4. 拷贝项目文件并安装项目本身
RUN uv sync --frozen --no-dev --python 3.12

ENV PATH="/app/.venv/bin:$PATH"

EXPOSE 8000
CMD ["uv", "run","-m","app.litserve_serve"]
