Merge pull request #995 from wallies/patch-1

multistage docker build
This commit is contained in:
Krish Dholakia 2023-12-12 17:32:46 -08:00 • committed by GitHub
commit 1b94256889
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 11 deletions

View file

@ -1,8 +1,11 @@
# Base image
ARG LITELLM_BASE_IMAGE=python:3.9-slim
ARG LITELLM_BUILD_IMAGE=python:3.9
# allow users to specify, else use python 3.9-slim
FROM $LITELLM_BASE_IMAGE
# Runtime image
ARG LITELLM_RUNTIME_IMAGE=python:3.9-slim
# allow users to specify, else use python 3.9
FROM $LITELLM_BUILD_IMAGE as builder
# Set the working directory to /app
WORKDIR /app
@ -13,11 +16,23 @@ 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 .
# 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 wheel && \
pip wheel --no-cache-dir --wheel-dir=/app/wheels -r requirements.txt
###############################################################################
FROM $LITELLM_RUNTIME_IMAGE as runtime
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . .
COPY --from=builder /app/wheels /app/wheels
RUN pip install --no-index --find-links=/app/wheels -r requirements.txt
# Trigger the Prisma CLI to be installed
RUN prisma -v
@ -25,7 +40,6 @@ RUN prisma -v
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"]

View file

@ -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