A lightweight, containerized development environment featuring a Node.js (v24-slim) application container fronted by an NGINX (alpine) reverse proxy, configured using Docker Compose, a Makefile, and custom directory structures.
app1: Runs a Node.js 24 environment (node:24-slim) mapping port3000internally. It executes a basic HTTP server located in./www/app1/server.mjs.web: Runs an NGINX reverse proxy (nginx:alpine) mapped to host port80. It routes incoming traffic toapp1using dynamic DNS resolution (127.0.0.11) to prevent container startup race conditions.- Network: Both services communicate through a custom bridge network named
nodejs-network.
.
├── docker-compose.yml
├── Makefile
├── nginx
│ └── conf.d
│ ├── app1.conf
│ └── README.md
├── README.md
└── www
├── app1
│ └── server.mjs
└── README.md
- Docker
- Docker Compose
make(optional, for convenience commands)
Ensure your project directory matches the structure above.
You can start the containers in detached mode using the provided Makefile or Docker Compose directly:
Using make:
make upUsing Docker Compose:
docker compose up -dTo stop and remove the containers:
Using make:
make downUsing Docker Compose:
docker compose down- Add a local host entry to your
/etc/hostsfile (or equivalent) to resolveapp1.localhostto127.0.0.1:127.0.0.1 app1.localhost - Open your browser or run a
curlrequest:Expected response:curl http://app1.localhost
Hello World!
The NGINX configuration uses Docker's embedded DNS resolver (127.0.0.11) with variable-based proxying (set $upstream_app1 http://app1:3000;). This ensures NGINX gracefully handles situations where the Node.js container restarts or starts up after NGINX.
A minimal standalone ECMAScript module (.mjs) running a native Node.js HTTP server on port 3000.