| |
| FROM ubuntu:24.04 AS base |
|
|
| ARG PYTHON_VERSION=3.12 |
|
|
| |
| ENV PATH="/root/.local/bin:${PATH}" |
| ENV DEBIAN_FRONTEND=noninteractive |
|
|
| |
| ENV UV_HTTP_TIMEOUT=500 |
| ENV VIRTUAL_ENV="/opt/venv" |
| ENV UV_PYTHON_INSTALL_DIR=/opt/uv/python |
| ENV UV_LINK_MODE="copy" |
| ENV PATH="$VIRTUAL_ENV/bin:$PATH" |
|
|
|
|
| |
| RUN apt update -y \ |
| && apt install -y curl \ |
| && rm -rf /var/lib/apt/lists/* \ |
| && apt clean |
|
|
| |
| RUN curl -LsSf https://astral.sh/uv/install.sh | sh |
|
|
| |
| RUN uv venv --python ${PYTHON_VERSION} --seed ${VIRTUAL_ENV} |
|
|
| FROM scratch AS local_src |
| COPY . /src |
|
|
| |
| FROM base AS build-image |
|
|
| |
| ENV PATH="/root/.cargo/bin:${PATH}" |
|
|
| |
| RUN apt update -y \ |
| && apt install -y git build-essential libssl-dev pkg-config protobuf-compiler \ |
| && rm -rf /var/lib/apt/lists/* \ |
| && apt clean |
|
|
| |
| RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ |
| && rustc --version && cargo --version && protoc --version |
|
|
| |
| COPY --from=local_src /src /opt/sglang |
|
|
| |
| WORKDIR /opt/sglang/sgl-model-gateway |
|
|
| |
| RUN uv pip install maturin \ |
| && cargo clean \ |
| && rm -rf bindings/python/dist/ \ |
| && cd bindings/python \ |
| && ulimit -n 65536 && maturin build --release --features vendored-openssl --out dist \ |
| && rm -rf /root/.cache |
|
|
| |
| FROM base AS router-image |
|
|
| |
| COPY --from=build-image /opt/sglang/sgl-model-gateway/bindings/python/dist/*.whl dist/ |
|
|
| |
| RUN uv pip install --force-reinstall dist/*.whl |
|
|
| |
| RUN rm -rf /root/.cache dist/ \ |
| && apt purge -y --auto-remove curl |
|
|
| |
| ENTRYPOINT ["python3", "-m", "sglang_router.launch_router"] |
|
|