FROM node:18-alpine AS deps RUN apk add --no-cache libc6-compat WORKDIR /app COPY package.json yarn.lock ./ RUN yarn install --frozen-lockfile FROM node:18-alpine AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . ARG APP_ENV RUN yarn build -e $APP_ENV FROM node:18-alpine AS runner WORKDIR /app ENV NODE_ENV production RUN addgroup -g 1001 -S nodejs RUN adduser -S mvpmasters -u 1001 COPY --from=builder /app/next.config.js ./next.config.js COPY --from=builder /app/public ./public # Set the correct permission for prerender cache RUN mkdir .next RUN chown mvpmasters:nodejs .next COPY --from=builder --chown=mvpmasters:nodejs /app/.next ./.next COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/package.json ./package.json USER mvpmasters EXPOSE 3000 ARG APP_ENV ENV APP_ENV=$APP_ENV CMD yarn start -e $APP_ENV