diff --git a/Dockerfile b/Dockerfile index 14d8fcced..ca02645df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -91,19 +91,31 @@ COPY --chown=etherpad:etherpad ./var ./var COPY --chown=etherpad:etherpad ./bin ./bin COPY --chown=etherpad:etherpad ./pnpm-workspace.yaml ./package.json ./ + FROM build as development COPY --chown=etherpad:etherpad ./src/package.json .npmrc ./src/pnpm-lock.yaml ./src/ RUN bin/installDeps.sh && { [ -z "${ETHERPAD_PLUGINS}" ] || \ pnpm install --workspace-root ${ETHERPAD_PLUGINS}; } - + +FROM build as buildProd + +COPY --chown=etherpad:etherpad ./src ./src + +RUN bin/installDeps.sh && { [ -z "${ETHERPAD_PLUGINS}" ] || \ + pnpm install --workspace-root ${ETHERPAD_PLUGINS}; } + +RUN pnpm run next-build + + FROM build as production ENV NODE_ENV=production ENV ETHERPAD_PRODUCTION=true -COPY --chown=etherpad:etherpad ./src ./src +COPY --chown=etherpad:etherpad --from=buildProd /opt/etherpad-lite/src/.next/ ./src/.next/ +COPY --chown=etherpad:etherpad ./src/ ./src/ RUN bin/installDeps.sh && { [ -z "${ETHERPAD_PLUGINS}" ] || \ pnpm install --workspace-root ${ETHERPAD_PLUGINS}; } diff --git a/package.json b/package.json index 891edbd5a..9bccf649a 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "dev": "pnpm --filter ep_etherpad-lite run dev", "prod": "pnpm --filter ep_etherpad-lite run prod", "ts-check": "pnpm --filter ep_etherpad-lite run ts-check", - "ts-check:watch": "pnpm --filter ep_etherpad-lite run ts-check:watch" + "ts-check:watch": "pnpm --filter ep_etherpad-lite run ts-check:watch", + "next-build": "pnpm --filter ep_etherpad-lite run build-next" }, "dependencies": { "ep_etherpad-lite": "workspace:./src" diff --git a/src/node/hooks/express/admin.ts b/src/node/hooks/express/admin.ts index 32e92178d..9770fae0f 100644 --- a/src/node/hooks/express/admin.ts +++ b/src/node/hooks/express/admin.ts @@ -4,7 +4,7 @@ import {ArgsExpressType} from "../../types/ArgsExpressType"; const eejs = require('../../eejs'); import next from 'next' -const app = next({dev: true}) +const app = next({dev: process.env.NODE_ENV != 'production'}) const handle = app.getRequestHandler() /** * Add the admin navigation link diff --git a/src/package.json b/src/package.json index 8c4866d0f..a0a96610a 100644 --- a/src/package.json +++ b/src/package.json @@ -123,7 +123,8 @@ "dev": "node --import tsx node/server.ts", "prod": "node --import tsx node/server.ts", "ts-check": "tsc --noEmit", - "ts-check:watch": "tsc --noEmit --watch" + "ts-check:watch": "tsc --noEmit --watch", + "build-next": "next build" }, "version": "1.9.7", "license": "Apache-2.0"