Unverified Commit 965ca365 authored by Bowen Liang's avatar Bowen Liang Committed by GitHub

use pm2 to guard and monitor the web service in docker file (#2238)

parent b4988ce2
...@@ -40,12 +40,17 @@ ENV TZ UTC ...@@ -40,12 +40,17 @@ ENV TZ UTC
RUN ln -s /usr/share/zoneinfo/${TZ} /etc/localtime \ RUN ln -s /usr/share/zoneinfo/${TZ} /etc/localtime \
&& echo ${TZ} > /etc/timezone && echo ${TZ} > /etc/timezone
# global runtime packages
RUN yarn global add pm2 \
&& yarn cache clean
WORKDIR /app/web WORKDIR /app/web
COPY --from=builder /app/web/public ./public COPY --from=builder /app/web/public ./public
COPY --from=builder /app/web/.next/standalone ./ COPY --from=builder /app/web/.next/standalone ./
COPY --from=builder /app/web/.next/static ./.next/static COPY --from=builder /app/web/.next/static ./.next/static
COPY docker/pm2.json ./pm2.json
COPY docker/entrypoint.sh ./entrypoint.sh COPY docker/entrypoint.sh ./entrypoint.sh
ARG COMMIT_SHA ARG COMMIT_SHA
......
...@@ -10,4 +10,4 @@ export NEXT_PUBLIC_PUBLIC_API_PREFIX=${APP_API_URL}/api ...@@ -10,4 +10,4 @@ export NEXT_PUBLIC_PUBLIC_API_PREFIX=${APP_API_URL}/api
export NEXT_PUBLIC_SENTRY_DSN=${SENTRY_DSN} export NEXT_PUBLIC_SENTRY_DSN=${SENTRY_DSN}
export NEXT_PUBLIC_SITE_ABOUT=${SITE_ABOUT} export NEXT_PUBLIC_SITE_ABOUT=${SITE_ABOUT}
node ./server.js pm2 start ./pm2.json --no-daemon
{ {
"apps": [ "apps": [
{ {
"name": "WebApp", "name": "dify-web",
"exec_mode": "cluster", "script": "/app/web/server.js",
"instances": 1, "cwd": "/app/web",
"script": "./node_modules/next/dist/bin/next", "exec_mode": "cluster",
"cwd": "/app/web", "instances": 2
"args": "start" }
} ]
] }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment