Refactor Dockerfile and CI Configuration
- Updated the CI configuration in .drone.yml to use the new Dockerfile located at ./cmd/web/Dockerfile. - Removed the old Dockerfile and Dockerfile-drone as they are no longer needed. - Refactored the cmd/web/Dockerfile to streamline the build process and improve organization. - Introduced a new bootstrap package to handle application initialization, including configuration, logging, MongoDB, Redis, and authorization service setup. - Added a health check endpoint for monitoring the server status, enhancing the API's operational capabilities.
This commit is contained in:
+8
-7
@@ -71,18 +71,19 @@ import (
|
||||
"tm/internal/tender_approval"
|
||||
"tm/internal/user"
|
||||
|
||||
"tm/cmd/web/bootstrap"
|
||||
_ "tm/cmd/web/docs" // This is generated by swag
|
||||
"tm/cmd/web/router"
|
||||
)
|
||||
|
||||
func main() {
|
||||
conf := initConfig()
|
||||
conf := bootstrap.InitConfig()
|
||||
|
||||
logger := initLogger(conf.Logging)
|
||||
logger := bootstrap.InitLogger(conf.Logging)
|
||||
defer logger.Sync()
|
||||
|
||||
// Initialize MongoDB connection manager
|
||||
mongoManager := initMongoDB(conf.Database.MongoDB, logger)
|
||||
mongoManager := bootstrap.InitMongoDB(conf.Database.MongoDB, logger)
|
||||
defer func() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
@@ -94,7 +95,7 @@ func main() {
|
||||
}()
|
||||
|
||||
// Initialize Redis connection manager
|
||||
redisClient := initRedis(conf.Cache.Redis, logger)
|
||||
redisClient := bootstrap.InitRedis(conf.Cache.Redis, logger)
|
||||
defer func() {
|
||||
if err := redisClient.Close(); err != nil {
|
||||
logger.Error("Failed to close Redis connection", map[string]interface{}{
|
||||
@@ -104,8 +105,8 @@ func main() {
|
||||
}()
|
||||
|
||||
// Initialize authorization service
|
||||
userAuthService := initAuthorizationService(conf.UserAuth.JWT, redisClient, logger)
|
||||
customerAuthService := initAuthorizationService(conf.CustomerAuth.JWT, redisClient, logger)
|
||||
userAuthService := bootstrap.InitAuthorizationService(conf.UserAuth.JWT, redisClient, logger)
|
||||
customerAuthService := bootstrap.InitAuthorizationService(conf.CustomerAuth.JWT, redisClient, logger)
|
||||
|
||||
// Initialize repositories with MongoDB connection manager
|
||||
userRepository := user.NewUserRepository(mongoManager, logger)
|
||||
@@ -145,7 +146,7 @@ func main() {
|
||||
})
|
||||
|
||||
// Initialize HTTP server
|
||||
e := initHTTPServer(conf, logger)
|
||||
e := bootstrap.InitHTTPServer(conf, logger)
|
||||
|
||||
// Register routes
|
||||
router.RegisterAdminRoutes(e, userHandler, companyHandler, customerHandler, tenderHandler, feedbackHandler, tenderApprovalHandler)
|
||||
|
||||
Reference in New Issue
Block a user