Commit f749107a authored by StyleZhang's avatar StyleZhang

optimize web dockerfile

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