Node PostgreSQL Nginx Docker Compose
Copy a ready-to-run Node.js + PostgreSQL + Nginx docker-compose.yml for local development. Includes .env.example, commands, and connection strings — no signup.
Node.js + PostgreSQL + Nginx
Copy a ready-to-run Node.js + PostgreSQL + Nginx docker-compose.yml for local development. Includes .env.example, commands, and connection strings — no signup.
此工具在你的浏览器本地运行。你的输入不会被上传。
Copy the generated result or open the full tool to adjust inputs locally.
Node.js + PostgreSQL + Nginx
services:
app:
image: "node:22-alpine"
command: npm run dev
env_file:
- .env
ports:
- "3000:3000"
depends_on:
- db
volumes:
- ".:/app"
working_dir: /app
networks:
- app_network
db:
image: "postgres:16-alpine"
environment:
POSTGRES_DB: "${POSTGRES_DB}"
POSTGRES_USER: "${POSTGRES_USER}"
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
ports:
- "5432:5432"
volumes:
- "postgres_data:/var/lib/postgresql/data"
healthcheck:
test:
- CMD-SHELL
- "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"
interval: "10s"
timeout: "5s"
retries: 5
networks:
- app_network
nginx:
image: "nginx:1.27-alpine"
ports:
- "80:80"
volumes:
- "./nginx.conf:/etc/nginx/conf.d/default.conf:ro"
depends_on:
- app
networks:
- app_network
volumes:
postgres_data: {}
networks:
app_network:
driver: bridge
# .env.example
COMPOSE_PROJECT_NAME=node_api
APP_PORT=3000
APP_ENV=development
APP_SECRET=change-me
POSTGRES_DB=app
POSTGRES_USER=app
POSTGRES_PASSWORD=change-me
DATABASE_URL=postgresql://app:change-me@db:5432/app
DATABASE_PORT=5432
# Commands
cp .env.example .env
docker compose up -d --build
docker compose ps
docker compose logs -f app
docker compose exec app sh
docker compose down
docker compose down -v # remove named volumes and local data
# Notes
PostgreSQL internal: postgresql://app:${POSTGRES_PASSWORD}@db:5432/app
PostgreSQL local: postgresql://app:${POSTGRES_PASSWORD}@localhost:${DATABASE_PORT}/app
Preset: Node.js + PostgreSQL + Nginx
Mode: development
Notes:
- Review image tags, commands, and mounted paths for your actual application layout.
- Secrets are represented as environment variables in .env.example; replace placeholder values before use.
- Healthchecks are included for supported infrastructure services.
- Named Docker volumes are enabled for local persistence.Copy a ready-to-run Node.js + PostgreSQL + Nginx docker-compose.yml for local development. Includes .env.example, commands, and connection strings — no signup.
Node.js + PostgreSQL + Nginx
It is a strong starter, not a hardened production deployment. Review secrets, TLS, backups, resource limits, and network exposure before production use.
No. Preset generation is static and the interactive builder runs locally in the browser.
Yes. The page exposes copyable and downloadable output for docker-compose.yml and related notes.