Skip to main content

Node.js React + Fastify REST

The Node.js stack uses separate Dockerfiles for each component due to different runtime requirements.

Images​

ImageDefault PortBase Image
stemix-nodejs-react-fastify-rest-web3400nginx:alpine
stemix-nodejs-react-fastify-rest-bff8400node:24-alpine

Build​

# Both images
make -C stacks/nodejs/react-fastify/rest build-containers

# Individual
make -C stacks/nodejs/react-fastify/rest build-container-web
make -C stacks/nodejs/react-fastify/rest build-container-bff

Web Container (nginx)​

The web container serves the Vite-built React SPA via nginx and proxies /api/* requests to the BFF backend.

Environment Variables​

VariableRequiredDescription
BFF_URLYesBFF backend URL (example: http://host.docker.internal:8400)

The BFF_URL variable is injected at container startup using the nginx official image's built-in envsubst template processing. No custom entrypoint script is needed.

Architecture​

Browser --> nginx:3400 --> /api/* proxy_pass --> BFF_URL
--> /* static SPA files

BFF Container (Fastify)​

Environment Variables​

VariableDefaultDescription
OUR_IDP_API_HOST0.0.0.0Bind address
OUR_IDP_API_PORT8400Listen port

Dockerfiles​

  • Web: stacks/nodejs/react-fastify/rest/web/Dockerfile
  • BFF: stacks/nodejs/react-fastify/rest/bff/Dockerfile

Both Dockerfiles require the repo root as build context because the pnpm workspace metadata and pnpm-lock.yaml live at root.