Commit f749107a authored by StyleZhang's avatar StyleZhang

optimize web dockerfile

parent 51554361
......@@ -42,7 +42,7 @@ jobs:
uses: docker/build-push-action@v4
with:
context: "{{defaultContext}}:web"
platforms: ${{ github.ref == 'refs/heads/deploy/dev' && 'linux/amd64' || 'linux/amd64,linux/arm64' }}
platforms: linux/amd64,linux/arm64
build-args: |
COMMIT_SHA=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
push: true
......
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