litellm
/
Dockerfile
73 строки · 2.0 Кб
1# Base image for building
2ARG LITELLM_BUILD_IMAGE=python:3.11.8-slim
3
4# Runtime image
5ARG LITELLM_RUNTIME_IMAGE=python:3.11.8-slim
6# Builder stage
7FROM $LITELLM_BUILD_IMAGE as builder
8
9# Set the working directory to /app
10WORKDIR /app
11
12# Install build dependencies
13RUN apt-get clean && apt-get update && \
14apt-get install -y gcc python3-dev && \
15rm -rf /var/lib/apt/lists/*
16
17RUN pip install --upgrade pip && \
18pip install build
19
20# Copy the current directory contents into the container at /app
21COPY . .
22
23# Build Admin UI
24RUN chmod +x build_admin_ui.sh && ./build_admin_ui.sh
25
26# Build the package
27RUN rm -rf dist/* && python -m build
28
29# There should be only one wheel file now, assume the build only creates one
30RUN ls -1 dist/*.whl | head -1
31
32# Install the package
33RUN pip install dist/*.whl
34
35# install dependencies as wheels
36RUN pip wheel --no-cache-dir --wheel-dir=/wheels/ -r requirements.txt
37
38# install semantic-cache [Experimental]- we need this here and not in requirements.txt because redisvl pins to pydantic 1.0
39RUN pip install redisvl==0.0.7 --no-deps
40
41# ensure pyjwt is used, not jwt
42RUN pip uninstall jwt -y
43RUN pip uninstall PyJWT -y
44RUN pip install PyJWT --no-cache-dir
45
46# Build Admin UI
47RUN chmod +x build_admin_ui.sh && ./build_admin_ui.sh
48
49# Runtime stage
50FROM $LITELLM_RUNTIME_IMAGE as runtime
51
52WORKDIR /app
53# Copy the current directory contents into the container at /app
54COPY . .
55RUN ls -la /app
56
57# Copy the built wheel from the builder stage to the runtime stage; assumes only one wheel file is present
58COPY --from=builder /app/dist/*.whl .
59COPY --from=builder /wheels/ /wheels/
60
61# Install the built wheel using pip; again using a wildcard if it's the only file
62RUN pip install *.whl /wheels/* --no-index --find-links=/wheels/ && rm -f *.whl && rm -rf /wheels
63
64# Generate prisma client
65RUN prisma generate
66RUN chmod +x entrypoint.sh
67
68EXPOSE 4000/tcp
69
70ENTRYPOINT ["litellm"]
71
72# Append "--detailed_debug" to the end of CMD to view detailed debug logs
73CMD ["--port", "4000"]
74