content: FROM node:18-alpine AS base
  
  # Install pnpm
  RUN npm install -g pnpm
  
  FROM base AS deps
  WORKDIR /app
  
  # Copy root package.json and pnpm files
  COPY package.json pnpm-workspace.yaml ./
  COPY packages/web/package.json ./packages/web/
  COPY packages/shared/package.json ./packages/shared/
  COPY packages/ui/package.json ./packages/ui/
  
  # Install dependencies
  RUN pnpm install --frozen-lockfile
  
  FROM base AS builder
  WORKDIR /app
  COPY --from=deps /app/node_modules ./node_modules
  COPY . .
  
  # Build shared packages first
  RUN pnpm --filter @monorepo/shared build
  RUN pnpm --filter @monorepo/ui build
  
  # Build web app
  RUN pnpm --filter @monorepo/web build
  
  FROM base AS runner
  WORKDIR /app
  
  ENV NODE_ENV production
  
  RUN addgroup --system --gid 1001 nodejs
  RUN adduser --system --uid 1001 nextjs
  
  COPY --from=builder /app/packages/web/public ./public
  COPY --from=builder --chown=nextjs:nodejs /app/packages/web/.next/standalone ./
  COPY --from=builder --chown=nextjs:nodejs /app/packages/web/.next/static ./packages/web/.next/static
  
  USER nextjs
  
  EXPOSE 3000
  
  ENV PORT 3000
  ENV HOSTNAME "0.0.0.0"
  
  CMD ["node", "packages/web/server.js"]