Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# VCS
.git

# Python
__pycache__
*.pyc
*.pyo
*.pyd
.venv
venv
.env

# Rust
/target
**/target
Cargo.lock

# Caches
.cache
pip-cache
uv-cache

# Logs
*.log

# Build outputs
/dist
/build

# IDE/editor
.vscode
.idea
*.swp
49 changes: 49 additions & 0 deletions .github/workflows/aa-release-router.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build and push sglang-router to Harbor

on:
push:
tags:
- 'aa/release/*'

permissions:
contents: read

jobs:
meta:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.ver.outputs.version }}
should_run: ${{ steps.ver.outputs.should_run }}
steps:
- name: Compute version with datetime suffix
id: ver
shell: bash
run: |
REF_NAME="${GITHUB_REF_NAME}"
if [[ "$REF_NAME" == aa/release/* ]]; then
BASE_VERSION="${REF_NAME#aa/release/}"
DT="$(date -u +%Y%m%dT%H%M%SZ)"
echo "version=${BASE_VERSION}-${DT}" >> "$GITHUB_OUTPUT"
echo "should_run=true" >> "$GITHUB_OUTPUT"
else
echo "Non-release ref: $REF_NAME. Skipping publish." >&2
echo "should_run=false" >> "$GITHUB_OUTPUT"
fi
build-and-publish:
if: ${{ needs.meta.outputs.should_run == 'true' }}
needs: meta
permissions:
contents: read
id-token: write
uses: Aleph-Alpha/shared-workflows/.github/workflows/build-and-push.yaml@a7c73c4e95557755ef409b1d2906ab94fc73d90a
with:
registry: ${{ vars.REGISTRY }}
registry_user: ${{ vars.REGISTRY_USER }}
image_repository: inference-images/sglang-router
version: ${{ needs.meta.outputs.version }}
push: true
containerfile: ./docker/Dockerfile.sgl_router
context: .
runs_on: ubuntu-latest
secrets:
registry_password: ${{ secrets.REGISTRY_PASSWORD }}
71 changes: 71 additions & 0 deletions docker/Dockerfile.sgl_router
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Concise build for sglang-router: build wheel once and run via Python module

ARG UBUNTU_VERSION=25.04

FROM ubuntu:${UBUNTU_VERSION} AS builder

ARG PYTHON_VERSION=3.12
ARG RUST_TOOLCHAIN=stable

ENV DEBIAN_FRONTEND=noninteractive \
PATH="/root/.cargo/bin:/root/.local/bin:${PATH}" \
UV_LINK_MODE=copy \
UV_PYTHON_INSTALL_DIR=/opt/uv/python

RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
build-essential \
libssl-dev \
pkg-config \
protobuf-compiler \
libprotobuf-dev \
&& rm -rf /var/lib/apt/lists/*

# Install uv
RUN curl -fsSL https://astral.sh/uv/install.sh | sh

SHELL ["/bin/bash", "-lc"]

# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- -y --profile minimal --default-toolchain ${RUST_TOOLCHAIN}

WORKDIR /workspace

COPY sgl-router/ sgl-router/

WORKDIR /workspace/sgl-router

# Build wheel and install into a virtualenv to collect runtime deps
RUN uv venv --python ${PYTHON_VERSION} --seed && \
uv build && \
uv pip install -p .venv --no-cache-dir --force-reinstall dist/*.whl

# Strip caches to shrink builder layer size
RUN rm -rf /root/.cache /root/.cargo/registry/index

FROM ubuntu:${UBUNTU_VERSION} AS runtime

ENV DEBIAN_FRONTEND=noninteractive \
PATH="/opt/sglang/.venv/bin:${PATH}"

RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /opt/sglang

COPY --from=builder /opt/uv/python /opt/uv/python
COPY --from=builder /workspace/sgl-router/.venv ./.venv

# Create non-root user
RUN useradd -r -u 10001 -g root sglang && \
chown -R sglang:root /opt/sglang && \
chmod -R g=u /opt/sglang

USER 10001

ENTRYPOINT ["/opt/sglang/.venv/bin/python", "-m", "sglang_router.launch_router"]
CMD ["--help"]