agentsclimarketplace

Nestjs deployment

Skill FilippoDeSilva/skills/skills/nestjs/nestjs-deployment

Containerize NestJS apps with multi-stage Docker builds, tune Node.js memory, and implement graceful shutdown hooks. Use when writing Dockerfiles, configuring K8s deployments, or adding shutdown hooks for NestJS.From its SKILL.md

Install
npx -y skills add FilippoDeSilva/skills --skill nestjs-deployment

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

2.9 KB, 590 tokens by cl100k_base, as published. Nobody here has run it

Deployment & Ops Standards

Priority: P1 (OPERATIONAL)

Workflow: Containerize NestJS App

  1. Write multi-stage Dockerfile — Build stage installs devDeps and runs nest build; run stage copies only dist and pruned node_modules.
  2. Set non-root user — Add USER node to Dockerfile.
  3. Tune memory — Set --max-old-space-size to ~75% of container memory limit.
  4. Enable shutdown hooks — Call app.enableShutdownHooks() in main.ts.
  5. Add K8s pre-stop — Configure 5-10s sleep pre-stop hook for LB draining.

Dockerfile Example

See implementation examples

Runtime Tuning (Node.js)

  • Memory Config: Container memory != Node memory.
  • Rule: Explicitly set Max Old Space.
  • Command: node --max-old-space-size=XXX dist/main
  • Calculation: Set to ~75-80% of Kubernetes Limit. (Limit: 1GB -> OldSpace: 800MB).
  • Graceful Shutdown:
  • Signal: Listen to SIGTERM.
  • NestJS: app.enableShutdownHooks() mandatory.
  • Sleep: Add "Pre-Stop" sleep in K8s (5-10s) to allow Load Balancer to drain connections before Node process stops accepting traffic.

Init Patterns

  • Database Migrations:
  • Anti-Pattern: Running migration in main.ts on startup.
  • Pro Pattern: Use Init Container in Kubernetes that runs npm run typeorm:migration:run before app container starts.

Environment Variables & CI/CD

  • CI/CD Pipelines (GitHub, GitLab, Azure, etc.):
  • If you modify src/config/env.validation.ts to add new environment variable, you MUST map it explicitly in your deployment pipeline/infrastructure-as-code.
  • Platform Context:
  • Cloud Run/ECS: Variables must explicitly passed in service definition.
  • Kubernetes: New variables must added to Deployment manifest or ConfigMap/Secret.
  • Lambda/Serverless: Must added to serverless.yml or provider console.
  • Fundamental Rule: Application code configuration changes "breaking changes" for infrastructure layer. Never assume environment inheritance.

Anti-Patterns

  • No migrations in main.ts: Use K8s Init Containers or pre-deploy CI steps for migration runs.
  • No root user in Docker: Always add USER node to Dockerfile; running as root security risk.
  • No unbounded Node heap: Set --max-old-space-size to ~75% of container memory limit.

What ships with it: 2 files

2.2 KB alongside SKILL.md

evals/

references/

Gives 0 of the 12 instructions most containers cloud skills give in 590 tokens

Counted across 607 of the 657 authors here whose files we hold, read 2026-08-07

  • Run containers as a non-root userin 66 of 607, across 46 files
  • Use multi-stage buildsin 53 of 607, across 44 files
  • Use Promise.all for independent operationsin 47 of 607, across 13 files
  • Import directly instead of barrel filesin 46 of 607, across 12 files
  • Use ternary instead of AND for conditionalsin 45 of 607, across 12 files
  • Use Set or Map for O(1) lookupsin 42 of 607, across 10 files
  • Create a .dockerignore filein 41 of 607, across 31 files
  • Read individual rule files for detailsin 39 of 607, across 9 files
  • Copy dependency files before source codein 36 of 607, across 23 files
  • Authenticate server actions like API routesin 35 of 607, across 7 files
  • Use next/dynamic for heavy componentsin 34 of 607, across 9 files
  • Use React.cache for per-request deduplicationin 34 of 607, across 10 files

Said here and by no other author read

  • tune node memory limits
  • add kubernetes pre-stop hooks
  • run migrations in init containers
  • map new environment variables in infrastructure

Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.

Keep looking

Skills are one crate of 326,852. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.