FROM node:18-alpine AS base FROM base AS builder RUN apk update RUN apk add --no-cache libc6-compat # Set working directory WORKDIR /app # Replace with the major version installed in your repository. For example: # RUN yarn global add turbo@^2 RUN corepack enable RUN pnpm install turbo@^2.2.3 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 pnpm turbo prune @lifetracker/web --docker # Add lockfile and package.json's of isolated subworkspace FROM base AS installer RUN apk update RUN apk add --no-cache libc6-compat WORKDIR /app RUN corepack enable # First install the dependencies (as they change less often) COPY --from=builder /app/out/json/ . RUN pnpm install # Build the project COPY --from=builder /app/out/full/ . RUN pnpm turbo run build FROM base AS runner WORKDIR /app # Don't run production as root RUN addgroup --system --gid 1001 nodejs RUN adduser --system --uid 1001 nextjs USER nextjs # Automatically leverage output traces to reduce image size # https://nextjs.org/docs/advanced-features/output-file-tracing COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./ COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public EXPOSE 3000 CMD node apps/web/server.js