Implement Scraper Dockerfile and Refactor CI Configuration

- Added a new Dockerfile for the scraper application located at cmd/scraper/Dockerfile to streamline the build process.
- Updated the CI configuration in .drone.yml to correctly build the scraper application with the new Dockerfile.
- Refactored the main application entry point to utilize a new bootstrap package for configuration, logging, and MongoDB initialization.
- Enhanced the scraper's configuration management by defining a dedicated Config struct for better organization and maintainability.
This commit is contained in:
n.nakhostin
2025-08-31 14:23:01 +03:30
parent 511155e0a7
commit 45d2e84fd7
5 changed files with 48 additions and 26 deletions
+6 -6
View File
@@ -2,25 +2,25 @@ package main
import (
"context"
"log"
"time"
"tm/cmd/scraper/bootstrap"
)
func main() {
// Load configuration
config, err := LoadConfig(".")
config, err := bootstrap.InitConfig()
if err != nil {
log.Fatalf("Failed to load configuration: %v", err)
panic(err)
}
// Initialize logger
appLogger := initLogger(config.Logging)
appLogger := bootstrap.InitLogger(config.Logging)
appLogger.Info("Starting TED scraper application", map[string]interface{}{
"version": "1.0.0",
})
// Initialize MongoDB connection
mongoManager := initMongoDB(config.Database.MongoDB, appLogger)
mongoManager := bootstrap.InitMongoDB(config.Database.MongoDB, appLogger)
defer func() {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
@@ -31,7 +31,7 @@ func main() {
}
}()
initTEDScraper(*config, mongoManager, appLogger)
bootstrap.InitTEDScraper(*config, mongoManager, appLogger)
appLogger.Info("TED scraper application stopped", map[string]interface{}{})
}