FROM node:18-alpine AS build # Install dependencies only when needed # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. RUN apk add --no-cache libc6-compat WORKDIR /app # Copy and install the dependencies for the project COPY package.json yarn.lock ./ RUN yarn # Copy all other project files to working directory COPY . . ENV PORT 3000 EXPOSE 3000 # Run the next build process and generate the artifacts RUN yarn build CMD ["node", ".next/standalone/server.js"]