Spaces:
Running
Running
github-actions[bot] commited on
Commit ·
10fc7f0
1
Parent(s): d1c780a
deploy: ebc2c38 — 更新 Dockerfile.huggingface
Browse files- Dockerfile +28 -13
- Dockerfile.huggingface +28 -13
Dockerfile
CHANGED
|
@@ -12,15 +12,26 @@
|
|
| 12 |
# [Bug3] npm install --omit=dev (--only=production deprecated in npm v10)
|
| 13 |
# [Bug5] ARG LITELLM_VERSION for single-source versioning
|
| 14 |
# [BugP] prisma generate — LiteLLM v1.61+ initialises its Prisma client at
|
| 15 |
-
# lifespan startup whenever database_url is present in config.
|
| 16 |
-
#
|
| 17 |
-
#
|
| 18 |
-
#
|
| 19 |
# ModuleNotFoundError: No module named 'prisma'
|
| 20 |
# Exception: Unable to find Prisma binaries.
|
| 21 |
# Please run 'prisma generate' first.
|
| 22 |
-
#
|
| 23 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
FROM node:20-alpine AS frontend-builder
|
| 26 |
WORKDIR /build
|
|
@@ -36,6 +47,11 @@ FROM python:3.11-slim
|
|
| 36 |
|
| 37 |
ARG LITELLM_VERSION=1.81.14
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 40 |
curl gnupg ca-certificates nginx supervisor build-essential \
|
| 41 |
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
|
@@ -43,17 +59,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 43 |
&& apt-get purge -y gnupg && apt-get autoremove -y \
|
| 44 |
&& rm -rf /var/lib/apt/lists/*
|
| 45 |
|
| 46 |
-
#
|
| 47 |
-
#
|
| 48 |
-
#
|
| 49 |
-
#
|
| 50 |
-
# <litellm_package_dir>/proxy/schema.prisma
|
| 51 |
-
# We locate it dynamically so the path stays correct across LiteLLM versions.
|
| 52 |
RUN pip install --no-cache-dir "litellm[proxy]==${LITELLM_VERSION}" \
|
|
|
|
| 53 |
&& SCHEMA_PATH=$(python3 -c \
|
| 54 |
"import litellm, os; \
|
| 55 |
print(os.path.join(os.path.dirname(litellm.__file__), 'proxy', 'schema.prisma'))") \
|
| 56 |
-
&& echo "Running
|
| 57 |
&& prisma generate --schema "${SCHEMA_PATH}"
|
| 58 |
|
| 59 |
RUN useradd -m -u 1000 -s /bin/bash user
|
|
|
|
| 12 |
# [Bug3] npm install --omit=dev (--only=production deprecated in npm v10)
|
| 13 |
# [Bug5] ARG LITELLM_VERSION for single-source versioning
|
| 14 |
# [BugP] prisma generate — LiteLLM v1.61+ initialises its Prisma client at
|
| 15 |
+
# lifespan startup whenever database_url is present in config. The
|
| 16 |
+
# prisma-client-py package requires the Prisma query-engine binary to
|
| 17 |
+
# exist before the process starts. Without this step the container
|
| 18 |
+
# crashes immediately with:
|
| 19 |
# ModuleNotFoundError: No module named 'prisma'
|
| 20 |
# Exception: Unable to find Prisma binaries.
|
| 21 |
# Please run 'prisma generate' first.
|
| 22 |
+
#
|
| 23 |
+
# IMPORTANT — cache-dir alignment:
|
| 24 |
+
# prisma-client-py stores the downloaded query-engine binary in
|
| 25 |
+
# PRISMA_BINARY_CACHE_DIR (default: ~/.cache/prisma-binaries/).
|
| 26 |
+
# If we run `prisma generate` as root during the build, binaries land
|
| 27 |
+
# in /root/.cache/. At runtime the container runs as uid=1000 (user),
|
| 28 |
+
# which looks in /home/user/.cache/ — a completely different path, so
|
| 29 |
+
# the binary is never found.
|
| 30 |
+
#
|
| 31 |
+
# Fix: set PRISMA_BINARY_CACHE_DIR=/app/.prisma (a path under /app
|
| 32 |
+
# that gets chowned to user:user later in this file). Both the build
|
| 33 |
+
# step and the runtime process use this same env-var, so the binary is
|
| 34 |
+
# always found regardless of which uid is active.
|
| 35 |
|
| 36 |
FROM node:20-alpine AS frontend-builder
|
| 37 |
WORKDIR /build
|
|
|
|
| 47 |
|
| 48 |
ARG LITELLM_VERSION=1.81.14
|
| 49 |
|
| 50 |
+
# Point prisma-client-py at a stable, user-writable cache directory.
|
| 51 |
+
# This env var must be set before `prisma generate` and must persist into the
|
| 52 |
+
# final container so the runtime process finds the binary in the same place.
|
| 53 |
+
ENV PRISMA_BINARY_CACHE_DIR=/app/.prisma
|
| 54 |
+
|
| 55 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 56 |
curl gnupg ca-certificates nginx supervisor build-essential \
|
| 57 |
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
|
|
|
| 59 |
&& apt-get purge -y gnupg && apt-get autoremove -y \
|
| 60 |
&& rm -rf /var/lib/apt/lists/*
|
| 61 |
|
| 62 |
+
# Install LiteLLM and run prisma generate in a single layer (as root, so
|
| 63 |
+
# pip can write to system site-packages). The query-engine binary is written
|
| 64 |
+
# to $PRISMA_BINARY_CACHE_DIR (/app/.prisma) which is later chowned to
|
| 65 |
+
# user:user, making it readable at runtime.
|
|
|
|
|
|
|
| 66 |
RUN pip install --no-cache-dir "litellm[proxy]==${LITELLM_VERSION}" \
|
| 67 |
+
&& mkdir -p "${PRISMA_BINARY_CACHE_DIR}" \
|
| 68 |
&& SCHEMA_PATH=$(python3 -c \
|
| 69 |
"import litellm, os; \
|
| 70 |
print(os.path.join(os.path.dirname(litellm.__file__), 'proxy', 'schema.prisma'))") \
|
| 71 |
+
&& echo "Running prisma generate --schema ${SCHEMA_PATH}" \
|
| 72 |
&& prisma generate --schema "${SCHEMA_PATH}"
|
| 73 |
|
| 74 |
RUN useradd -m -u 1000 -s /bin/bash user
|
Dockerfile.huggingface
CHANGED
|
@@ -12,15 +12,26 @@
|
|
| 12 |
# [Bug3] npm install --omit=dev (--only=production deprecated in npm v10)
|
| 13 |
# [Bug5] ARG LITELLM_VERSION for single-source versioning
|
| 14 |
# [BugP] prisma generate — LiteLLM v1.61+ initialises its Prisma client at
|
| 15 |
-
# lifespan startup whenever database_url is present in config.
|
| 16 |
-
#
|
| 17 |
-
#
|
| 18 |
-
#
|
| 19 |
# ModuleNotFoundError: No module named 'prisma'
|
| 20 |
# Exception: Unable to find Prisma binaries.
|
| 21 |
# Please run 'prisma generate' first.
|
| 22 |
-
#
|
| 23 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
FROM node:20-alpine AS frontend-builder
|
| 26 |
WORKDIR /build
|
|
@@ -36,6 +47,11 @@ FROM python:3.11-slim
|
|
| 36 |
|
| 37 |
ARG LITELLM_VERSION=1.81.14
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 40 |
curl gnupg ca-certificates nginx supervisor build-essential \
|
| 41 |
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
|
@@ -43,17 +59,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 43 |
&& apt-get purge -y gnupg && apt-get autoremove -y \
|
| 44 |
&& rm -rf /var/lib/apt/lists/*
|
| 45 |
|
| 46 |
-
#
|
| 47 |
-
#
|
| 48 |
-
#
|
| 49 |
-
#
|
| 50 |
-
# <litellm_package_dir>/proxy/schema.prisma
|
| 51 |
-
# We locate it dynamically so the path stays correct across LiteLLM versions.
|
| 52 |
RUN pip install --no-cache-dir "litellm[proxy]==${LITELLM_VERSION}" \
|
|
|
|
| 53 |
&& SCHEMA_PATH=$(python3 -c \
|
| 54 |
"import litellm, os; \
|
| 55 |
print(os.path.join(os.path.dirname(litellm.__file__), 'proxy', 'schema.prisma'))") \
|
| 56 |
-
&& echo "Running
|
| 57 |
&& prisma generate --schema "${SCHEMA_PATH}"
|
| 58 |
|
| 59 |
RUN useradd -m -u 1000 -s /bin/bash user
|
|
|
|
| 12 |
# [Bug3] npm install --omit=dev (--only=production deprecated in npm v10)
|
| 13 |
# [Bug5] ARG LITELLM_VERSION for single-source versioning
|
| 14 |
# [BugP] prisma generate — LiteLLM v1.61+ initialises its Prisma client at
|
| 15 |
+
# lifespan startup whenever database_url is present in config. The
|
| 16 |
+
# prisma-client-py package requires the Prisma query-engine binary to
|
| 17 |
+
# exist before the process starts. Without this step the container
|
| 18 |
+
# crashes immediately with:
|
| 19 |
# ModuleNotFoundError: No module named 'prisma'
|
| 20 |
# Exception: Unable to find Prisma binaries.
|
| 21 |
# Please run 'prisma generate' first.
|
| 22 |
+
#
|
| 23 |
+
# IMPORTANT — cache-dir alignment:
|
| 24 |
+
# prisma-client-py stores the downloaded query-engine binary in
|
| 25 |
+
# PRISMA_BINARY_CACHE_DIR (default: ~/.cache/prisma-binaries/).
|
| 26 |
+
# If we run `prisma generate` as root during the build, binaries land
|
| 27 |
+
# in /root/.cache/. At runtime the container runs as uid=1000 (user),
|
| 28 |
+
# which looks in /home/user/.cache/ — a completely different path, so
|
| 29 |
+
# the binary is never found.
|
| 30 |
+
#
|
| 31 |
+
# Fix: set PRISMA_BINARY_CACHE_DIR=/app/.prisma (a path under /app
|
| 32 |
+
# that gets chowned to user:user later in this file). Both the build
|
| 33 |
+
# step and the runtime process use this same env-var, so the binary is
|
| 34 |
+
# always found regardless of which uid is active.
|
| 35 |
|
| 36 |
FROM node:20-alpine AS frontend-builder
|
| 37 |
WORKDIR /build
|
|
|
|
| 47 |
|
| 48 |
ARG LITELLM_VERSION=1.81.14
|
| 49 |
|
| 50 |
+
# Point prisma-client-py at a stable, user-writable cache directory.
|
| 51 |
+
# This env var must be set before `prisma generate` and must persist into the
|
| 52 |
+
# final container so the runtime process finds the binary in the same place.
|
| 53 |
+
ENV PRISMA_BINARY_CACHE_DIR=/app/.prisma
|
| 54 |
+
|
| 55 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 56 |
curl gnupg ca-certificates nginx supervisor build-essential \
|
| 57 |
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
|
|
|
| 59 |
&& apt-get purge -y gnupg && apt-get autoremove -y \
|
| 60 |
&& rm -rf /var/lib/apt/lists/*
|
| 61 |
|
| 62 |
+
# Install LiteLLM and run prisma generate in a single layer (as root, so
|
| 63 |
+
# pip can write to system site-packages). The query-engine binary is written
|
| 64 |
+
# to $PRISMA_BINARY_CACHE_DIR (/app/.prisma) which is later chowned to
|
| 65 |
+
# user:user, making it readable at runtime.
|
|
|
|
|
|
|
| 66 |
RUN pip install --no-cache-dir "litellm[proxy]==${LITELLM_VERSION}" \
|
| 67 |
+
&& mkdir -p "${PRISMA_BINARY_CACHE_DIR}" \
|
| 68 |
&& SCHEMA_PATH=$(python3 -c \
|
| 69 |
"import litellm, os; \
|
| 70 |
print(os.path.join(os.path.dirname(litellm.__file__), 'proxy', 'schema.prisma'))") \
|
| 71 |
+
&& echo "Running prisma generate --schema ${SCHEMA_PATH}" \
|
| 72 |
&& prisma generate --schema "${SCHEMA_PATH}"
|
| 73 |
|
| 74 |
RUN useradd -m -u 1000 -s /bin/bash user
|