# syntax=docker/dockerfile:1 FROM oven/bun:alpine AS base # Builder stage - do everything here FROM base AS builder RUN apk add --no-cache libc6-compat WORKDIR /app # Copy all source code first COPY . . # Install dependencies (this will create proper workspace structure) RUN bun install # Build the Next.js app ENV NEXT_TELEMETRY_DISABLED=1 ENV SKIP_ENV_VALIDATION=1 RUN bun run build --filter=@gib/next # Runner stage FROM node:20-alpine AS runner WORKDIR /app ENV NODE_ENV=production ENV NEXT_TELEMETRY_DISABLED=1 RUN addgroup --system --gid 1001 nodejs && \ adduser --system --uid 1001 nextjs # Copy built application COPY --from=builder --chown=nextjs:nodejs /app/apps/next/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/apps/next/.next/static ./apps/next/.next/static COPY --from=builder --chown=nextjs:nodejs /app/apps/next/public ./apps/next/public USER nextjs EXPOSE 3000 ENV PORT=3000 ENV HOSTNAME="0.0.0.0" CMD ["node", "apps/next/server.js"]