# syntax=docker/dockerfile:1 FROM langgenius/dify-web:1.18.0@sha256:e55a6bf1addf109c3655567663f906624f0980061efed864e0f07d23c71fa385 AS web RUN tar -cf /tmp/web.tar -C /app targets/next FROM langgenius/dify-plugin-daemon:0.6.10-local@sha256:34412a22d1e1d1a6c73727fef88cffbcdd9be7a21bf9ad3076b4bf5c1b88fd9b AS plugin FROM langgenius/dify-sandbox:0.2.15@sha256:750e1111426ef31a9217b81c98cccfb750f17b182af3221102e420afa9f0928e AS sandbox RUN tar -cf /tmp/sandbox-root.tar -C / bin sbin lib lib64 usr opt var etc conf main entrypoint.sh root FROM pgvector/pgvector:pg15-bookworm@sha256:47af0b65960b14f1c6945aa4ccae37836c632e9a6fe0eea9160936e616e5b2e9 AS vector FROM langgenius/dify-api:1.18.0@sha256:0120970fb4ea59aa328d63b7dda635cccc071efb8aae470cd07115a026dbffd3 USER root RUN printf '#!/bin/sh\nexit 101\n' > /usr/sbin/policy-rc.d \ && apt-get update && apt-get install -y --no-install-recommends postgresql-15 postgresql-client-15 redis-server nginx squid ca-certificates \ && rm -rf /var/lib/apt/lists/* \ && (getent passwd 1000 || useradd -m -u 1000 hfapp) COPY --from=vector /usr/lib/postgresql/15/lib/vector.so /usr/lib/postgresql/15/lib/vector.so COPY --from=vector /usr/share/postgresql/15/extension/vector* /usr/share/postgresql/15/extension/ COPY --from=web /tmp/web.tar /tmp/web.tar RUN tar -xf /tmp/web.tar -C /app && rm /tmp/web.tar COPY --from=web /app/entrypoint.sh /opt/hf-dify/web-entrypoint.sh COPY --from=plugin /app /opt/dify-plugin COPY --from=sandbox /tmp/sandbox-root.tar /tmp/sandbox-root.tar RUN mkdir -p /opt/dify-sandbox/dev /opt/dify-sandbox/tmp /opt/dify-sandbox/proc /opt/dify-sandbox/run \ && tar -xf /tmp/sandbox-root.tar -C /opt/dify-sandbox && rm /tmp/sandbox-root.tar && chmod 1777 /opt/dify-sandbox/tmp RUN chroot /opt/dify-sandbox /bin/bash -c 'tar -xf /opt/node-v20.20.0-linux-x64.tar.xz -C /opt && mkdir -p /usr/local/bin && ln -sf /opt/node-v20.20.0-linux-x64/bin/node /usr/local/bin/node' \ && uv venv /opt/hf-sync && uv pip install --python /opt/hf-sync/bin/python huggingface_hub==1.10.2 \ && chown -R 1000:1000 /app/targets /opt/dify-plugin && chown 1000:1000 /app/api /app/api/storage \ && mkdir -p /state /run/hf-dify COPY hf-dify/ /opt/hf-dify/ RUN chmod +x /opt/hf-dify/*.sh && python -m compileall -q /opt/hf-dify \ && /usr/sbin/nginx -t -c /opt/hf-dify/nginx.conf ENV PYTHONUNBUFFERED=1 HF_HUB_DISABLE_TELEMETRY=1 DO_NOT_TRACK=1 EXPOSE 7860 WORKDIR /app/api ENTRYPOINT ["/opt/hf-sync/bin/python", "/opt/hf-dify/runtime.py"]