2024-01-08 13:07:47 +08:00
|
|
|
# Base image for building
|
2025-01-08 12:35:57 +08:00
|
|
|
ARG LITELLM_BUILD_IMAGE=cgr.dev/chainguard/python:latest-dev
|
2023-12-01 06:49:21 +08:00
|
|
|
|
2023-12-06 06:55:53 +08:00
|
|
|
# Runtime image
|
2025-01-08 12:35:57 +08:00
|
|
|
ARG LITELLM_RUNTIME_IMAGE=cgr.dev/chainguard/python:latest-dev
|
2024-01-08 13:07:47 +08:00
|
|
|
# Builder stage
|
2024-09-21 23:21:11 +08:00
|
|
|
FROM $LITELLM_BUILD_IMAGE AS builder
|
2024-01-08 13:07:47 +08:00
|
|
|
|
|
|
|
|
# Set the working directory to /app
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
2025-01-08 12:35:57 +08:00
|
|
|
USER root
|
|
|
|
|
|
2024-01-08 13:07:47 +08:00
|
|
|
# Install build dependencies
|
2025-04-09 00:03:25 +08:00
|
|
|
RUN apk add --no-cache gcc python3-dev openssl openssl-dev
|
2025-01-08 12:35:57 +08:00
|
|
|
|
2024-01-08 13:07:47 +08:00
|
|
|
|
|
|
|
|
RUN pip install --upgrade pip && \
|
|
|
|
|
pip install build
|
|
|
|
|
|
|
|
|
|
# Copy the current directory contents into the container at /app
|
|
|
|
|
COPY . .
|
|
|
|
|
|
2024-02-22 13:28:56 +08:00
|
|
|
# Build Admin UI
|
2024-10-08 14:04:43 +08:00
|
|
|
RUN chmod +x docker/build_admin_ui.sh && ./docker/build_admin_ui.sh
|
2024-02-22 13:28:56 +08:00
|
|
|
|
2024-01-08 13:07:47 +08:00
|
|
|
# Build the package
|
|
|
|
|
RUN rm -rf dist/* && python -m build
|
|
|
|
|
|
|
|
|
|
# There should be only one wheel file now, assume the build only creates one
|
|
|
|
|
RUN ls -1 dist/*.whl | head -1
|
|
|
|
|
|
|
|
|
|
# Install the package
|
|
|
|
|
RUN pip install dist/*.whl
|
|
|
|
|
|
|
|
|
|
# install dependencies as wheels
|
|
|
|
|
RUN pip wheel --no-cache-dir --wheel-dir=/wheels/ -r requirements.txt
|
2023-12-03 16:38:44 +08:00
|
|
|
|
2024-03-20 07:59:59 +08:00
|
|
|
# ensure pyjwt is used, not jwt
|
|
|
|
|
RUN pip uninstall jwt -y
|
|
|
|
|
RUN pip uninstall PyJWT -y
|
2024-09-27 22:51:20 +08:00
|
|
|
RUN pip install PyJWT==2.9.0 --no-cache-dir
|
2024-03-20 07:59:59 +08:00
|
|
|
|
2024-02-22 13:02:46 +08:00
|
|
|
# Build Admin UI
|
2024-10-08 14:04:43 +08:00
|
|
|
RUN chmod +x docker/build_admin_ui.sh && ./docker/build_admin_ui.sh
|
2024-02-22 13:02:46 +08:00
|
|
|
|
2023-12-17 08:01:02 +08:00
|
|
|
# Runtime stage
|
2024-09-21 23:21:11 +08:00
|
|
|
FROM $LITELLM_RUNTIME_IMAGE AS runtime
|
2023-12-03 16:38:44 +08:00
|
|
|
|
2025-01-08 12:35:57 +08:00
|
|
|
# Ensure runtime stage runs as root
|
|
|
|
|
USER root
|
|
|
|
|
|
|
|
|
|
# Install runtime dependencies
|
2025-04-09 00:03:25 +08:00
|
|
|
RUN apk add --no-cache openssl
|
2024-09-24 08:58:22 +08:00
|
|
|
|
2023-12-17 08:01:02 +08:00
|
|
|
WORKDIR /app
|
2024-01-06 17:29:10 +08:00
|
|
|
# Copy the current directory contents into the container at /app
|
|
|
|
|
COPY . .
|
|
|
|
|
RUN ls -la /app
|
2023-12-03 16:38:44 +08:00
|
|
|
|
2023-12-17 08:01:02 +08:00
|
|
|
# Copy the built wheel from the builder stage to the runtime stage; assumes only one wheel file is present
|
2024-01-08 13:07:47 +08:00
|
|
|
COPY --from=builder /app/dist/*.whl .
|
|
|
|
|
COPY --from=builder /wheels/ /wheels/
|
2024-01-08 10:32:50 +08:00
|
|
|
|
2023-12-17 08:01:02 +08:00
|
|
|
# Install the built wheel using pip; again using a wildcard if it's the only file
|
2024-01-09 16:14:37 +08:00
|
|
|
RUN pip install *.whl /wheels/* --no-index --find-links=/wheels/ && rm -f *.whl && rm -rf /wheels
|
2024-01-08 10:32:50 +08:00
|
|
|
|
2024-03-15 00:10:56 +08:00
|
|
|
# Generate prisma client
|
|
|
|
|
RUN prisma generate
|
2024-10-08 14:04:43 +08:00
|
|
|
RUN chmod +x docker/entrypoint.sh
|
2025-01-07 09:27:09 +08:00
|
|
|
RUN chmod +x docker/prod_entrypoint.sh
|
2024-01-09 15:40:03 +08:00
|
|
|
|
2024-01-08 13:07:47 +08:00
|
|
|
EXPOSE 4000/tcp
|
2023-11-23 17:19:54 +08:00
|
|
|
|
2025-01-07 09:27:09 +08:00
|
|
|
ENTRYPOINT ["docker/prod_entrypoint.sh"]
|
2024-03-07 08:31:32 +08:00
|
|
|
|
|
|
|
|
# Append "--detailed_debug" to the end of CMD to view detailed debug logs
|
2024-04-09 04:23:56 +08:00
|
|
|
CMD ["--port", "4000"]
|