node-docker-example/docker-compose.yml
2022-03-22 00:37:06 +03:00

51 lines
1.1 KiB
YAML

version: '3.8'
services:
nginx:
container_name: nginx
restart: always
image: nginx:latest
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
ports:
- 80:80
depends_on:
- backend
backend:
container_name: nodejs
restart: always
build:
context: .
target: production
ports:
- ${PORT}:${PORT}
env_file:
- .env
environment:
- NODE_ENV=production
- PG_HOST=postgres
- PG_PORT=5432
- PG_USER=postgres
- PG_PASSWORD=1234
- PG_DB_NAME=articles
volumes:
- ./:/home/node/app
command: dumb-init node index.js
depends_on:
- postgres
postgres:
container_name: postgres
image: postgres:14
volumes:
- postgres_volume:/var/lib/postgresql/data
- ./sql/schema_init.sql:/docker-entrypoint-initdb.d/schema_init.sql
- ./sql/seed.sql:/docker-entrypoint-initdb.d/seed.sql
environment:
POSTGRES_USER: ${PG_USER}
POSTGRES_PASSWORD: ${PG_PASSWORD}
POSTGRES_DB: ${PG_DB_NAME}
ports:
- 5432:5432
volumes:
postgres_volume: