mirror of
https://github.com/hanzo-ml/kserve.git
synced 2026-10-30 20:53:49 +00:00
65 lines
2.0 KiB
Docker
65 lines
2.0 KiB
Docker
ARG PYTHON_VERSION=3.11
|
|
ARG BASE_IMAGE=python:${PYTHON_VERSION}-slim-bookworm
|
|
ARG VENV_PATH=/prod_venv
|
|
|
|
FROM ${BASE_IMAGE} AS builder
|
|
|
|
# Required for building packages for arm64 arch
|
|
RUN apt-get update && apt-get install -y --no-install-recommends curl python3-dev build-essential && apt-get clean && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install uv
|
|
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
|
|
ln -s /root/.local/bin/uv /usr/local/bin/uv
|
|
|
|
# Set up and activate virtual environment
|
|
ARG VENV_PATH
|
|
ENV VIRTUAL_ENV=${VENV_PATH}
|
|
RUN uv venv $VIRTUAL_ENV
|
|
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
|
|
|
# Copy storage metadata for editable dependency resolution
|
|
COPY storage/pyproject.toml storage/uv.lock storage/
|
|
|
|
# ------------------ Install kserve dependencies ------------------
|
|
COPY kserve/pyproject.toml kserve/uv.lock kserve/
|
|
RUN cd kserve && uv sync --active --no-cache
|
|
|
|
# Copy source code separately (better Docker caching)
|
|
COPY kserve kserve
|
|
RUN cd kserve && uv sync --active --no-cache
|
|
|
|
# ------------------ Install aiffairness dependencies ------------------
|
|
COPY aiffairness/pyproject.toml aiffairness/uv.lock aiffairness/
|
|
RUN cd aiffairness && uv sync --active --no-cache
|
|
|
|
COPY aiffairness aiffairness
|
|
RUN cd aiffairness && uv sync --active --no-cache
|
|
|
|
# Generate third-party licenses
|
|
COPY pyproject.toml pyproject.toml
|
|
COPY third_party/pip-licenses.py pip-licenses.py
|
|
# TODO: Remove this when upgrading to python 3.11+
|
|
RUN pip install --no-cache-dir tomli
|
|
RUN mkdir -p third_party/library && python3 pip-licenses.py
|
|
|
|
|
|
# ------------------ Final Stage ------------------
|
|
FROM ${BASE_IMAGE} AS prod
|
|
|
|
# Activate virtual env
|
|
ARG VENV_PATH
|
|
ENV VIRTUAL_ENV=${VENV_PATH}
|
|
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
|
|
|
RUN useradd kserve -m -u 1000 -d /home/kserve
|
|
|
|
COPY --from=builder --chown=kserve:kserve third_party third_party
|
|
COPY --from=builder --chown=kserve:kserve $VIRTUAL_ENV $VIRTUAL_ENV
|
|
COPY --from=builder kserve kserve
|
|
COPY --from=builder aiffairness aiffairness
|
|
|
|
USER 1000
|
|
ENV PYTHONPATH=/aiffairness
|
|
ENTRYPOINT ["python", "-m", "aifserver"]
|