FROM oven/bun:1 AS build-stage WORKDIR /app # Limit memory for Node processes (3 GB) COPY package.json bun.lockb* ./ RUN bun install --frozen-lockfile # --- ✅ Rebuild sharp for correct Linux architecture --- RUN bun x npm rebuild sharp --platform=linux --arch=x64 --target=$(node -v | sed 's/v//') COPY . . RUN bun run build FROM oven/bun:1 AS production-stage WORKDIR /app COPY --from=build-stage /app /app EXPOSE 3000 ENV NODE_ENV=production CMD ["bun", "run", "start"]