Next.js Discord

Discord Forum

Docker build with export output

Unanswered
Polar bear posted this in #help-forum
Open in Discord
Polar bearOP
Hello, so we have recently upgraded our next version from 12 to 14 in our capacitor react project and now the build process does not work anymore.

Before we used the next export -o build command to export the build (using output: standalone) Which worked find but now that in 13.0.0 the next export was removed we need to use output: export

this seems to break our dockerfile. What would we need to change in the dockerfile for it to work again?

FROM node:18 as base

WORKDIR /usr/src/app

RUN npm install -g npm@8.19.2


FROM base as deps

ARG NODE_ENV=development
ENV NODE_ENV=${NODE_ENV}

WORKDIR /usr/src/app

COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./

RUN npm install --legacy-peer-deps


FROM deps as build

ARG NODE_ENV=development
ENV NODE_ENV=${NODE_ENV}

WORKDIR /usr/src/app

COPY . .

RUN npm run build:docker:prod


FROM node:18-alpine as app

ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}

WORKDIR /usr/src/app

COPY --from=build /usr/src/app/public ./public
COPY --from=build /usr/src/app/.next/standalone ./  # error here
COPY --from=build /usr/src/app/.next/static ./.next/static

EXPOSE 3000

ENV PORT 3000

CMD ["node", "server.js"]



module.exports = {
  output: "export",

  images: {
    unoptimized: true,
  },

};

1 Reply

Northeast Congo Lion
Hi did you ever figure this out? I'm running into a similar issue