Sign inSign up

minhle202/node-api

By minhle202

Updated 4 months ago

Minimal Node.js 22 + Fastify REST API starter — multi-stage, non-root, healthcheck. Multi-arch.

Image
0

371

minhle202/node-api repository overview

docker-node-api

A minimal, production-ready Node.js 22 + Fastify REST API starter in a small, multi-stage Docker image. Use it as a clean foundation for building HTTP services without the boilerplate.

Quick start

docker pull minhle202/node-api
docker run --rm -p 3000:3000 minhle202/node-api
curl http://localhost:3000/health
curl "http://localhost:3000/api/hello?name=Minh"

Endpoints

  • GET / — service info JSON (name, version, available endpoints).
  • GET /health — health check returning { "status": "ok", "uptime": <seconds> }.
  • GET /api/hello?name= — greeting; name defaults to world.

What's inside

  • Node.js 22 on the pinned node:22-alpine base — small footprint.
  • Fastify 5 as the only runtime dependency.
  • Multi-stage build: prod dependencies installed via npm ci --omit=dev, then copied into a clean runtime layer.
  • Runs as the non-root node user.
  • Built-in HEALTHCHECK hitting /health using Node's native fetch (no curl/wget needed).
  • Graceful shutdown on SIGTERM / SIGINT.
  • Multi-arch: linux/amd64 and linux/arm64.

Configuration

Env varDefaultDescription
PORT3000Listen port
HOST0.0.0.0Bind address
LOG_LEVELinfoFastify logger level
NODE_ENVproductionSet in the image

Override at runtime:

docker run --rm -p 8080:8080 -e PORT=8080 minhle202/node-api

License

MIT © Lê Đức Minh

Tag summary

Content type

Image

Digest

sha256:9809a7271

Size

56.1 MB

Last updated

4 months ago

docker pull minhle202/node-api