nestjs-deployment
Skill29 starsChanged 2 months agoMITView on GitHub
Productionizes NestJS apps for containers. Use for multi-stage Docker builds of NestJS or Nx apps, webpack externals, migrations at deploy time, health checks, CORS and rate limiting, production logging, or deploying to a cloud platform.
- Installs packages
1 other project uses a version of this.
Adopted by
Most recently taken up by
- FilippoDeSilva/skillstheir own version, first seen Jun 26, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- FilippoDeSilva/skills★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository25 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- agent-lanesSkill
- angular-3d-scene-crafterSkill
- angular-frontend-patternsSkill
- angular-gsap-animation-crafterSkill
- ddd-architectureSkill
- execute-phase-gated-taskSkill
- extract-and-relocate-angular-component-featureSkill
- fleet-orchestrationSkill
- humanize-librarySkill
- impeccableSkill
- nestjs-backend-patternsSkill
- nx-workspace-architectSkill
- orchestrationSkill
- ptah-cli-usageSkill
- resilient-nestjs-patternsSkill
- saas-platform-patternsSkill
- saas-workspace-initializerSkill
- skill-creatorSkill
- technical-content-writerSkill
- tribunalSkill
- typesafe-aiSkill
- ui-ux-designerSkill
- video-showcaseSkill
- webhook-architectureSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
Before shipping to production, verify every item:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
NestJS Deployment Patterns
Patterns for taking NestJS applications from development to production with Docker, proper bundling, database migrations, and security hardening. Extracted from production deployments on DigitalOcean App Platform but adaptable to any cloud provider.
Activation scope
This skill activates per-module during Stage B of the SaaS bootstrap, typically against a deploy-docker or deploy-ci roadmap item. It is NOT part of the Stage A foundation produced by saas-workspace-initializer — Stage A only sets up minimal lint/test CI. Reach for this skill when productionizing the deployment pipeline, not before there is anything to deploy.
Deployment Checklist
Before shipping to production, verify every item:
- Multi-stage Docker build (builder, deps, runtime)
- Webpack externals for problematic packages
- Database migration on deploy (
prisma migrate deploy) - Health check endpoint (
/apior/api/health) - Non-root container user
- Environment-driven configuration (
ConfigService) - Rate limiting (
@nestjs/throttler) - CORS restricted to frontend URL
- Input validation pipeline (
ValidationPipe) - Production logging levels (no debug/verbose)
- Memory limits (
--max-old-space-size) .dockerignoreexcludes unnecessary files
Architecture
[Development]
Dockerfile.dev
-> Full dependencies (dev + prod)
-> Volume mounts for hot reload
-> nx serve for development server
-> Health check on /api
[Production]
Dockerfile (multi-stage)
Stage 1: Builder
-> Install ALL deps, copy source
-> npx nx build app-name
-> Generate Prisma client
Stage 2: Dependencies
-> Copy generated package.json from builder
-> npm install --omit=dev
-> Explicitly install webpack externals
Stage 3: Runtime
-> node:24-alpine minimal image
-> Non-root user (nestjs:nodejs)
-> Copy: node_modules, built app, Prisma files
-> Regenerate Prisma client (Alpine binaries)
-> Health check, memory limits
-> CMD: prisma migrate deploy && node main.jsQuick Start: Minimal Production Dockerfile
# Stage 1: Build
FROM node:24-alpine AS builder
WORKDIR /app
RUN apk add --no-cache openssl libc6-compat
COPY package.json package-lock.json nx.json tsconfig.base.json ./
COPY apps/my-api ./apps/my-api/
COPY libs ./libs/
RUN npm ci
RUN cd apps/my-api && npx prisma generate
RUN npx nx build my-api --configuration=production
# Stage 2: Production deps
FROM node:24-alpine AS deps
WORKDIR /app
RUN apk add --no-cache openssl libc6-compat
COPY --from=builder /app/dist/apps/my-api/package.json ./
RUN npm install --omit=dev
# Stage 3: Runtime
FROM node:24-alpine AS production
WORKDIR /app
RUN apk add --no-cache openssl libc6-compat
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nestjs
COPY --from=deps /app/node_modules ./node_modules
COPY --from=builder /app/dist/apps/my-api ./
COPY --from=builder /app/apps/my-api/prisma ./prisma/
RUN npx prisma generate --schema=prisma/schema.prisma
RUN chown -R nestjs:nodejs /app
USER nestjs
EXPOSE 3000
ENV NODE_ENV=production
ENV NODE_OPTIONS="--max-old-space-size=450"
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api || exit 1
CMD ["sh", "-c", "npx prisma migrate deploy && node main.js"]Quick Start: Production main.ts
The production bootstrap() is where every global concern converges, and order matters. It must: pick log levels from NODE_ENV (no debug/verbose in production); create the app with rawBody: true so webhook HMAC verification can read the unparsed body; register the cookie parser; install a global ValidationPipe with whitelist, forbidNonWhitelisted and transform; restrict CORS to the configured frontend URL with credentials: true; and set the api global prefix while excluding webhook paths.
For the full annotated implementation, plus the table explaining each setting, see production-hardening.md.
Decision Matrix
| Need | Pattern | Reference |
| Docker build for NestJS + Nx | Multi-stage Dockerfile | docker-multistage.md |
| Packages break when bundled | Webpack externals | webpack-bundling.md |
| DB schema sync on deploy | Migration on startup | database-migrations.md |
| CORS, rate limiting, validation | Production hardening | production-hardening.md |
| Health checks, logging, memory | Production hardening | production-hardening.md |
References
Load these for detailed implementation guidance:
- docker-multistage.md - Multi-stage Docker builds for dev and production, docker-compose, .dockerignore
- production-hardening.md - Security, CORS, rate limiting, validation, logging, health checks, memory management
- database-migrations.md - Prisma migration strategy, PrismaService pattern, deploy workflow, rollback
- webpack-bundling.md - NestJS webpack config, externals for problematic packages, package.json generation
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.

