From 15057d717ab8da9dc0c44203cb7904ae718884ad Mon Sep 17 00:00:00 2001 From: Cameron <561860+wallies@users.noreply.github.com> Date: Sun, 3 Dec 2023 18:38:44 +1000 Subject: [PATCH 1/5] multistage docker build --- Dockerfile | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index fa1147c392c..ea94febdd87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ # Base image -ARG LITELLM_BASE_IMAGE=python:3.9-slim +ARG LITELLM_BASE_IMAGE=python:3.9 -# allow users to specify, else use python 3.9-slim -FROM $LITELLM_BASE_IMAGE +# allow users to specify, else use python 3.9 +FROM $LITELLM_BASE_IMAGE as builder # Set the working directory to /app WORKDIR /app @@ -13,16 +13,37 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* # Copy the current directory contents into the container at /app -COPY . /app +COPY requirements.txt . + +# Make a virtualenv that we can copy across multistage builds +ENV VIRTUAL_ENV=/venv +RUN python -m venv $VIRTUAL_ENV +# "Activate" the virtualenv +ENV PATH="$VIRTUAL_ENV/bin:$PATH" # Install any needed packages specified in requirements.txt -RUN pip wheel --no-cache-dir --wheel-dir=wheels -r requirements.txt -RUN pip install --no-cache-dir --find-links=wheels -r requirements.txt +RUN pip install --no-cache-dir -r /app/requirements.txt + +############################################################################### +# Runtime image +ARG LITELLM_RUNTIME_IMAGE=python:3.9-slim + +FROM $LITELLM_RUNTIME_IMAGE as runtime + +WORKDIR /app + +# Copy the current directory contents into the container at /app +COPY . . + +# "Activate" the virtualenv +ENV VIRTUAL_ENV=/venv +ENV PATH="$VIRTUAL_ENV/bin:$PATH" + +COPY --from=builder /venv /venv EXPOSE 4000/tcp # Start the litellm proxy, using the `litellm` cli command https://docs.litellm.ai/docs/simple_proxy - # Start the litellm proxy with default options CMD ["--port", "4000"] From 3fc9272640800186792c7ca3dd03cf0b8b915a36 Mon Sep 17 00:00:00 2001 From: Cam Parry Date: Wed, 6 Dec 2023 08:55:53 +1000 Subject: [PATCH 2/5] fix: theNav hrefs --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index ea94febdd87..e29fe426996 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,9 @@ # Base image ARG LITELLM_BASE_IMAGE=python:3.9 +# Runtime image +ARG LITELLM_RUNTIME_IMAGE=python:3.9-slim + # allow users to specify, else use python 3.9 FROM $LITELLM_BASE_IMAGE as builder @@ -25,9 +28,6 @@ ENV PATH="$VIRTUAL_ENV/bin:$PATH" RUN pip install --no-cache-dir -r /app/requirements.txt ############################################################################### -# Runtime image -ARG LITELLM_RUNTIME_IMAGE=python:3.9-slim - FROM $LITELLM_RUNTIME_IMAGE as runtime WORKDIR /app From c99466bc25a63c9e5bbc8571fe9cdb93f9401235 Mon Sep 17 00:00:00 2001 From: Cameron <561860+wallies@users.noreply.github.com> Date: Wed, 6 Dec 2023 09:21:00 +1000 Subject: [PATCH 3/5] Update Dockerfile --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e29fe426996..aa7964fca06 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ # Base image -ARG LITELLM_BASE_IMAGE=python:3.9 +ARG LITELLM_BUILD_IMAGE=python:3.9 # Runtime image ARG LITELLM_RUNTIME_IMAGE=python:3.9-slim # allow users to specify, else use python 3.9 -FROM $LITELLM_BASE_IMAGE as builder +FROM $LITELLM_BUILD_IMAGE as builder # Set the working directory to /app WORKDIR /app From dc1904ea1e46302105fc66aeb04f52b95dd1345c Mon Sep 17 00:00:00 2001 From: Cam Parry Date: Mon, 11 Dec 2023 02:33:21 -1000 Subject: [PATCH 4/5] use wheels --- Dockerfile | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index aa7964fca06..da7bb722348 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,14 +18,9 @@ RUN apt-get update && \ # Copy the current directory contents into the container at /app COPY requirements.txt . -# Make a virtualenv that we can copy across multistage builds -ENV VIRTUAL_ENV=/venv -RUN python -m venv $VIRTUAL_ENV -# "Activate" the virtualenv -ENV PATH="$VIRTUAL_ENV/bin:$PATH" - # Install any needed packages specified in requirements.txt -RUN pip install --no-cache-dir -r /app/requirements.txt +RUN pip install wheel && \ + pip wheel --no-cache-dir --wheel-dir=/app/wheels -r requirements.txt ############################################################################### FROM $LITELLM_RUNTIME_IMAGE as runtime @@ -35,11 +30,9 @@ WORKDIR /app # Copy the current directory contents into the container at /app COPY . . -# "Activate" the virtualenv -ENV VIRTUAL_ENV=/venv -ENV PATH="$VIRTUAL_ENV/bin:$PATH" +COPY --from=builder /app/wheels /app/wheels -COPY --from=builder /venv /venv +RUN pip install --no-index --find-links=/app/wheels -r requirements.txt EXPOSE 4000/tcp From 30faef5052c23d8b07536f390b76e01d264317fa Mon Sep 17 00:00:00 2001 From: Cam Parry Date: Wed, 13 Dec 2023 09:30:14 +1000 Subject: [PATCH 5/5] rebase and docs --- docs/my-website/docs/proxy/deploy.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/my-website/docs/proxy/deploy.md b/docs/my-website/docs/proxy/deploy.md index 65ba90eeee3..2dc57b116f7 100644 --- a/docs/my-website/docs/proxy/deploy.md +++ b/docs/my-website/docs/proxy/deploy.md @@ -7,12 +7,12 @@ See the latest available ghcr docker image here: https://github.com/berriai/litellm/pkgs/container/litellm ```shell -docker pull ghcr.io/berriai/litellm:main-v1.10.1 +docker pull ghcr.io/berriai/litellm:main-v1.12.3 ``` ### Run the Docker Image ```shell -docker run ghcr.io/berriai/litellm:main-v1.10.0 +docker run ghcr.io/berriai/litellm:main-v1.12.3 ``` #### Run the Docker Image with LiteLLM CLI args @@ -21,12 +21,12 @@ See all supported CLI args [here](https://docs.litellm.ai/docs/proxy/cli): Here's how you can run the docker image and pass your config to `litellm` ```shell -docker run ghcr.io/berriai/litellm:main-v1.10.0 --config your_config.yaml +docker run ghcr.io/berriai/litellm:main-v1.12.3 --config your_config.yaml ``` Here's how you can run the docker image and start litellm on port 8002 with `num_workers=8` ```shell -docker run ghcr.io/berriai/litellm:main-v1.10.0 --port 8002 --num_workers 8 +docker run ghcr.io/berriai/litellm:main-v1.12.3 --port 8002 --num_workers 8 ``` #### Run the Docker Image using docker compose @@ -42,6 +42,10 @@ Here's an example `docker-compose.yml` file version: "3.9" services: litellm: + build: + context: . + args: + target: runtime image: ghcr.io/berriai/litellm:main ports: - "8000:8000" # Map the container port to the host, change the host port if necessary