node-deploy
Skill0 starsChanged 3 days agoMITView on GitHub
Deploy Node.js backends to production with Docker, PM2 or systemd - multi-stage Dockerfile (npm ci, prune dev deps, slim base pinned to LTS, non-root node user, exec-form CMD, tini, HEALTHCHECK), .dockerignore, PM2 ecosystem (cluster mode, kill_timeout, wait_ready, zero-downtime reload), hardened systemd unit (dedicated user, EnvironmentFile, Restart, sandboxing), graceful shutdown on SIGTERM (readiness off, drain, server.close, close pools and workers, hard timeout) and liveness/readiness endpoints. Includes a checker for unpinned base images, root containers, devDependencies in images, npm start or shell-form CMD swallowing signals, secrets in ENV or Environment=, .dockerignore gaps, PM2 watch/kill_timeout, systemd root/Restart/hardening, missing SIGTERM handling and health endpoints, and localhost binding (incl. Fastify's default). Use when the user containerises or deploys a Node.js API, sets up PM2 or systemd, sees dropped requests or 502s on deploy, or asks for health checks or graceful shutdown.
- Reads credentials
In this repository8 other files it gives its agents.
- AGENTS.mdAGENTS.md
- api-performanceSkill
- background-jobsSkill
- env-configSkill
- error-handling-patternsSkill
- logging-and-tracingSkill
- node-security-reviewSkill
- package-json-auditSkill
The file
Files
Node.js deploy
Small, non-root images or services that start fast, report health honestly, and finish
in-flight work when told to stop. Templates live in assets/; the checker reviews what
the project already has.
Paths below are relative to this skill's folder (in Claude Code: ${CLAUDE_SKILL_DIR}).
When to use
- "Dockerize my Node API", "review my Dockerfile", "deploy with PM2 / systemd"
- Requests fail or 502 during deploys/restarts; containers take 10 s to stop
- "Add health checks / readiness / liveness", "graceful shutdown"
- Moving from
npm starton a VPS to a supervised service
When not to use
- Environment variable design and validation:
env-config - Queue worker shutdown details:
background-jobs(this skill wires the process) - Cloud-specific IaC (Terraform, Helm charts, ECS task definitions) beyond the probe/ signal settings shown in references
- Dependency vulnerabilities:
package-json-audit
Workflow
- Pick the target with the user: Docker/Compose (or Kubernetes), PM2 on a VM, or
systemd on a VM. Note Node major, build step (
tsc,tsup, none), entry file, port, whether a reverse proxy/load balancer sits in front. - Check what exists (read-only).
Exit 1 = findings at or abovepython3 scripts/deploy_check.py . python3 scripts/deploy_check.py . --json --min-severity low--fail-on(defaultmedium). - Fix high findings first: root user, unpinned base, secrets baked into the image or
unit (tell the user to rotate them: image layers and
systemctl showexpose them), missing SIGTERM handling. - Apply templates (adapt paths, show the diff, wait for approval):
- Docker: assets/Dockerfile + assets/.dockerignore
- PM2: assets/ecosystem.config.cjs
- systemd: assets/node-app.service
- Lifecycle: assets/lifecycle.mjs for
/healthz,/readyzand the shutdown sequence; framework hooks in references/graceful-shutdown.md.
- Platform settings from references/targets.md: stop grace
period /
kill_timeout/TimeoutStopSecabove the shutdown time, probes, memory limit and--max-old-space-size, proxytrust proxyand keep-alive timeouts. - Verify (commands for the user to run, or you with permission):
Then the zero-dropped-requests test from the graceful shutdown reference. Re-run the checker.docker build -t api:test . && docker run --rm -p 3000:3000 --env-file .env api:test docker exec <id> id # uid=1000(node), not root curl -fsS localhost:3000/healthz && curl -fsS localhost:3000/readyz time docker stop <id> # well under 10 s, exit code 0
Output
Deploy review: api (Docker + nginx) - 3 high, 5 medium
HIGH Dockerfile:1 FROM node (latest) -> node:22-bookworm-slim, multi-stage
HIGH Dockerfile runs as root -> USER node, COPY --chown=node:node
HIGH Dockerfile:5 ENV API_TOKEN baked into the image -> runtime env; rotate the token
MED Dockerfile:8 CMD npm start (shell form) -> CMD ["node","dist/server.js"] with tini
MED src/server.js SIGTERM exits without server.close(); no /readyz -> lifecycle.mjs
After: image 1.1 GB -> 210 MB, docker stop 10.2 s -> 1.4 s, 0 errors during stop under load.Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

