HUB
Sign inSign up
nginx-nodejs logo

lotuswebagency/nginx-nodejs

By lotuswebagency

•Updated 2 days ago

Rootless Node.js + Nginx runtime: Brotli/gzip statics, caching, s6 supervision, logs to Loki.

Image
Languages & frameworks
Web servers
Monitoring & observability
0

9.4K

lotuswebagency/nginx-nodejs repository overview

⁠lotuswebagency/nginx-nodejs

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.

  • Fast static delivery. Nginx serves files first with Brotli and gzip, precompressed .br and .gz siblings, immutable caching for /assets/, and falls back to Node for everything else.
  • Rootless and hardened. Every process runs as UID 1000. Read-only root, all capabilities dropped, no-new-privileges and noexec tmpfs are tested on every release.
  • Safe defaults. Security headers on every response, forged X-Forwarded-For rejected, source maps, dot files and node_modules blocked.
  • Sized to the container. Nginx workers follow the CPU quota and the V8 heap follows the memory limit.
  • Sanitized logs. Tokens, passwords, emails and IP addresses are scrubbed before anything is written. Optional Fluent Bit delivery to Loki with a disk queue.
  • Verifiable. Trivy-gated (no fixable HIGH or CRITICAL findings), Cosign-signed, with an SBOM and SLSA provenance. Rebuilt weekly on a digest-pinned Wolfi base.

GitHub⁠ · Full documentation⁠ · Lotus Web Agency⁠

⁠Quick start

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.

⁠Tags

TagContents
latest, 26, 26.14, 26.14.0Runtime on Node.js 26 (Active LTS)
24, 24.22, 24.22.3Runtime on Node.js 24 (Maintenance LTS)
builder, 26-builder, 24-builderBuild 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.

⁠Environment variables

VariableDefaultEffect
STATIC_ROOT/app/publicDirectory Nginx serves
APP_DIR/appWorking directory of the Node process
NODE_PORT3000Port Node listens on, loopback only
NODE_HEALTH_PATH/healthzRoute that must return 200
RUNTIME_MODEprodprod: static first, then Node. dev: everything to Node
NODE_ENVproductionPassed to your app
PUBLIC_SCHEMEhttphttps behind a TLS proxy; sent as X-Forwarded-Proto
INGRESS_TRUSTED_IPSemptyIPs or CIDRs of proxies allowed to set X-Forwarded-For
NGINX_WORKER_PROCESSESfrom the CPU quotaNginx workers, 1 to 64 or auto
NODE_MAX_OLD_SPACE_SIZEfrom the memory limitV8 heap in MB, or off
LOG_SERVICE, APP_ENVnginx-nodejs, productionLog and Loki labels
LOKI_ENABLED01 ships logs to Loki
LOKI_HOST, LOKI_PORT, LOKI_TLSnone, 3100, offLoki endpoint
LOKI_BEARER_TOKEN or LOKI_USER + LOKI_PASSWORDunsetLoki auth; each has a _FILE form for secrets
LOKI_TENANT_IDunsetX-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⁠.

⁠Image facts

  • Port 8080 (Nginx). Built-in healthcheck. User node, UID 1000.
  • Logs are written to /var/lib/nginx-nodejs/logs/, not docker logs. Mount a volume there.
  • Writable paths: /run/nginx-nodejs, /tmp, /var/lib/nginx-nodejs.
  • Allow 45 seconds to stop (--stop-timeout 45, stop_grace_period: 45s).
  • Precompress assets in your build (brotli -k -q 11, gzip -k -9) for zero CPU cost per request.

⁠Hardened deployment

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⁠.

⁠Verify the image

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

⁠More images from Lotus Web Agency

ImageWhat 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 imageRootless 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

⁠About

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.

Tag summary
Recent tags
Content type
Image
Digest
sha256:d5a590f8a…
Size
56.7 MB
Last updated
2 days ago
docker pull lotuswebagency/nginx-nodejs:latest