Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

feat(docker): add PM2_INSTANCES variable and update entrypoint script… (#14083)

Wu Tianwei252d2c425bb9
diff --git a/docker/docker-compose-template.yaml b/docker/docker-compose-template.yaml
index 342fa24aff5..f284449f953 100644
--- a/docker/docker-compose-template.yaml
+++ b/docker/docker-compose-template.yaml
@@ -64,6 +64,7 @@ services:
MARKETPLACE_URL: ${MARKETPLACE_URL:-https://marketplace.dify.ai}
TOP_K_MAX_VALUE: ${TOP_K_MAX_VALUE:-}
INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH: ${INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH:-}
+ PM2_INSTANCES: ${PM2_INSTANCES:-2}
# The postgres database.
db:
diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml
index e0905d90c0a..b1eb3d82648 100644
--- a/docker/docker-compose.yaml
+++ b/docker/docker-compose.yaml
@@ -476,6 +476,7 @@ services:
MARKETPLACE_URL: ${MARKETPLACE_URL:-https://marketplace.dify.ai}
TOP_K_MAX_VALUE: ${TOP_K_MAX_VALUE:-}
INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH: ${INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH:-}
+ PM2_INSTANCES: ${PM2_INSTANCES:-2}
# The postgres database.
db:
diff --git a/web/Dockerfile b/web/Dockerfile
index b5423463abc..51c88e7fc92 100644
--- a/web/Dockerfile
+++ b/web/Dockerfile
@@ -46,6 +46,7 @@ ENV MARKETPLACE_API_URL=http://127.0.0.1:5001
ENV MARKETPLACE_URL=http://127.0.0.1:5001
ENV PORT=3000
ENV NEXT_TELEMETRY_DISABLED=1
+ENV PM2_INSTANCES=2
# set timezone
ENV TZ=UTC
@@ -58,7 +59,6 @@ COPY --from=builder /app/web/public ./public
COPY --from=builder /app/web/.next/standalone ./
COPY --from=builder /app/web/.next/static ./.next/static
-COPY docker/pm2.json ./pm2.json
COPY docker/entrypoint.sh ./entrypoint.sh
diff --git a/web/README.md b/web/README.md
index ddba8ed28a2..900924f348d 100644
--- a/web/README.md
+++ b/web/README.md
@@ -70,6 +70,8 @@ If you want to customize the host and port:
pnpm run start --port=3001 --host=0.0.0.0
```
+If you want to customize the number of instances launched by PM2, you can configure `PM2_INSTANCES` in `docker-compose.yaml` or `Dockerfile`.
+
## Storybook
This project uses [Storybook](https://storybook.js.org/) for UI component development.
diff --git a/web/docker/entrypoint.sh b/web/docker/entrypoint.sh
index 409916b27c1..d0ee56b889f 100755
--- a/web/docker/entrypoint.sh
+++ b/web/docker/entrypoint.sh
@@ -28,4 +28,4 @@ export NEXT_PUBLIC_CSP_WHITELIST=${CSP_WHITELIST}
export NEXT_PUBLIC_TOP_K_MAX_VALUE=${TOP_K_MAX_VALUE}
export NEXT_PUBLIC_INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH=${INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH}
-pm2 start ./pm2.json --no-daemon
+pm2 start /app/web/server.js --name dify-web --cwd /app/web -i ${PM2_INSTANCES} --no-daemon