mirror of
https://github.com/nprasad2077/NBA_Go.git
synced 2026-09-22 14:05:13 +00:00
dev mode returned local
This commit is contained in:
+2
-1
@@ -4,7 +4,8 @@ FROM golang:1.24-bullseye AS builder
|
||||
ENV CGO_ENABLED=1
|
||||
ENV GOOS=linux
|
||||
# Changed from Apple Silicon arm64 config.
|
||||
ENV GOARCH=amd64
|
||||
# ENV GOARCH=amd64
|
||||
ENV GOARCH=arm64
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
||||
+43
-20
@@ -1,49 +1,72 @@
|
||||
# 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'.
|
||||
version: '3.8'
|
||||
|
||||
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.
|
||||
# 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.local
|
||||
command: ["/nba_go", "import-data"]
|
||||
env_file: .env
|
||||
command: ["/nba_go"]
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
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.
|
||||
# MODIFIED: All API services now depend on postgres being healthy.
|
||||
# The volume mount for './data' is no longer needed.
|
||||
api1:
|
||||
build: .
|
||||
env_file: .env.local
|
||||
env_file: .env
|
||||
ports:
|
||||
- '5001:5000'
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- api.network
|
||||
restart: always
|
||||
|
||||
api2:
|
||||
build: .
|
||||
env_file: .env.local
|
||||
env_file: .env
|
||||
ports:
|
||||
- '5002:5000'
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- api.network
|
||||
restart: always
|
||||
|
||||
api3:
|
||||
build: .
|
||||
env_file: .env.local
|
||||
env_file: .env
|
||||
ports:
|
||||
- '5003:5000'
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- api.network
|
||||
restart: always
|
||||
@@ -57,7 +80,7 @@ services:
|
||||
- api2
|
||||
- api3
|
||||
ports:
|
||||
- '8080:8080'
|
||||
- '8081:8080'
|
||||
networks:
|
||||
- api.network
|
||||
|
||||
@@ -93,7 +116,7 @@ services:
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
# The 'postgres_data' volume is not needed in this configuration.
|
||||
postgres_data: # New volume for Postgres
|
||||
prometheus_data:
|
||||
grafana_data:
|
||||
|
||||
|
||||
+1
-1
@@ -477,7 +477,7 @@ var SwaggerInfo = &swag.Spec{
|
||||
Version: "1.0",
|
||||
Host: "",
|
||||
BasePath: "/",
|
||||
Schemes: []string{"https"},
|
||||
Schemes: []string{"http"},
|
||||
Title: "NBA_Go API",
|
||||
Description: "Stats service, now with public access!",
|
||||
InfoInstanceName: "swagger",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"schemes": [
|
||||
"https"
|
||||
"http"
|
||||
],
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
|
||||
+1
-1
@@ -303,7 +303,7 @@ paths:
|
||||
- PlayerTotals
|
||||
x-order: 1
|
||||
schemes:
|
||||
- https
|
||||
- http
|
||||
swagger: "2.0"
|
||||
tags:
|
||||
- name: PlayerTotals
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
// importPlayerAdvanced fetches and stores advanced stats for seasons 2017–2025
|
||||
func importPlayerAdvanced(db *gorm.DB) {
|
||||
for season := 1991; season <= 2002; season++ {
|
||||
for season := 2024; season <= 2025; season++ {
|
||||
if err := services.FetchAndStorePlayerAdvancedScrapedStats(db, season, false); err != nil {
|
||||
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
|
||||
func importPlayerAdvancedPlayoffs(db *gorm.DB) {
|
||||
for season := 1991; season <= 2002; season++ {
|
||||
for season := 2024; season <= 2025; season++ {
|
||||
if err := services.FetchAndStorePlayerAdvancedScrapedStats(db, season, true); err != nil {
|
||||
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
|
||||
func importPlayerTotalsScrape(db *gorm.DB) {
|
||||
for season := 1991; season <= 2002; season++ {
|
||||
for season := 2024; season <= 2025; season++ {
|
||||
if err := services.FetchAndStorePlayerTotalScrapedStats(db, season, false); err != nil {
|
||||
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
|
||||
func importPlayerTotalsPlayoffsScrape(db *gorm.DB) {
|
||||
for season := 1991; season <= 2002; season++ {
|
||||
for season := 2024; season <= 2025; season++ {
|
||||
if err := services.FetchAndStorePlayerTotalScrapedStats(db, season, true); err != nil {
|
||||
log.Printf("scraped playoffs import failed for %d: %v", season, err)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// @title NBA_Go API
|
||||
// @version 1.0
|
||||
// @description Stats service, now with public access!
|
||||
// @schemes https
|
||||
// //@schemes https
|
||||
// @schemes http
|
||||
// @BasePath /
|
||||
//
|
||||
// @tag.name PlayerTotals
|
||||
@@ -45,7 +46,7 @@ import (
|
||||
func main() {
|
||||
// ——— One-off import-data mode ———
|
||||
if len(os.Args) > 1 && os.Args[1] == "import-data" {
|
||||
// Run all migrations + import steps exactly once
|
||||
// Run all DB migrations + import steps exactly once
|
||||
db := config.InitDB(true)
|
||||
|
||||
importPlayerAdvanced(db)
|
||||
|
||||
Reference in New Issue
Block a user