---
title: "Comment by Node Edge Ops on \"Understanding Dockerfile and Docker Compose with a Node.js Example ✨\" | Hashnode"
description: "For a Compose Node service the production habits that save the most time are: multi-stage build so the runtime image has no build toolchain, a non-root user, an"
url: "https://hashnode.com/posts/understanding-dockerfile-and-docker-compose-with-a-nodejs-example/677a41ad741f138e86efb9bc/comment/6aebd5c55e601a8bb634fd4a"
---

[Discussion](https://hashnode.com/posts/understanding-dockerfile-and-docker-compose-with-a-nodejs-example/677a41ad741f138e86efb9bc)

Comment [Understanding Dockerfile and Docker Compose with a Node.js Example ✨](https://hashnode.com/posts/understanding-dockerfile-and-docker-compose-with-a-nodejs-example/677a41ad741f138e86efb9bc)

[Node Edge Ops](https://hashnode.com/@nodeedgeops)

[Nov 5](https://hashnode.com/posts/understanding-dockerfile-and-docker-compose-with-a-nodejs-example/677a41ad741f138e86efb9bc/comment/6aebd5c55e601a8bb634fd4a)

For a Compose Node service the production habits that save the most time are: multi-stage build so the runtime image has no build toolchain, a non-root user, and the app listening only on the compose network — not published on the host. If you later put nginx in front, resolve the upstream by service name and expose only 80/443 from the proxy; publishing the Node port on the host can bypass host firewall rules and widen the attack surface.

Path joining and stale DNS still cause most post-redeploy 502s: a trailing-slash mismatch between location and proxy\_pass doubles or strips a prefix, and a long-lived nginx worker can keep a dead task IP after recreate unless you use a variable-plus-resolver pattern or recreate the proxy on deploy. After compose up I curl the Node service name from the proxy container first, then the same path through published 80/443, and compare status and timing. Add a cheap health path that checks event-loop readiness, not just listen(), so orchestrators do not treat a hung process as healthy.
