Commit b0d4c25d authored by StyleZhang's avatar StyleZhang

optimize web dockerfile

parents fcd596c3 f749107a
......@@ -8,7 +8,7 @@
```bash
cd ../docker
docker-compose -f docker-compose.middleware.yaml up -d
docker-compose -f docker-compose.middleware.yaml -p dify up -d
cd ../api
```
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 EDITION SELF_HOSTED
ENV DEPLOY_ENV PRODUCTION
ENV CONSOLE_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
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
COPY . /app/web/
RUN npm run build
EXPOSE 3000
COPY docker/pm2.json /app/web/pm2.json
COPY docker/entrypoint.sh /entrypoint.sh
......
......@@ -4,9 +4,8 @@
"name": "WebApp",
"exec_mode": "cluster",
"instances": 1,
"script": "./node_modules/next/dist/bin/next",
"cwd": "/app/web",
"args": "start"
"script": "./server.js",
"cwd": "/app/web"
}
]
}
......@@ -29,6 +29,7 @@ const nextConfig = {
// https://nextjs.org/docs/api-reference/next.config.js/ignoring-typescript-errors
ignoreBuildErrors: true,
},
output: 'standalone',
async redirects() {
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