Skip to main content

NestJS on Kubernetes

NestJS logoNestJS logo

Structured TypeScript APIs with a health check, a dev pod and a production image.

larakube nestjs:new
🟡 Not yet verified🏘️ Joins the Plex Commons once verifiedTypeScriptScaffolds via official CLI

nestjs:new starts a NestJS API with the Nest CLI, adds the health endpoint Kubernetes needs, and generates a dev pod for your machine plus a production image and manifests for the cloud. NestJS is the first framework on LaraKube CLI's server-app engine, so the other non-PHP frameworks follow the path it proves.

Not yet verified

Every piece is built, but nobody has run the full walkthrough yet: scaffold, run locally, build the image, deploy through CI. Try it, but don't promise it to a client until this badge turns green.

🚀 Create a project

larakube nestjs:new api

LaraKube CLI runs the official @nestjs/cli inside a node:24-alpine container, under Docker or Podman, so you don't need Node on your machine. The project uses npm and strict TypeScript, without a git repository of its own. Then it asks:

ChoiceOptionsWith --fast
DatabasePostgreSQL (recommended), MySQL, MariaDBPostgreSQL
CacheRedis (recommended), MemcachedRedis
Object storageNone, MinIO (recommended), SeaweedFS, GarageMinIO
SearchNone, Meilisearch (meilisearch-js), Typesense (typesense-js)None

🧱 What LaraKube CLI adds

FileWhat it does
src/health.controller.tsA /healthz endpoint returning {"status":"ok"}, registered in AppModule
Dockerfile.nestjsInstalls dependencies, runs nest build, prunes to production dependencies, and starts node dist/main.js on port 3000
.dockerignoreKeeps your machine's node_modules and dist out of the image
.infrastructure/A dev pod for local work, and a Deployment, Service and Ingress for each cloud environment

Using Prisma? Once the project has prisma/schema.prisma, the next time LaraKube CLI regenerates its infrastructure the image runs prisma generate, and prisma migrate deploy runs in an init container before new pods take traffic.

🗄️ Databases and services

Your answers to the wizard are saved in .larakube.json, but LaraKube CLI doesn't provision a database, cache or storage for NestJS yet. There are no database pods, and nestjs:new doesn't join the Plex Commons. Point the app at services you run yourself for now; it will join the Commons once that's wired and verified.

💻 Run it locally

cd api
larakube up

The dev pod runs npm run start:dev on port 3000 and reloads as you edit. https://api.<your local domain>/healthz should return {"status":"ok"}.

☁️ Deploy

Create the cloud environment and its CI workflow:

larakube env production

Runtime values never go in the repository or the workflow. Put them in .env.production, then push them to the cluster:

larakube dotenv:push production

Commit and push. The workflow builds Dockerfile.nestjs, pushes the image, and rolls out the app. It stops with a clear error if you haven't run dotenv:push yet, rather than starting pods with no configuration.

➡️ Next