mirror of
https://github.com/nprasad2077/NBA_Go.git
synced 2026-09-22 05:55:13 +00:00
working remote db
This commit is contained in:
@@ -23,6 +23,7 @@ go.work.sum
|
|||||||
|
|
||||||
# env file
|
# env file
|
||||||
.env
|
.env
|
||||||
|
.env.local
|
||||||
|
|
||||||
|
|
||||||
data/nba.db
|
data/nba.db
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
# docker-compose.local.yml
|
||||||
|
#
|
||||||
|
# Use this file to run local services (API, Nginx, etc.) while
|
||||||
|
# connecting to a REMOTE database.
|
||||||
|
#
|
||||||
|
# This version includes the 'db-init' service. Note that this service
|
||||||
|
# will attempt to run its 'import-data' command every time you execute
|
||||||
|
# 'docker-compose up'.
|
||||||
|
|
||||||
|
services:
|
||||||
|
# This service runs the 'import-data' command against the remote database
|
||||||
|
# specified in your '.env.local' file. It has no 'depends_on' since there
|
||||||
|
# is no local postgres container to wait for.
|
||||||
|
db-init:
|
||||||
|
build: .
|
||||||
|
env_file: .env.local
|
||||||
|
command: ["/nba_go", "import-data"]
|
||||||
|
networks:
|
||||||
|
- api.network
|
||||||
|
restart: "no"
|
||||||
|
|
||||||
|
# API services now have no 'depends_on' section.
|
||||||
|
# They will start and immediately try to connect to the DB_HOST in your .env file.
|
||||||
|
api1:
|
||||||
|
build: .
|
||||||
|
env_file: .env.local
|
||||||
|
ports:
|
||||||
|
- '5001:5000'
|
||||||
|
networks:
|
||||||
|
- api.network
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
api2:
|
||||||
|
build: .
|
||||||
|
env_file: .env.local
|
||||||
|
ports:
|
||||||
|
- '5002:5000'
|
||||||
|
networks:
|
||||||
|
- api.network
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
api3:
|
||||||
|
build: .
|
||||||
|
env_file: .env.local
|
||||||
|
ports:
|
||||||
|
- '5003:5000'
|
||||||
|
networks:
|
||||||
|
- api.network
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
image: 'nginx:stable'
|
||||||
|
volumes:
|
||||||
|
- './nginx/nginx.conf:/etc/nginx/nginx.conf:ro'
|
||||||
|
depends_on:
|
||||||
|
- api1
|
||||||
|
- api2
|
||||||
|
- api3
|
||||||
|
ports:
|
||||||
|
- '8080: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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
# The 'postgres_data' volume is not needed in this configuration.
|
||||||
|
prometheus_data:
|
||||||
|
grafana_data:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
api.network: null
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
# docker-compose.override.yml
|
||||||
|
#
|
||||||
|
# This file is used for local development to connect to a REMOTE database.
|
||||||
|
# It overrides the main 'docker-compose.yml' by:
|
||||||
|
# 1. Disabling the local 'postgres' service by replacing it with a container that runs forever.
|
||||||
|
# 2. Removing the 'depends_on' conditions from other services that rely on the local database.
|
||||||
|
|
||||||
|
services:
|
||||||
|
# This section effectively disables the local postgres service.
|
||||||
|
# Instead of `command: "true"`, which exits immediately, we use `tail -f /dev/null`
|
||||||
|
# to keep the container running indefinitely, satisfying Docker Compose.
|
||||||
|
postgres:
|
||||||
|
image: busybox
|
||||||
|
command: ["tail", "-f", "/dev/null"]
|
||||||
|
networks: []
|
||||||
|
healthcheck: {}
|
||||||
|
volumes: []
|
||||||
|
|
||||||
|
# Remove the dependency on the local postgres container for the db-init service.
|
||||||
|
# It will now start immediately and use the DB_HOST from your .env.local file.
|
||||||
|
db-init:
|
||||||
|
depends_on: {}
|
||||||
|
|
||||||
|
# Remove the dependency on the local postgres container for the api1 service.
|
||||||
|
api1:
|
||||||
|
depends_on: {}
|
||||||
|
|
||||||
|
# Remove the dependency on the local postgres container for the api2 service.
|
||||||
|
api2:
|
||||||
|
depends_on: {}
|
||||||
|
|
||||||
|
# Remove the dependency on the local postgres container for the api3 service.
|
||||||
|
api3:
|
||||||
|
depends_on: {}
|
||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
// importPlayerAdvanced fetches and stores advanced stats for seasons 2017–2025
|
// importPlayerAdvanced fetches and stores advanced stats for seasons 2017–2025
|
||||||
func importPlayerAdvanced(db *gorm.DB) {
|
func importPlayerAdvanced(db *gorm.DB) {
|
||||||
for season := 2023; season <= 2025; season++ {
|
for season := 2015; season <= 2019; season++ {
|
||||||
if err := services.FetchAndStorePlayerAdvancedScrapedStats(db, season, false); err != nil {
|
if err := services.FetchAndStorePlayerAdvancedScrapedStats(db, season, false); err != nil {
|
||||||
log.Printf("advanced import failed for %d: %v", season, err)
|
log.Printf("advanced import failed for %d: %v", season, err)
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@ func importPlayerAdvanced(db *gorm.DB) {
|
|||||||
|
|
||||||
// importPlayerAdvancedPlayoffs fetches and stores advanced stats for playoffs seasons 2023–2025
|
// importPlayerAdvancedPlayoffs fetches and stores advanced stats for playoffs seasons 2023–2025
|
||||||
func importPlayerAdvancedPlayoffs(db *gorm.DB) {
|
func importPlayerAdvancedPlayoffs(db *gorm.DB) {
|
||||||
for season := 2023; season <= 2025; season++ {
|
for season := 2015; season <= 2019; season++ {
|
||||||
if err := services.FetchAndStorePlayerAdvancedScrapedStats(db, season, true); err != nil {
|
if err := services.FetchAndStorePlayerAdvancedScrapedStats(db, season, true); err != nil {
|
||||||
log.Printf("advanced import failed for %d: %v", season, err)
|
log.Printf("advanced import failed for %d: %v", season, err)
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ func importPlayerAdvancedPlayoffs(db *gorm.DB) {
|
|||||||
|
|
||||||
// importPlayerTotalsScrape fetches & stores scraped regular-season total stats
|
// importPlayerTotalsScrape fetches & stores scraped regular-season total stats
|
||||||
func importPlayerTotalsScrape(db *gorm.DB) {
|
func importPlayerTotalsScrape(db *gorm.DB) {
|
||||||
for season := 2023; season <= 2025; season++ {
|
for season := 2015; season <= 2019; season++ {
|
||||||
if err := services.FetchAndStorePlayerTotalScrapedStats(db, season, false); err != nil {
|
if err := services.FetchAndStorePlayerTotalScrapedStats(db, season, false); err != nil {
|
||||||
log.Printf("scraped totals import failed for %d: %v", season, err)
|
log.Printf("scraped totals import failed for %d: %v", season, err)
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ func importPlayerTotalsScrape(db *gorm.DB) {
|
|||||||
|
|
||||||
// importPlayerPlayoffsScrape fetches & stores scraped playoff total stats
|
// importPlayerPlayoffsScrape fetches & stores scraped playoff total stats
|
||||||
func importPlayerTotalsPlayoffsScrape(db *gorm.DB) {
|
func importPlayerTotalsPlayoffsScrape(db *gorm.DB) {
|
||||||
for season := 2023; season <= 2025; season++ {
|
for season := 2015; season <= 2019; season++ {
|
||||||
if err := services.FetchAndStorePlayerTotalScrapedStats(db, season, true); err != nil {
|
if err := services.FetchAndStorePlayerTotalScrapedStats(db, season, true); err != nil {
|
||||||
log.Printf("scraped playoffs import failed for %d: %v", season, err)
|
log.Printf("scraped playoffs import failed for %d: %v", season, err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user