File size: 4,133 Bytes
6904327
9271c2e
8f2f679
cf27663
 
 
 
 
 
 
 
6904327
d0910d6
9271c2e
 
 
007df08
b64f28a
54d9852
6904327
 
8f2f679
 
 
cf27663
8f2f679
 
 
 
 
 
 
 
 
 
cf27663
033307e
8f2f679
 
 
 
 
 
fc81b23
6904327
 
fc81b23
 
 
 
cf27663
 
 
 
 
 
 
 
 
 
 
111c9ea
d75e3b4
fc81b23
d4ea64f
6e8360f
111c9ea
d4ea64f
d75e3b4
a547f1a
fc81b23
cf27663
111c9ea
 
 
6904327
cf27663
a547f1a
6904327
111c9ea
9271c2e
 
 
 
 
 
6904327
8f2f679
6904327
 
 
 
 
 
a547f1a
 
8f2f679
 
 
cf27663
8f2f679
d75e3b4
111c9ea
a547f1a
111c9ea
9271c2e
cf27663
 
f5d0575
6904327
 
 
 
184d251
007df08
cf27663
 
 
d75e3b4
cf27663
 
 
 
 
 
 
 
a547f1a
 
da5c398
 
 
6904327
 
007df08
 
6904327
 
a304801
 
 
1580ab9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# ============================================================
# Dify 1.17.0 All-in-One for Hugging Face Spaces
#
# FIX 2:
# - Keep Dify Web 1.17 runtime at its ORIGINAL absolute paths:
#       /app/targets
#       /app/entrypoint.sh
#   because the official web entrypoint calls
#       /app/targets/next/web/server.js
# - Add ca-certificates for verified Upstash Redis TLS.
# - Keep API/Web/Worker/Plugin/Nginx in one HF container.
# ============================================================

FROM langgenius/dify-web:1.17.0 AS web
FROM langgenius/dify-plugin-daemon:0.6.10-local AS plugin_daemon
FROM langgenius/dify-api:1.17.0

USER root

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        nginx \
        redis-server \
        redis-tools \
        ca-certificates \
        locales \
        curl \
        ffmpeg \
        git \
        build-essential \
        cmake \
        pkg-config \
        libcairo2-dev \
        libjpeg62-turbo-dev \
        libgif-dev \
    && update-ca-certificates \
    && rm -rf /var/lib/apt/lists/* \
    && localedef \
        -i en_US \
        -c \
        -f UTF-8 \
        -A /usr/share/locale/locale.alias \
        en_US.UTF-8 || true

ENV LANG=en_US.UTF-8 \
    LC_ALL=en_US.UTF-8 \
    PYTHONIOENCODING=utf-8 \
    MALLOC_ARENA_MAX=2 \
    NODE_OPTIONS=--max-old-space-size=2048

# ------------------------------------------------------------
# Dify Web 1.17 official runtime layout.
#
# IMPORTANT:
# Do not relocate these into /app/web.
# /app/entrypoint.sh contains absolute /app/targets/... paths.
# ------------------------------------------------------------
COPY --from=web /app/targets /app/targets
COPY --from=web /app/entrypoint.sh /app/entrypoint.sh

# Plugin daemon binary.
COPY --from=plugin_daemon /app/main /opt/dify-plugin-daemon/main
COPY --from=plugin_daemon /app/commandline /opt/dify-plugin-daemon/commandline

COPY nginx.conf /etc/nginx/nginx.conf
COPY start.sh /app/start.sh
COPY hf_state_keeper.py /app/hf_state_keeper.py

ARG FORCE_REBUILD=20260908_DIFY_1170_HF_FIX3_PLUGIN_MIGRATE_CORS
RUN echo "${FORCE_REBUILD}" > /tmp/dify-build-version

# Writable uv cache for local plugins.
RUN install -d -o dify -g dify -m 0755 /home/dify \
    && install -d -o dify -g dify -m 0755 /home/dify/.cache \
    && install -d -o dify -g dify -m 0755 /home/dify/.cache/uv

# Runtime storage.
RUN mkdir -p \
        /app/api/storage \
        /app/api/storage/privkeys \
        /app/storage \
        /app/storage/cwd \
        /app/storage/plugin \
        /app/storage/plugin_packages \
        /app/storage/assets \
        /app/.tiktoken \
        /var/log/nginx \
        /var/lib/nginx \
        /var/lib/nginx/body \
        /var/lib/nginx/proxy \
        /var/lib/nginx/fastcgi \
        /var/lib/nginx/uwsgi \
        /var/lib/nginx/scgi \
        /var/cache/nginx \
        /run

RUN chmod +x \
        /app/start.sh \
        /app/hf_state_keeper.py \
        /app/entrypoint.sh \
        /opt/dify-plugin-daemon/main \
        /opt/dify-plugin-daemon/commandline \
    && chown -R dify:dify \
        /home/dify \
        /app/api/storage \
        /app/storage \
        /app/targets \
        /app/entrypoint.sh \
        /opt/dify-plugin-daemon \
        /var/log/nginx \
        /var/lib/nginx \
        /var/cache/nginx \
        /run \
        /etc/nginx

# Fail the Docker build immediately if the 1.17 web runtime was copied wrong.
RUN test -f /app/entrypoint.sh \
    && test -f /app/targets/next/web/server.js \
    && test -x /opt/dify-plugin-daemon/commandline \
    && test -f /etc/ssl/certs/ca-certificates.crt \
    && su -s /bin/bash dify -c '\
        test -w /home/dify/.cache/uv && \
        touch /home/dify/.cache/uv/.write-test && \
        rm -f /home/dify/.cache/uv/.write-test && \
        /usr/local/bin/uv --version && \
        node --version && \
        echo "DIFY 1.17 HF FIX2 BUILD TEST = OK" \
    '

ENV PORT=7860 \
    MODE=api \
    DEBUG=false \
    DEPLOY_ENV=PRODUCTION \
    EDITION=SELF_HOSTED

EXPOSE 7860

USER dify
WORKDIR /app/api

ENTRYPOINT []
CMD ["/bin/bash", "/app/start.sh"]