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: - nodejs networks: - app-network nodejs: container_name: nodejs restart: always build: context: . target: production dockerfile: Dockerfile ports: - 4000:4000 environment: - NODE_ENV=production - PG_HOST=postgres - PG_PORT=5432 - PG_USER=postgres - PG_PASSWORD=1234 - PG_DB_NAME=articles volumes: - ./:/home/node/app - node_modules:/home/node/app/node_modules entrypoint: ['./scripts/wait-for.sh', 'postgres:5432', '--'] command: ['dumb-init', 'node', 'index.js'] networks: - app-network 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: postgres POSTGRES_PASSWORD: 1234 POSTGRES_DB: articles ports: - 5432:5432 networks: - app-network volumes: postgres_volume: node_modules: networks: app-network: driver: bridge