Rootless Node.js + Nginx runtime: Brotli/gzip statics, caching, s6 supervision, logs to Loki.
9.4K
A production runtime for Node.js web apps: Nginx in front, your Node server behind it, rootless, with safe logs and optional Loki delivery.
Running Node.js directly on a port means Node serves static files, compresses responses and has to be trusted with client headers, while logs leak tokens and email addresses. This image puts a tuned Nginx in front of your Node process inside one container, supervises both, and keeps the logs clean. Your code, build tooling and CI stay in your project; you only copy the build output in.
.br and
.gz siblings, immutable caching for /assets/, and falls back to Node for everything else.no-new-privileges and noexec tmpfs are tested on every release.X-Forwarded-For rejected, source
maps, dot files and node_modules blocked.GitHub · Full documentation · Lotus Web Agency
Try the built-in demo app:
docker run -d --init --read-only --stop-timeout 45 \
--tmpfs /run/nginx-nodejs:uid=1000,gid=1000,mode=0700 \
--tmpfs /tmp:uid=1000,gid=1000,mode=1777 \
-v app-logs:/var/lib/nginx-nodejs \
-p 127.0.0.1:8080:8080 lotuswebagency/nginx-nodejs
Package your application (Astro, Nuxt, Next.js standalone, Express or any Node server):
FROM lotuswebagency/nginx-nodejs:26-builder AS build
COPY --chown=node:node package.json package-lock.json ./
RUN npm ci
COPY --chown=node:node . ./
RUN npm run build
FROM lotuswebagency/nginx-nodejs:26
COPY --from=build --chown=node:node /app/dist/ /app/dist/
ENV STATIC_ROOT=/app/dist/client
CMD ["node", "dist/server/entry.mjs"]
Your app must listen on HOST and PORT (set by the image) and answer 200 on /healthz
(or set NODE_HEALTH_PATH). The command must start with node; npm start is not supported.
Put a TLS-terminating proxy in front and do not expose port 8080 directly.
| Tag | Contents |
|---|---|
latest, 26, 26.14, 26.14.0 | Runtime on Node.js 26 (Active LTS) |
24, 24.22, 24.22.3 | Runtime on Node.js 24 (Maintenance LTS) |
builder, 26-builder, 24-builder | Build stage: Node.js and npm, no Nginx |
Use the same major in both stages. Version tags are read from the built image. Platforms:
linux/amd64 and linux/arm64 (the CI gate tests amd64 only; arm64 is checked under QEMU emulation before
a release, not on native hardware).
Node.js 22 tags are frozen and get no updates. Pin a major or @sha256:... in
production: latest moves to a new major when one is added.
| Variable | Default | Effect |
|---|---|---|
STATIC_ROOT | /app/public | Directory Nginx serves |
APP_DIR | /app | Working directory of the Node process |
NODE_PORT | 3000 | Port Node listens on, loopback only |
NODE_HEALTH_PATH | /healthz | Route that must return 200 |
RUNTIME_MODE | prod | prod: static first, then Node. dev: everything to Node |
NODE_ENV | production | Passed to your app |
PUBLIC_SCHEME | http | https behind a TLS proxy; sent as X-Forwarded-Proto |
INGRESS_TRUSTED_IPS | empty | IPs or CIDRs of proxies allowed to set X-Forwarded-For |
NGINX_WORKER_PROCESSES | from the CPU quota | Nginx workers, 1 to 64 or auto |
NODE_MAX_OLD_SPACE_SIZE | from the memory limit | V8 heap in MB, or off |
LOG_SERVICE, APP_ENV | nginx-nodejs, production | Log and Loki labels |
LOKI_ENABLED | 0 | 1 ships logs to Loki |
LOKI_HOST, LOKI_PORT, LOKI_TLS | none, 3100, off | Loki endpoint |
LOKI_BEARER_TOKEN or LOKI_USER + LOKI_PASSWORD | unset | Loki auth; each has a _FILE form for secrets |
LOKI_TENANT_ID | unset | X-Scope-OrgID |
Invalid settings stop the container with exit code 78 and a message naming the problem. Full reference, caching rules and the log contract: README.
8080 (Nginx). Built-in healthcheck. User node, UID 1000./var/lib/nginx-nodejs/logs/, not docker logs. Mount a volume there./run/nginx-nodejs, /tmp, /var/lib/nginx-nodejs.--stop-timeout 45, stop_grace_period: 45s).brotli -k -q 11, gzip -k -9) for zero CPU cost per request.services:
app:
image: registry.example.com/my-app:1.0 # built FROM lotuswebagency/nginx-nodejs
init: true
read_only: true
cap_drop: [ALL]
security_opt: ["no-new-privileges:true"]
pids_limit: 256
stop_grace_period: 45s
environment:
PUBLIC_SCHEME: https
INGRESS_TRUSTED_IPS: 172.18.0.0/16
tmpfs:
- /run/nginx-nodejs:noexec,nosuid,nodev,uid=1000,gid=1000,mode=0700
- /tmp:noexec,nosuid,nodev,uid=1000,gid=1000,mode=1777
volumes:
- app-logs:/var/lib/nginx-nodejs
volumes:
app-logs:
Kubernetes manifest: README.
cosign verify lotuswebagency/nginx-nodejs:latest \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
--certificate-identity-regexp '^https://github\.com/LotusWebAgency/docker-workflows/\.github/workflows/build-image\.yml@' \
--certificate-github-workflow-repository LotusWebAgency/nginx-nodejs
| Image | What it does |
|---|---|
dementev/angie — source | Public-facing reverse proxy and TLS terminator — Angie, the nginx fork, with brotli, zstd and cache-purge |
dementev/nginx — source | Static sites and SPAs behind that proxy — brotli/zstd siblings, Prometheus stub_status |
lotuswebagency/php — source | PHP 7.0 → 8.5 compiled from source on Wolfi, hardened and signed — successor to the deprecated dementev/php-fpm-with-ext |
lotuswebagency/nginx-nodejs — this image | Rootless Node.js runtime behind Nginx, with sanitized logs and optional Loki delivery |
lotuswebagency/mysql-percona — source | Percona Server for MySQL 8.4 and 9.7 LTS with XtraBackup, compiled from source with PGO and hardened — the from-source successor to dementev/mysql-percona |
dementev/mysql-percona — source | Percona Server for MySQL 8.4 LTS, XtraBackup built in, no root inside |
dementev/adminer — source | Adminer 6 with every driver it supports, for reaching any of the above |
Built and maintained by Vasilii Dementev at Lotus Web Agency. All our open-source work: lotuswebagency.com/open-source.
Issues and pull requests: GitHub. Security reports: SECURITY.md. Packaging is MIT licensed; Node.js, Nginx, s6, Fluent Bit and the other bundled software keep their own licenses.
docker pull lotuswebagency/nginx-nodejs:latest