FROM node:18-alpine AS baseFROM base AS builderRUN apk updateRUN apk add --no-cache libc6-compat# Set working directoryWORKDIR /app# Replace <your-major-version> with the major version installed in your repository. For example:# RUN yarn global add turbo@^2RUN yarn global add turbo@^<your-major-version>COPY . .# Generate a partial monorepo with a pruned lockfile for a target workspace.# Assuming "web" is the name entered in the project's package.json: { name: "web" }RUN turbo prune web --docker# Add lockfile and package.json's of isolated subworkspaceFROM base AS installerRUN apk updateRUN apk add --no-cache libc6-compatWORKDIR /app# First install the dependencies (as they change less often)COPY --from=builder /app/out/json/ .RUN yarn install# Build the projectCOPY --from=builder /app/out/full/ .RUN yarn turbo run buildFROM base AS runnerWORKDIR /app# Don't run production as rootRUN addgroup --system --gid 1001 nodejsRUN adduser --system --uid 1001 nextjsUSER nextjs# Automatically leverage output traces to reduce image size# https://nextjs.dev.org.tw/docs/advanced-features/output-file-tracingCOPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/staticCOPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/publicCMD node apps/web/server.js