mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 02:34:29 +00:00
feat(dockerfile): pre-download tiktoken in offline non_root image
This commit is contained in:
parent
23685e93f3
commit
a82d45e6ad
1 changed files with 8 additions and 0 deletions
|
@ -35,6 +35,10 @@ RUN pip install dist/*.whl
|
||||||
# install dependencies as wheels
|
# install dependencies as wheels
|
||||||
RUN pip wheel --no-cache-dir --wheel-dir=/wheels/ -r requirements.txt
|
RUN pip wheel --no-cache-dir --wheel-dir=/wheels/ -r requirements.txt
|
||||||
|
|
||||||
|
# Download tiktoken for offline usage of image, see https://stackoverflow.com/a/76107077. Let tiktoken itself download the file, to ensure correct naming
|
||||||
|
ENV TIKTOKEN_CACHE_DIR="/tiktoken"
|
||||||
|
RUN mkdir /tiktoken && python -c "import tiktoken; tiktoken.get_encoding('cl100k_base'); print('tiktoken imported successfully')"
|
||||||
|
|
||||||
# Runtime stage
|
# Runtime stage
|
||||||
FROM $LITELLM_RUNTIME_IMAGE AS runtime
|
FROM $LITELLM_RUNTIME_IMAGE AS runtime
|
||||||
|
|
||||||
|
@ -50,6 +54,10 @@ RUN ls -la /app
|
||||||
COPY --from=builder /app/dist/*.whl .
|
COPY --from=builder /app/dist/*.whl .
|
||||||
COPY --from=builder /wheels/ /wheels/
|
COPY --from=builder /wheels/ /wheels/
|
||||||
|
|
||||||
|
# Copy tiktoken from build stage, and set env variable to stop tiktoken from downloading file
|
||||||
|
COPY --from=builder /tiktoken /tiktoken
|
||||||
|
ENV CUSTOM_TIKTOKEN_CACHE_DIR="/tiktoken"
|
||||||
|
|
||||||
# Install the built wheel using pip; again using a wildcard if it's the only file
|
# Install the built wheel using pip; again using a wildcard if it's the only file
|
||||||
RUN pip install *.whl /wheels/* --no-index --find-links=/wheels/ && rm -f *.whl && rm -rf /wheels
|
RUN pip install *.whl /wheels/* --no-index --find-links=/wheels/ && rm -f *.whl && rm -rf /wheels
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue