mirror of
https://github.com/nprasad2077/NBA_Go.git
synced 2026-09-22 05:55:13 +00:00
129 lines
2.9 KiB
YAML
129 lines
2.9 KiB
YAML
version: '3.8'
|
|
|
|
services:
|
|
# NEW: Add a dedicated PostgreSQL database service
|
|
postgres:
|
|
image: postgres:15-alpine
|
|
environment:
|
|
POSTGRES_USER: ${DB_USER}
|
|
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
|
POSTGRES_DB: ${DB_NAME}
|
|
ports:
|
|
- '${DB_PORT}:5432' # Expose DB port to host machine for local tools
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data # Persist data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${DB_USER} -d ${DB_NAME}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
- api.network
|
|
|
|
# MODIFIED: This service now runs migrations and imports against the live Postgres DB
|
|
# "import-data" on initial run to migrate and import data.
|
|
db-init:
|
|
build: .
|
|
env_file: .env
|
|
command: ["/nba_go", "import-data"]
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
networks:
|
|
- api.network
|
|
restart: "no"
|
|
|
|
# MODIFIED: All API services now depend on postgres being healthy.
|
|
# The volume mount for './data' is no longer needed.
|
|
api1:
|
|
build: .
|
|
env_file: .env
|
|
ports:
|
|
- '5001:5000'
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
networks:
|
|
- api.network
|
|
restart: always
|
|
|
|
api2:
|
|
build: .
|
|
env_file: .env
|
|
ports:
|
|
- '5002:5000'
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
networks:
|
|
- api.network
|
|
restart: always
|
|
|
|
api3:
|
|
build: .
|
|
env_file: .env
|
|
ports:
|
|
- '5003:5000'
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
networks:
|
|
- api.network
|
|
restart: always
|
|
|
|
nginx:
|
|
image: 'nginx:stable'
|
|
volumes:
|
|
- './nginx/nginx.conf:/etc/nginx/nginx.conf:ro'
|
|
depends_on:
|
|
- api1
|
|
- api2
|
|
- api3
|
|
ports:
|
|
- '8081:8080'
|
|
networks:
|
|
- api.network
|
|
|
|
prometheus:
|
|
image: 'prom/prometheus:latest'
|
|
volumes:
|
|
- './prometheus/prometheus.yml:/etc/prometheus/prometheus.yml'
|
|
- 'prometheus_data:/prometheus'
|
|
command:
|
|
- '--config.file=/etc/prometheus/prometheus.yml'
|
|
- '--storage.tsdb.path=/prometheus'
|
|
- '--web.console.libraries=/etc/prometheus/console_libraries'
|
|
- '--web.console.templates=/etc/prometheus/consoles'
|
|
ports:
|
|
- '9090:9090'
|
|
networks:
|
|
- api.network
|
|
restart: unless-stopped
|
|
logging:
|
|
driver: "none"
|
|
|
|
grafana:
|
|
image: grafana/grafana:latest
|
|
ports:
|
|
- '3001:3000'
|
|
environment:
|
|
- GF_SECURITY_ADMIN_PASSWORD=testing
|
|
volumes:
|
|
- './grafana/provisioning/datasources:/etc/grafana/provisioning/datasources'
|
|
- './grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards'
|
|
- './grafana/dashboards:/var/lib/grafana/dashboards'
|
|
- 'grafana_data:/var/lib/grafana'
|
|
networks:
|
|
- api.network
|
|
restart: unless-stopped
|
|
logging:
|
|
driver: none
|
|
|
|
volumes:
|
|
postgres_data: # New volume for Postgres
|
|
prometheus_data:
|
|
grafana_data:
|
|
|
|
networks:
|
|
api.network: null
|