npm@latest resolves to 12.0.1, which requires node ^22.22.2 || ^24.15.0 || >=26.0.0. The image pins NODE_PACKAGE_VERSION=22.22.0, so the install fails with EBADENGINE and the API build cannot complete. The float is the defect: this step passed until npm 12 raised its node floor. Pin the major so the build stops depending on npm's release schedule.
112 lines
3.5 KiB
Docker
112 lines
3.5 KiB
Docker
# base image
|
|
FROM langgenius/python:3-debian13-sfw-ent-dev AS base
|
|
|
|
WORKDIR /app/api
|
|
|
|
# Install uv
|
|
ENV UV_VERSION=0.8.9
|
|
|
|
RUN pip3 install --no-cache-dir uv==${UV_VERSION}
|
|
|
|
# production stage
|
|
FROM base AS production
|
|
|
|
ENV FLASK_APP=app.py
|
|
ENV EDITION=SELF_HOSTED
|
|
ENV DEPLOY_ENV=PRODUCTION
|
|
Env CONSOLE_API_URL=http://127.0.0.1:5001
|
|
ENV CONSOLE_WEB_URL=http://127.0.0.1:3000
|
|
ENV SERVICE_API_URL=http://127.0.0.1:5001
|
|
ENV APP_WEB_URL=http://127.0.0.1:3000
|
|
|
|
EXPOSE 5001
|
|
|
|
# set timezone
|
|
ENV TZ=UTC
|
|
|
|
# Set UTF-8 locale
|
|
ENV LANG=en_US.UTF-8
|
|
ENV LC_ALL=en_US.UTF-8
|
|
ENV PYTHONIOENCODING=utf-8
|
|
|
|
WORKDIR /app/api
|
|
|
|
# Create non-root user
|
|
ARG dify_uid=1001
|
|
ARG NODE_MAJOR=22
|
|
ARG NODE_PACKAGE_VERSION=22.22.0-1nodesource1
|
|
ARG NODESOURCE_KEY_FPR=6F71F525282841EEDAF851B42F59B5F99B1BE0B4
|
|
|
|
RUN \
|
|
apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
ca-certificates \
|
|
curl \
|
|
gnupg \
|
|
&& mkdir -p /etc/apt/keyrings \
|
|
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key -o /tmp/nodesource.gpg \
|
|
&& gpg --show-keys --with-colons /tmp/nodesource.gpg \
|
|
| awk -F: '/^fpr:/ {print $10}' \
|
|
| grep -Fx "${NODESOURCE_KEY_FPR}" \
|
|
&& gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg /tmp/nodesource.gpg \
|
|
&& rm -f /tmp/nodesource.gpg \
|
|
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" \
|
|
> /etc/apt/sources.list.d/nodesource.list \
|
|
&& apt-get update \
|
|
# Install dependencies
|
|
&& apt-get install -y --no-install-recommends \
|
|
# basic environment
|
|
nodejs=${NODE_PACKAGE_VERSION} \
|
|
# for gmpy2 \
|
|
libgmp-dev libmpfr-dev libmpc-dev \
|
|
passwd \
|
|
g++ \
|
|
# For Security
|
|
expat libldap-dev perl libsqlite3-dev zlib1g \
|
|
# install fonts to support the use of tools like pypdfium2
|
|
fonts-noto-cjk \
|
|
# install a package to improve the accuracy of guessing mime type and file extension
|
|
media-types \
|
|
# install libmagic to support the use of python-magic guess MIMETYPE
|
|
libmagic1 \
|
|
&& apt-get autoremove -y \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Pinned to the 11.x line: npm@latest floats, and 12.x requires node >=22.22.2,
|
|
# which the pinned NODE_PACKAGE_VERSION above does not satisfy.
|
|
RUN npm install -g npm@11
|
|
|
|
RUN groupadd -r -g ${dify_uid} dify && \
|
|
useradd -r -u ${dify_uid} -g ${dify_uid} -s /bin/bash dify && \
|
|
chown -R dify:dify /app
|
|
# Copy Python environment and packages
|
|
ENV VIRTUAL_ENV=/app/api/.venv
|
|
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
|
|
|
|
# Copy source code
|
|
COPY --chown=dify:dify . /app/api
|
|
# Prepare entrypoint script
|
|
COPY --chown=dify:dify --chmod=755 docker/entrypoint.sh /entrypoint.sh
|
|
|
|
RUN uv sync --frozen --no-dev && pip3 install --no-cache-dir --upgrade "wheel==0.46.3" "jaraco.context==6.1.0" "setuptools==80.10.2" && uv cache clean && rm -rf /root/.cache/pip
|
|
|
|
# Download nltk data
|
|
RUN mkdir -p /usr/local/share/nltk_data \
|
|
&& NLTK_DATA=/usr/local/share/nltk_data python -c "import nltk; from unstructured.nlp.tokenize import download_nltk_packages; nltk.download('punkt'); nltk.download('averaged_perceptron_tagger'); nltk.download('stopwords'); download_nltk_packages()" \
|
|
&& chmod -R 755 /usr/local/share/nltk_data
|
|
|
|
ENV TIKTOKEN_CACHE_DIR=/app/api/.tiktoken_cache
|
|
|
|
RUN python -c "import tiktoken; tiktoken.encoding_for_model('gpt2')" \
|
|
&& chown -R dify:dify ${TIKTOKEN_CACHE_DIR}
|
|
|
|
|
|
|
|
ARG COMMIT_SHA
|
|
ENV COMMIT_SHA=${COMMIT_SHA}
|
|
ENV NLTK_DATA=/usr/local/share/nltk_data
|
|
|
|
USER dify
|
|
|
|
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
|