NestJS
Compile your Nest application and run its production Node entry point.
Deploy a NestJS app as a compiled Node server.
Compile and start the app
Set the build script to nest build. It normally writes dist/main.js. If yours
ends up somewhere else, such as in a monorepo, change the Dockerfile's CMD to match.
In main.ts, listen on 0.0.0.0 and the port in PORT:
await app.listen(Number(process.env.PORT ?? 3000), "0.0.0.0");
Add a controller route that returns 200, and set it as the app's health path
in Configuration. Include any global prefix: a /health route under an api
prefix is /api/health.
Build with a Dockerfile
This Dockerfile uses npm. For pnpm, Yarn or Bun, copy that tool's lockfile instead and change the install line.
FROM node:24.21.0-bookworm-slim@sha256:d6aa754f16b3197301076f047b5def2f02ea1dbbc2ca920407d46d7ec7f87b20 AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:24.21.0-bookworm-slim@sha256:d6aa754f16b3197301076f047b5def2f02ea1dbbc2ca920407d46d7ec7f87b20
WORKDIR /app
ENV NODE_ENV=production HOST=0.0.0.0 PORT=3000
COPY --from=build --chown=10001:10001 /app ./
USER 10001:10001
EXPOSE 3000
CMD ["node", "dist/main.js"]
Deploy the app
Save the Dockerfile at the source root. In Configuration, set the port to
3000 and the health path to the route you added above. Add a .dockerignore
that excludes .env*, .git, node_modules and local build output, then deploy:
smolcloud deploy APP_ID .
Open the address it prints. You can also call a route from the CLI:
smolcloud request APP_ID /
You don't have to write a Dockerfile: see Automatic builds. To add a database or file storage, see Databases and files.
See also: NestJS production guidance.