Include Sharp native libraries and verify final image conversion

This commit is contained in:
2026-09-10 12:08:16 -04:00
parent a12d239c49
commit 5c791164a3
+3
View File
@@ -22,10 +22,13 @@ FROM oven/bun:1.4.0 AS web
WORKDIR /app WORKDIR /app
ENV NODE_ENV=production HOSTNAME=0.0.0.0 PORT=3000 NEXT_TELEMETRY_DISABLED=1 ENV NODE_ENV=production HOSTNAME=0.0.0.0 PORT=3000 NEXT_TELEMETRY_DISABLED=1
COPY --from=builder --chown=bun:bun /app/apps/web/.next/standalone ./ COPY --from=builder --chown=bun:bun /app/apps/web/.next/standalone ./
# Next's standalone trace can omit libvips shared libraries loaded by Sharp.
COPY --from=builder --chown=bun:bun /app/node_modules/@img ./node_modules/@img
COPY --from=builder --chown=bun:bun /app/apps/web/.next/static ./apps/web/.next/static COPY --from=builder --chown=bun:bun /app/apps/web/.next/static ./apps/web/.next/static
COPY --from=builder --chown=bun:bun /app/apps/web/public ./apps/web/public COPY --from=builder --chown=bun:bun /app/apps/web/public ./apps/web/public
COPY --from=builder --chown=bun:bun /app/scripts/check-production-env.ts ./scripts/check-production-env.ts COPY --from=builder --chown=bun:bun /app/scripts/check-production-env.ts ./scripts/check-production-env.ts
USER bun USER bun
RUN cd /app/apps/web && bun -e 'import sharp from "sharp"; const image = await sharp({create:{width:8,height:8,channels:3,background:"white"}}).webp().toBuffer(); if (!image.length) throw new Error("Sharp runtime smoke test failed");'
EXPOSE 3000 EXPOSE 3000
CMD ["sh", "-c", "bun scripts/check-production-env.ts && exec bun apps/web/server.js"] CMD ["sh", "-c", "bun scripts/check-production-env.ts && exec bun apps/web/server.js"]