mirror of
https://github.com/langgenius/dify.git
synced 2025-12-21 06:54:41 +00:00
Compare commits
5 Commits
fix/loop-i
...
slim-api-d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43c2b869b3 | ||
|
|
ae3caa6160 | ||
|
|
849e86ee6a | ||
|
|
ada9aafe3e | ||
|
|
cf51c9cb01 |
@@ -1,6 +1,26 @@
|
|||||||
.env
|
.env
|
||||||
*.env.*
|
*.env.*
|
||||||
|
|
||||||
|
# VCS and editor noise
|
||||||
|
.git
|
||||||
|
.DS_Store
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
*.pyo
|
||||||
|
*.swp
|
||||||
|
.vscode
|
||||||
|
|
||||||
|
# Large or irrelevant project files
|
||||||
|
docs/
|
||||||
|
dev/
|
||||||
|
images/
|
||||||
|
|
||||||
|
|
||||||
|
# Local caches
|
||||||
|
.pytest_cache
|
||||||
|
.ruff_cache
|
||||||
|
.mypy_cache
|
||||||
|
|
||||||
storage/generate_files/*
|
storage/generate_files/*
|
||||||
storage/privkeys/*
|
storage/privkeys/*
|
||||||
storage/tools/*
|
storage/tools/*
|
||||||
@@ -12,8 +32,6 @@ logs
|
|||||||
|
|
||||||
# jetbrains
|
# jetbrains
|
||||||
.idea
|
.idea
|
||||||
.mypy_cache
|
|
||||||
.ruff_cache
|
|
||||||
|
|
||||||
# venv
|
# venv
|
||||||
.venv
|
.venv
|
||||||
|
|||||||
@@ -19,11 +19,15 @@ RUN apt-get update \
|
|||||||
# basic environment
|
# basic environment
|
||||||
g++ \
|
g++ \
|
||||||
# for building gmpy2
|
# for building gmpy2
|
||||||
libmpfr-dev libmpc-dev
|
libmpfr-dev libmpc-dev \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install Python dependencies
|
# Install Python dependencies
|
||||||
COPY pyproject.toml uv.lock ./
|
COPY pyproject.toml uv.lock ./
|
||||||
RUN uv sync --locked --no-dev
|
# Export without hashes because we'll build local wheels (hashes would mismatch)
|
||||||
|
RUN uv export --locked --no-dev --format requirements.txt --no-hashes --output-file /tmp/requirements.txt \
|
||||||
|
&& pip wheel --no-cache-dir -r /tmp/requirements.txt -w /wheels \
|
||||||
|
&& uv cache prune --ci
|
||||||
|
|
||||||
# production stage
|
# production stage
|
||||||
FROM base AS production
|
FROM base AS production
|
||||||
@@ -54,10 +58,10 @@ RUN groupadd -r -g ${dify_uid} dify && \
|
|||||||
useradd -r -u ${dify_uid} -g ${dify_uid} -s /bin/bash dify && \
|
useradd -r -u ${dify_uid} -g ${dify_uid} -s /bin/bash dify && \
|
||||||
chown -R dify:dify /app
|
chown -R dify:dify /app
|
||||||
|
|
||||||
RUN \
|
RUN set -eux; \
|
||||||
apt-get update \
|
apt-get update; \
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
&& apt-get install -y --no-install-recommends \
|
apt-get install -y --no-install-recommends \
|
||||||
# basic environment
|
# basic environment
|
||||||
curl nodejs \
|
curl nodejs \
|
||||||
# for gmpy2 \
|
# for gmpy2 \
|
||||||
@@ -67,33 +71,33 @@ RUN \
|
|||||||
# install fonts to support the use of tools like pypdfium2
|
# install fonts to support the use of tools like pypdfium2
|
||||||
fonts-noto-cjk \
|
fonts-noto-cjk \
|
||||||
# install a package to improve the accuracy of guessing mime type and file extension
|
# install a package to improve the accuracy of guessing mime type and file extension
|
||||||
media-types \
|
media-types \
|
||||||
# install libmagic to support the use of python-magic guess MIMETYPE
|
# install libmagic to support the use of python-magic guess MIMETYPE
|
||||||
libmagic1 \
|
libmagic1; \
|
||||||
&& apt-get autoremove -y \
|
apt-get autoremove -y; \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Copy Python environment and packages
|
# Install Python packages from prebuilt wheels (no virtualenv to avoid copying ~1.8GB layer)
|
||||||
ENV VIRTUAL_ENV=/app/api/.venv
|
COPY --from=packages /tmp/requirements.txt /tmp/requirements.txt
|
||||||
COPY --from=packages --chown=dify:dify ${VIRTUAL_ENV} ${VIRTUAL_ENV}
|
COPY --from=packages /wheels /wheels
|
||||||
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
|
RUN pip install --no-cache-dir --no-index --find-links /wheels -r /tmp/requirements.txt \
|
||||||
|
&& rm -rf /wheels /tmp/requirements.txt
|
||||||
# Download nltk data
|
|
||||||
RUN mkdir -p /usr/local/share/nltk_data && NLTK_DATA=/usr/local/share/nltk_data python -c "import nltk; nltk.download('punkt'); nltk.download('averaged_perceptron_tagger'); nltk.download('stopwords')" \
|
|
||||||
&& chmod -R 755 /usr/local/share/nltk_data
|
|
||||||
|
|
||||||
ENV TIKTOKEN_CACHE_DIR=/app/api/.tiktoken_cache
|
ENV TIKTOKEN_CACHE_DIR=/app/api/.tiktoken_cache
|
||||||
|
|
||||||
RUN python -c "import tiktoken; tiktoken.encoding_for_model('gpt2')" \
|
# Pre-fetch NLTK data and warm tiktoken cache before copying source to maximize layer reuse
|
||||||
|
RUN set -eux; \
|
||||||
|
mkdir -p /usr/local/share/nltk_data; \
|
||||||
|
NLTK_DATA=/usr/local/share/nltk_data python -c "import nltk; nltk.download('punkt'); nltk.download('averaged_perceptron_tagger'); nltk.download('stopwords')"; \
|
||||||
|
chmod -R 755 /usr/local/share/nltk_data; \
|
||||||
|
python -c "import tiktoken; tiktoken.encoding_for_model('gpt2')" \
|
||||||
&& chown -R dify:dify ${TIKTOKEN_CACHE_DIR}
|
&& chown -R dify:dify ${TIKTOKEN_CACHE_DIR}
|
||||||
|
|
||||||
# Copy source code
|
# Copy source code
|
||||||
COPY --chown=dify:dify . /app/api/
|
COPY --chown=dify:dify . /app/api/
|
||||||
|
|
||||||
# Prepare entrypoint script
|
# Prepare entrypoint script
|
||||||
COPY --chown=dify:dify --chmod=755 docker/entrypoint.sh /entrypoint.sh
|
COPY --chown=dify:dify --chmod=755 docker/entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
|
|
||||||
ARG COMMIT_SHA
|
ARG COMMIT_SHA
|
||||||
ENV COMMIT_SHA=${COMMIT_SHA}
|
ENV COMMIT_SHA=${COMMIT_SHA}
|
||||||
ENV NLTK_DATA=/usr/local/share/nltk_data
|
ENV NLTK_DATA=/usr/local/share/nltk_data
|
||||||
|
|||||||
Reference in New Issue
Block a user