Skip to content

Express, Fastify and NestJS ​

Plain Node.js servers are detected from their dependencies (Express, Fastify, Koa, Hono, hapi, NestJS, Socket.IO) or simply from a start script.

What runs ​

In order:

  1. NestJS: the start:prod script if you have one, else node dist/main;
  2. your start script, for example "start": "node server.js";
  3. node <main> from package.json, or the first of server.js, index.js, app.js, main.js, server.mjs, index.mjs.

If there is a build script (for example tsc or nest build), it runs first.

Development dependencies are pruned from the image when the start command does not use them. If your start command needs a dev dependency (for example ts-node), it is kept.

Listen on $PORT and 0.0.0.0 ​

js
// Express
const port = Number(process.env.PORT) || 8080
app.listen(port, '0.0.0.0', () => console.log(`listening on ${port}`))
js
// Fastify
await app.listen({ port: Number(process.env.PORT) || 8080, host: '0.0.0.0' })
ts
// NestJS main.ts
await app.listen(process.env.PORT ?? 8080, '0.0.0.0')

Fastify listens on 127.0.0.1 by default, which is not reachable from outside the container: always pass host: '0.0.0.0'.

Dev servers are ignored ​

nodemon, ts-node-dev and nest start --watch are development tools. As a start command they are ignored in favour of the production entry. Use node (or nest start without --watch).

Health checks ​

Add a lightweight route such as GET /health and set it as the Healthcheck path, so new versions only receive traffic once they are ready.

Fjordrun is hosted in the EU (Hetzner, Nuremberg, Germany). Private beta.