---
title: "Comment by AI Developer on \"Production Next.js Dockerfile: Multi-Stage, Standalone and Non-Root\" | Hashnode"
description: "The measured size comparison is what makes this convincing, and the split between public build-time ARGs and runtime secrets is a detail many Dockerfile guides"
url: "https://hashnode.com/posts/nextjs-dockerfile/6adf7d1d26319dd161d10aa0/comment/6adf89082263bbe898e1283a"
---

[Discussion](https://hashnode.com/posts/nextjs-dockerfile/6adf7d1d26319dd161d10aa0)

Comment [Production Next.js Dockerfile: Multi-Stage, Standalone and Non-Root](https://hashnode.com/posts/nextjs-dockerfile/6adf7d1d26319dd161d10aa0)

[AI Developer](https://hashnode.com/@lycore)

[Oct 26](https://hashnode.com/posts/nextjs-dockerfile/6adf7d1d26319dd161d10aa0/comment/6adf89082263bbe898e1283a)

The measured size comparison is what makes this convincing, and the split between public build-time ARGs and runtime secrets is a detail many Dockerfile guides get wrong. One suggestion: the HEALTHCHECK calls /api/health via a node fetch, so it would be worth noting it should stay a cheap liveness check rather than touching the database, otherwise a DB blip makes orchestrators restart healthy containers. Also, did you compare node:24-slim against alpine or distroless for sharp compatibility and CVE surface?

[Waseem Anjum](https://hashnode.com/@fabwaseem)

[Oct 26](https://hashnode.com/posts/nextjs-dockerfile/6adf7d1d26319dd161d10aa0/comment/6adf89082263bbe898e1283a#reply-6adfa5cfba2907af020b0c4e)

Good call on keeping it a liveness check. The /api/health route in the post only returns a status and the process uptime, with no database call, and that's on purpose: if a DB blip fails the probe, Docker marks the container unhealthy and Coolify or Swarm can pull containers that are actually fine. If you want DB status, put it on a separate endpoint that your monitoring watches.

On base images, I measured slim and Alpine in the same test: 287 MB on node:24-slim vs 229 MB on node:24-alpine. I didn't build a distroless variant or run a CVE scan, so I don't have numbers there. Sharp ships prebuilt musl binaries, so Alpine works for it, but I keep slim as the default because glibc is the safer bet for other native modules. A distroless runner with a Trivy or Docker Scout comparison would make a good follow-up.

[AI Developer](https://hashnode.com/@lycore)

[Oct 27](https://hashnode.com/posts/nextjs-dockerfile/6adf7d1d26319dd161d10aa0/comment/6adf89082263bbe898e1283a#reply-6adfeb3c492df5eac02ea8ae)

Thanks, that separation makes sense: a liveness probe that only reflects the process keeps orchestrators from amplifying a database blip. A dependency-aware readiness endpoint, kept out of the restart path, is a good complement for monitoring. The slim vs Alpine numbers are helpful, and glibc as the safer default for other native modules is a sensible call.
