I try to dockerize a next.js app.
So I have this Dockerfile:
FROM node:18-alpine AS BUILD_IMAGE
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
COPY . .
RUN yarn build
RUN npm prune --production
FROM node:18-alpine
WORKDIR /app
COPY --from=BUILD_IMAGE /app/package.json ./package.json
COPY --from=BUILD_IMAGE /app/node_modules ./node_modules
COPY --from=BUILD_IMAGE /app/.next ./.next
COPY --from=BUILD_IMAGE /app/public ./public
EXPOSE 3000
CMD ["yarn", "start"]
But when I try to build the Dockerifile with the command:
docker build -t frontend:v1 -f Dockerfile.prod .
I get this error:
ERROR: failed to solve: process "/bin/sh -c yarn install --frozen-lockfile" did not complete successfully: exit code: 1
on this line:
RUN yarn install --frozen-lockfile
Question: how to resolve the error: failed to solve: process "/bin/sh -c yarn install --frozen-lockfile"