Deployment & Going Further

Ship It & Keep Learning

Deployment & Going Further

Practical deployment notes for shipping Nest to production, plus a curated path forward.

4 min read Level 2/5 #nestjs#deployment#production
What you'll learn
  • Pick a host that suits your team and scale
  • Handle env vars, secrets, and migrations safely
  • Find the next resources to deepen your Nest knowledge

You have a Dockerfile, tests, logging, config, and a queue. All that is left is to ship — and to figure out where Nest fits in your team’s bigger picture.

Where Nest Lives Happily

  • Fly.io — fast deploys, regions close to users, built-in volumes.
  • Railway / Render — push-to-deploy with managed Postgres and Redis.
  • AWS ECS / Fargate — serious workloads with the full AWS toolbox.
  • Kubernetes (GKE / EKS / AKS) — when you have many services and need the platform features.

For a first deploy, Fly or Render reduce the surface area dramatically.

Health Endpoints

Hosts probe /health to decide if your container is alive. @nestjs/terminus ships a controller that runs configurable checks:

import { Controller, Get } from '@nestjs/common';
import {
  HealthCheck,
  HealthCheckService,
  TypeOrmHealthIndicator,
} from '@nestjs/terminus';

@Controller('health')
export class HealthController {
  constructor(
    private health: HealthCheckService,
    private db: TypeOrmHealthIndicator,
  ) {}

  @Get()
  @HealthCheck()
  check() {
    return this.health.check([() => this.db.pingCheck('db')]);
  }
}

Env Vars & Secrets

  • Validate on boot with @nestjs/config + Joi (see lesson 1 in this section).
  • Never bake secrets into images — inject them at runtime via the host’s secret manager.
  • Differentiate .env.local (dev only) from .env.example (committed).

Migrations In CI

Run migrations as a separate step before rolling the new container — not from main.ts. If main.ts migrates on boot, every replica races on deploy and one will lose.

# CI deploy pipeline
npm run db:migrate -- --env=production
fly deploy

Going Further

  • The official docs at docs.nestjs.com are excellent — read the Recipes section once you finish this course.
  • awesome-nestjs on GitHub for curated libraries and example apps.
  • The Trilon blog (the team behind Nest) for deep dives and patterns.
  • Build something. Ship something. Then come back and refactor it.

You now know enough to build a real production service in Nest. The rest is reps. Good luck — and ship often.