Update Dockerfile
Browse files- Dockerfile +8 -31
Dockerfile
CHANGED
@@ -20,29 +20,9 @@ RUN apt-get update && apt-get install -y \
|
|
20 |
&& npm install -g npm@latest \
|
21 |
&& rm -rf /var/lib/apt/lists/*
|
22 |
|
23 |
-
#
|
24 |
-
FROM
|
25 |
-
|
26 |
-
WORKDIR /app
|
27 |
-
|
28 |
-
# Clone repository and build web components
|
29 |
-
RUN git clone --depth 1 https://github.com/langgenius/dify.git . && \
|
30 |
-
cd web && \
|
31 |
-
npm ci && \
|
32 |
-
npm run build && \
|
33 |
-
npm run standalone
|
34 |
-
|
35 |
-
# API builder stage
|
36 |
-
FROM base AS api-builder
|
37 |
-
|
38 |
-
WORKDIR /app
|
39 |
-
|
40 |
-
# Clone repository and build API components
|
41 |
-
RUN git clone --depth 1 https://github.com/langgenius/dify.git . && \
|
42 |
-
cd api && \
|
43 |
-
pip install --no-cache-dir poetry && \
|
44 |
-
poetry install --no-dev && \
|
45 |
-
poetry build
|
46 |
|
47 |
# Final stage
|
48 |
FROM base
|
@@ -54,17 +34,14 @@ RUN useradd -m -u 1000 user
|
|
54 |
WORKDIR /app
|
55 |
RUN mkdir -p api web && chown -R user:user /app
|
56 |
|
57 |
-
# Copy
|
58 |
-
COPY --from=
|
59 |
-
COPY --from=
|
60 |
-
COPY --from=web-builder --chown=user /app/web/public /app/web/public/
|
61 |
-
COPY --from=web-builder --chown=user /app/web/.next/standalone /app/web/
|
62 |
-
COPY --from=web-builder --chown=user /app/web/.next/static /app/web/.next/static/
|
63 |
|
64 |
# Install Python requirements
|
65 |
RUN pip install --no-cache-dir gunicorn gevent
|
66 |
|
67 |
-
# Set environment variables
|
68 |
ENV FLASK_APP=app.py \
|
69 |
EDITION=SELF_HOSTED \
|
70 |
DEPLOY_ENV=PRODUCTION \
|
@@ -77,7 +54,7 @@ ENV FLASK_APP=app.py \
|
|
77 |
# Switch to non-root user
|
78 |
USER user
|
79 |
|
80 |
-
# Expose required ports
|
81 |
EXPOSE 7860 3000
|
82 |
|
83 |
# Create startup script
|
|
|
20 |
&& npm install -g npm@latest \
|
21 |
&& rm -rf /var/lib/apt/lists/*
|
22 |
|
23 |
+
# Pull official images
|
24 |
+
FROM langgenius/dify-web:latest AS web
|
25 |
+
FROM langgenius/dify-api:latest AS api
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
# Final stage
|
28 |
FROM base
|
|
|
34 |
WORKDIR /app
|
35 |
RUN mkdir -p api web && chown -R user:user /app
|
36 |
|
37 |
+
# Copy from official images instead of building
|
38 |
+
COPY --from=web --chown=user /app/web /app/web/
|
39 |
+
COPY --from=api --chown=user /app/api /app/api/
|
|
|
|
|
|
|
40 |
|
41 |
# Install Python requirements
|
42 |
RUN pip install --no-cache-dir gunicorn gevent
|
43 |
|
44 |
+
# Set environment variables for Hugging Face Spaces
|
45 |
ENV FLASK_APP=app.py \
|
46 |
EDITION=SELF_HOSTED \
|
47 |
DEPLOY_ENV=PRODUCTION \
|
|
|
54 |
# Switch to non-root user
|
55 |
USER user
|
56 |
|
57 |
+
# Expose Hugging Face Spaces required ports
|
58 |
EXPOSE 7860 3000
|
59 |
|
60 |
# Create startup script
|