Commit b0d4c25d authored by StyleZhang's avatar StyleZhang

optimize web dockerfile

parents fcd596c3 f749107a
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
```bash ```bash
cd ../docker cd ../docker
docker-compose -f docker-compose.middleware.yaml up -d docker-compose -f docker-compose.middleware.yaml -p dify up -d
cd ../api cd ../api
``` ```
2. Copy `.env.example` to `.env` 2. Copy `.env.example` to `.env`
......
FROM node:18.17.0-alpine FROM node:18.17.0-alpine AS base
FROM base AS deps
WORKDIR /app/web
COPY package.json ./package.json
RUN npm install --only=prod
LABEL maintainer="takatost@gmail.com" FROM base AS builder
WORKDIR /app/web
COPY --from=deps /app/web/node_modules ./node_modules
COPY . .
RUN npm run build
FROM base AS runner
LABEL maintainer="takatost@gmail.com"
ENV NODE_ENV=production ENV NODE_ENV=production
ENV EDITION SELF_HOSTED ENV EDITION SELF_HOSTED
ENV DEPLOY_ENV PRODUCTION ENV DEPLOY_ENV PRODUCTION
ENV CONSOLE_API_URL http://127.0.0.1:5001 ENV CONSOLE_API_URL http://127.0.0.1:5001
ENV APP_API_URL http://127.0.0.1:5001 ENV APP_API_URL http://127.0.0.1:5001
EXPOSE 3000
WORKDIR /app/web
COPY package.json /app/web/package.json
RUN npm install pm2 -g RUN npm install pm2 -g
WORKDIR /app/web
COPY --from=builder /app/web/public ./public
COPY --from=builder /app/web/.next/standalone ./
COPY --from=builder /app/web/.next/static ./.next/static
RUN npm install --only=prod EXPOSE 3000
COPY . /app/web/
RUN npm run build
COPY docker/pm2.json /app/web/pm2.json COPY docker/pm2.json /app/web/pm2.json
COPY docker/entrypoint.sh /entrypoint.sh COPY docker/entrypoint.sh /entrypoint.sh
......
...@@ -4,9 +4,8 @@ ...@@ -4,9 +4,8 @@
"name": "WebApp", "name": "WebApp",
"exec_mode": "cluster", "exec_mode": "cluster",
"instances": 1, "instances": 1,
"script": "./node_modules/next/dist/bin/next", "script": "./server.js",
"cwd": "/app/web", "cwd": "/app/web"
"args": "start"
} }
] ]
} }
...@@ -29,6 +29,7 @@ const nextConfig = { ...@@ -29,6 +29,7 @@ const nextConfig = {
// https://nextjs.org/docs/api-reference/next.config.js/ignoring-typescript-errors // https://nextjs.org/docs/api-reference/next.config.js/ignoring-typescript-errors
ignoreBuildErrors: true, ignoreBuildErrors: true,
}, },
output: 'standalone',
async redirects() { async redirects() {
return [ return [
{ {
......
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