From 8b45a9ac1a0f010519d1355cb454ac21df6b9935 Mon Sep 17 00:00:00 2001 From: Anu Viswan Date: Sat, 2 Aug 2025 12:07:40 +0530 Subject: [PATCH 1/6] adding review containers to docker --- server/nt.microservice/docker-compose.yml | 86 ++++++++++++++----- .../nt.orchestrator.AppHost/Program.cs | 4 +- 2 files changed, 67 insertions(+), 23 deletions(-) diff --git a/server/nt.microservice/docker-compose.yml b/server/nt.microservice/docker-compose.yml index 0ca203cf..ad6b69c3 100644 --- a/server/nt.microservice/docker-compose.yml +++ b/server/nt.microservice/docker-compose.yml @@ -43,7 +43,7 @@ services: dockerfile: aggregatorservices/UserIdentityAggregatorService/UserIdentityAggregatorService.Api/Dockerfile environment: - ASPNETCORE_ENVIRONMENT=Development - - ASPNETCORE_URLS=http://+:8080;https://+:8081 + - ASPNETCORE_URLS=http://+:8080;https://+:8079 networks: nt.common.network: depends_on: @@ -52,7 +52,7 @@ services: ports: # - "8000-8099:80" - "8002:8080" - - "8003:8081" + - "8003:8079" ############################################################################################################### @@ -269,10 +269,10 @@ services: # command: ["bash", "-c", "mongod --bind_ip_all & sleep 5 && bash /services/MovieService/MovieService.Data/Seed/init-mongo.sh"] # MovieService: Database Management Tool - mongo-express: + nt.movieservice.db.manager: image: mongo-express - hostname: nt.common.mongoexpress - container_name: nt.common.mongoexpress + hostname: nt.movieservice.db.manager + container_name: nt.movieservice.db.manager restart: always ports: - 8081:8081 @@ -313,6 +313,65 @@ services: - "27018:27017" volumes: - nt.movieservice.db.volume:/data/db + + nt.reviewservice.db.manager: + image: mongo-express + hostname: nt.reviewservice.db.manager + container_name: nt.reviewservice.db.manager + restart: always + ports: + - 8082:8081 + environment: + ME_CONFIG_MONGODB_ADMINUSERNAME: root + ME_CONFIG_MONGODB_ADMINPASSWORD: mypass + # ME_CONFIG_MONGODB_URL: mongodb://root:mypass@nt:27017/ + ME_CONFIG_BASICAUTH: false + ME_CONFIG_MONGODB_SERVER: nt.movieservice.db # MongoDB service name + ME_CONFIG_MONGODB_PORT: 27018 # MongoDB port + networks: + nt.reviewservice.network: + depends_on: + - nt.reviewservice.db + + nt.reviewservice.cache: + image: redis:latest + container_name: nt.reviewservice.cache + hostname: nt.reviewservice.cache + networks: + nt.reviewservice.network: + ports: + - "6379:6379" + command: ["redis-server", "--requirepass", "Password123"] + environment: + - Redis__Host=review-redis + - Redis__Port=6379 + + nt.reviewservice.cache.insight: + image: redis/redisinsight:latest + container_name: redis-insight + ports: + - "8083:8081" + depends_on: + - nt.reviewservice.cache + environment: + - REDIS_HOST=review-redis + - REDIS_PORT=6379 + - REDIS_PASSWORD=Password123 + networks: + nt.reviewservice.network: + + nt.reviewservice.cache.commander: + image: rediscommander/redis-commander:latest + container_name: nt.reviewservice.cache.commander + ports: + - "8084:8081" + environment: + - REDIS_HOSTS=local:review-redis:6379:Password123 + depends_on: + - nt.reviewservice.cache + networks: + nt.reviewservice.network: + ############################################################################################################### # Infrastructure Services @@ -359,6 +418,7 @@ services: - "8080:8000" - "9000:9000" + # # Prometheus # nt.common.prometheus: @@ -385,22 +445,6 @@ services: - ## Mongo Express to manage MongoDb - #nt.common.mongoexpress: - # image: mongo-express - # hostname: nt.common.mongoexpress - # container_name: nt.common.mongoexpress - # restart: always - # environment: - # ME_CONFIG_MONGODB_ADMINUSERNAME: root - # ME_CONFIG_MONGODB_ADMINPASSWORD: admin123 - # ME_CONFIG_MONGODB_URL: mongodb://root:admin123@authServiceLog:27017/ - # networks: - # nt.authservice.network: - # nt.common.network: - # ports: - # - 8081:8081 - nt.common.servicediscovery: image: hashicorp/consul container_name: nt.common.servicediscovery diff --git a/server/nt.microservice/infrastructure/nt.orchestrator.AppHost/Program.cs b/server/nt.microservice/infrastructure/nt.orchestrator.AppHost/Program.cs index d2a7f710..104a8969 100644 --- a/server/nt.microservice/infrastructure/nt.orchestrator.AppHost/Program.cs +++ b/server/nt.microservice/infrastructure/nt.orchestrator.AppHost/Program.cs @@ -71,8 +71,8 @@ .WithEnvironment("Redis__Port", "6379") .WithContainerName(Constants.ReviewService.Cache.ContainerName) .WithHttpEndpoint(port: 8081, targetPort: 8081, isProxied: true) - .WithRedisInsight() - .WithRedisCommander(); + .WithRedisInsight(containerName: "nt-reviewservice-cache-insight") + .WithRedisCommander(containerName:"nt-reviewservice-cache-commander"); var blobStorage = builder.AddContainer("nt-userservice-blobstorage", infrastructureSettings.BlobStorage.DockerImage) .WithVolume("//d/Source/nt/server/nt.microservice/services/UserService/BlobStorage:/data") From 71089f31023bac3904e9db67336c02c41a2b8a3e Mon Sep 17 00:00:00 2001 From: Anu Viswan Date: Sat, 2 Aug 2025 20:44:01 +0530 Subject: [PATCH 2/6] working on docker compose - review service --- .../docker-compose.override.yml | 15 +------ server/nt.microservice/docker-compose.yml | 39 +++++++++++++++++-- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/server/nt.microservice/docker-compose.override.yml b/server/nt.microservice/docker-compose.override.yml index ad85e728..f1bb1868 100644 --- a/server/nt.microservice/docker-compose.override.yml +++ b/server/nt.microservice/docker-compose.override.yml @@ -1,16 +1,5 @@ services: - reviewservice.presenation.api: - environment: - - ASPNETCORE_ENVIRONMENT=Development - - ASPNETCORE_HTTP_PORTS=8080 - - ASPNETCORE_HTTPS_PORTS=8081 - ports: - - "8080" - - "8081" - volumes: - - ${APPDATA}/Microsoft/UserSecrets:/home/app/.microsoft/usersecrets:ro - - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro - - ${APPDATA}/ASP.NET/Https:/home/app/.aspnet/https:ro - - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro + nt.reviewservice.service: + diff --git a/server/nt.microservice/docker-compose.yml b/server/nt.microservice/docker-compose.yml index ad6b69c3..18d50d51 100644 --- a/server/nt.microservice/docker-compose.yml +++ b/server/nt.microservice/docker-compose.yml @@ -26,7 +26,10 @@ services: nt.common.network: depends_on: - "nt.authservice.service" - - "nt.userservice.service" + - "nt.userservice.service" + - "nt.movieservice.service" + - "nt.reviewservice.service" + - "nt.common.servicediscovery" ports: - "8001:80" # - "9001:443" @@ -79,6 +82,7 @@ services: depends_on: - nt.authservice.db - nt.common.rabbitmq + - "nt.common.servicediscovery" #- "nt.authservice.log.db" expose: - "80" @@ -187,6 +191,7 @@ services: depends_on: - "nt.common.rabbitmq" - "nt.userservice.db" + - "nt.common.servicediscovery" volumes: - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro @@ -244,6 +249,7 @@ services: nt.movieservice.network: depends_on: - "nt.movieservice.db" + - "nt.common.servicediscovery" volumes: - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro @@ -293,11 +299,34 @@ services: # Review Service : Responsible for Reviews ############################################################################################################### - reviewservice.presenation.api: + nt.reviewservice.service: image: ${DOCKER_REGISTRY-}reviewservicepresenationapi + hostname: nt.reviewservice.service + container_name: nt.reviewservice.service build: context: . dockerfile: services/ReviewService/ReviewService.Presentation.Api/Dockerfile + networks: + nt.common.network: + nt.reviewservice.network: + depends_on: + - "nt.reviewservice.db" + - "nt.reviewservice.cache" + - "nt.reviewservice.cache.insight" + - "nt.reviewservice.cache.commander" + - "nt.common.servicediscovery" + environment: + - ASPNETCORE_ENVIRONMENT=Development + - ASPNETCORE_HTTP_PORTS=8080 + - ASPNETCORE_HTTPS_PORTS=8081 + ports: + - "8501:8080" + - "8502:8081" + volumes: + - ${APPDATA}/Microsoft/UserSecrets:/home/app/.microsoft/usersecrets:ro + - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro + - ${APPDATA}/ASP.NET/Https:/home/app/.aspnet/https:ro + - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro nt.reviewservice.db: image: mongo:latest @@ -312,7 +341,7 @@ services: ports: - "27018:27017" volumes: - - nt.movieservice.db.volume:/data/db + - nt.reviewservice.db.volume:/data/db nt.reviewservice.db.manager: image: mongo-express @@ -326,7 +355,7 @@ services: ME_CONFIG_MONGODB_ADMINPASSWORD: mypass # ME_CONFIG_MONGODB_URL: mongodb://root:mypass@nt:27017/ ME_CONFIG_BASICAUTH: false - ME_CONFIG_MONGODB_SERVER: nt.movieservice.db # MongoDB service name + ME_CONFIG_MONGODB_SERVER: nt.reviewservice.db # MongoDB service name ME_CONFIG_MONGODB_PORT: 27018 # MongoDB port networks: nt.reviewservice.network: @@ -467,6 +496,8 @@ volumes: name: "nt.authservice.log.db.volume" nt.movieservice.db.volume: name: "nt.movieservice.db.volume" + nt.reviewservice.db.volume: + name: "nt.reviewservice.db.volume" networks: nt.authservice.network: From 8d094c282eecb049b867a34b03f1d1fe34835bda Mon Sep 17 00:00:00 2001 From: Anu Viswan Date: Sat, 2 Aug 2025 21:45:40 +0530 Subject: [PATCH 3/6] fixing services --- .../UserIdentityAggregatorService.Api/Program.cs | 4 ++++ .../UserIdentityAggregatorService.Api/appsettings.json | 2 +- server/nt.microservice/docker-compose.override.yml | 2 -- server/nt.microservice/docker-compose.yml | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/server/nt.microservice/aggregatorservices/UserIdentityAggregatorService/UserIdentityAggregatorService.Api/Program.cs b/server/nt.microservice/aggregatorservices/UserIdentityAggregatorService/UserIdentityAggregatorService.Api/Program.cs index b7bd915a..1c22d2ca 100644 --- a/server/nt.microservice/aggregatorservices/UserIdentityAggregatorService/UserIdentityAggregatorService.Api/Program.cs +++ b/server/nt.microservice/aggregatorservices/UserIdentityAggregatorService/UserIdentityAggregatorService.Api/Program.cs @@ -14,6 +14,10 @@ public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); builder.AddServiceDefaults(); + builder.Configuration + .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) + .AddEnvironmentVariables(); // <- This ensures env vars are considered + var corsPolicy = "_ntClientAppsOrigins"; builder.Services.AddCors(option => { diff --git a/server/nt.microservice/aggregatorservices/UserIdentityAggregatorService/UserIdentityAggregatorService.Api/appsettings.json b/server/nt.microservice/aggregatorservices/UserIdentityAggregatorService/UserIdentityAggregatorService.Api/appsettings.json index 5ce82026..1451cc6c 100644 --- a/server/nt.microservice/aggregatorservices/UserIdentityAggregatorService/UserIdentityAggregatorService.Api/appsettings.json +++ b/server/nt.microservice/aggregatorservices/UserIdentityAggregatorService/UserIdentityAggregatorService.Api/appsettings.json @@ -11,7 +11,7 @@ "serviceId": "useridentityaggregator-1", // Unique service ID for Consul registration "serviceHost": "nt.useridentityaggregator.service", // The address or hostname for Consul to reach the service (can be a Docker container name or IP) "servicePort": 80, // The port that the service is listening on - "healthCheckUrl": "http://nt.useridentityaggregator.service/api/healthcheck/health", // The health check URL to monitor the service's health + "healthCheckUrl": "http://nt.useridentityaggregator.service:80/api/healthcheck/health", // The health check URL to monitor the service's health "registryUri": "http://nt.common.servicediscovery:8500", // Address of the Consul agent (can be changed based on your setup) "deregisterAfterMinutes": 5 // Time to wait before deregistering a service after health check failure }, diff --git a/server/nt.microservice/docker-compose.override.yml b/server/nt.microservice/docker-compose.override.yml index f1bb1868..c0f53d75 100644 --- a/server/nt.microservice/docker-compose.override.yml +++ b/server/nt.microservice/docker-compose.override.yml @@ -1,5 +1,3 @@ -services: - nt.reviewservice.service: diff --git a/server/nt.microservice/docker-compose.yml b/server/nt.microservice/docker-compose.yml index 18d50d51..49e337bd 100644 --- a/server/nt.microservice/docker-compose.yml +++ b/server/nt.microservice/docker-compose.yml @@ -52,6 +52,7 @@ services: depends_on: - "nt.authservice.service" - "nt.userservice.service" + - "nt.common.servicediscovery" ports: # - "8000-8099:80" - "8002:8080" From 86f4cbd508666f767ef0051c2e4b3b89c8c8194f Mon Sep 17 00:00:00 2001 From: Anu Viswan Date: Sun, 3 Aug 2025 17:36:33 +0530 Subject: [PATCH 4/6] Fixed connection string --- server/nt.microservice/docker-compose.yml | 5 +++-- .../ReviewService.Presentation.Api/appsettings.json | 11 ++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/server/nt.microservice/docker-compose.yml b/server/nt.microservice/docker-compose.yml index 49e337bd..0354096a 100644 --- a/server/nt.microservice/docker-compose.yml +++ b/server/nt.microservice/docker-compose.yml @@ -272,7 +272,7 @@ services: ports: - "27017:27017" volumes: - - nt.movieservice.db.volume:/data/db + - nt.movieservice.db.volume:/data/db # command: ["bash", "-c", "mongod --bind_ip_all & sleep 5 && bash /services/MovieService/MovieService.Data/Seed/init-mongo.sh"] # MovieService: Database Management Tool @@ -339,10 +339,11 @@ services: MONGO_INITDB_ROOT_PASSWORD: mypass networks: nt.reviewservice.network: + nt.common.network: ports: - "27018:27017" volumes: - - nt.reviewservice.db.volume:/data/db + - nt.reviewservice.db.volume:/data/db nt.reviewservice.db.manager: image: mongo-express diff --git a/server/nt.microservice/services/ReviewService/ReviewService.Presentation.Api/appsettings.json b/server/nt.microservice/services/ReviewService/ReviewService.Presentation.Api/appsettings.json index 454469a6..8dbaced8 100644 --- a/server/nt.microservice/services/ReviewService/ReviewService.Presentation.Api/appsettings.json +++ b/server/nt.microservice/services/ReviewService/ReviewService.Presentation.Api/appsettings.json @@ -8,7 +8,7 @@ "AllowedHosts": "*", "DatabaseOptions": { //"ConnectionString": "mongodb://root:mypass@nt.movieservice.db:27017", - "ConnectionString": "mongodb://root:mypass@nt.reviewservice.db:27018/?authSource=admin", + "ConnectionString": "mongodb://root:mypass@nt.reviewservice.db:27017/?authSource=admin", "DatabaseName": "ntreviewstore", "ReviewCollectionName": "reviews" }, @@ -17,5 +17,14 @@ "InstanceName": "nt-reviewservice-cache", "ExpirationInMinutes": 60, "EnableCaching": true + }, + "ServiceRegistrationConfig": { + "serviceName": "nt.reviewservice.service", // The name under which the service will be registered in Consul + "serviceId": "reviewservice-1", // Unique service ID for Consul registration + "serviceAddress": "nt.reviewservice.service", // The address or hostname for Consul to reach the service (can be a Docker container name or IP) + "servicePort": 80, // The port that the service is listening on + "healthCheckUrl": "http://nt.reviewservice.service:80/api/healthcheck/health", // The health check URL to monitor the service's health + "registryUri": "http://nt.common.servicediscovery:8500", // Address of the Consul agent (can be changed based on your setup) + "deregisterAfterMinutes": 5 // Time to wait before deregistering a service after health check failure } } From 25ba57de77a14502073acf4e89d8356944fa2d00 Mon Sep 17 00:00:00 2001 From: Anu Viswan Date: Sun, 3 Aug 2025 19:08:53 +0530 Subject: [PATCH 5/6] temp fixes for docker compose --- server/nt.microservice/docker-compose.yml | 35 +++++++++---------- .../infrastructure/nt.gateway/ocelot.json | 2 +- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/server/nt.microservice/docker-compose.yml b/server/nt.microservice/docker-compose.yml index 0354096a..62a2cf3f 100644 --- a/server/nt.microservice/docker-compose.yml +++ b/server/nt.microservice/docker-compose.yml @@ -46,7 +46,7 @@ services: dockerfile: aggregatorservices/UserIdentityAggregatorService/UserIdentityAggregatorService.Api/Dockerfile environment: - ASPNETCORE_ENVIRONMENT=Development - - ASPNETCORE_URLS=http://+:8080;https://+:8079 + - ASPNETCORE_URLS=http://+:80;https://+:8079 networks: nt.common.network: depends_on: @@ -55,7 +55,7 @@ services: - "nt.common.servicediscovery" ports: # - "8000-8099:80" - - "8002:8080" + - "8002:80" - "8003:8079" @@ -314,14 +314,13 @@ services: - "nt.reviewservice.db" - "nt.reviewservice.cache" - "nt.reviewservice.cache.insight" - - "nt.reviewservice.cache.commander" - "nt.common.servicediscovery" environment: - ASPNETCORE_ENVIRONMENT=Development - - ASPNETCORE_HTTP_PORTS=8080 + - ASPNETCORE_HTTP_PORTS=80 - ASPNETCORE_HTTPS_PORTS=8081 ports: - - "8501:8080" + - "8501:80" - "8502:8081" volumes: - ${APPDATA}/Microsoft/UserSecrets:/home/app/.microsoft/usersecrets:ro @@ -379,29 +378,29 @@ services: nt.reviewservice.cache.insight: image: redis/redisinsight:latest - container_name: redis-insight + container_name: nt.reviewservice.insight ports: - "8083:8081" depends_on: - nt.reviewservice.cache environment: - - REDIS_HOST=review-redis + - REDIS_HOST=nt.reviewservice.cache - REDIS_PORT=6379 - REDIS_PASSWORD=Password123 networks: nt.reviewservice.network: - nt.reviewservice.cache.commander: - image: rediscommander/redis-commander:latest - container_name: nt.reviewservice.cache.commander - ports: - - "8084:8081" - environment: - - REDIS_HOSTS=local:review-redis:6379:Password123 - depends_on: - - nt.reviewservice.cache - networks: - nt.reviewservice.network: + # nt.reviewservice.cache.commander: + # image: rediscommander/redis-commander:latest + # container_name: nt.reviewservice.cache.commander + # ports: + # - "8084:8081" + # environment: + # - "REDIS_HOSTS=local:nt.reviewservice.cache:6379:Password123:0" + # depends_on: + # - nt.reviewservice.cache + # networks: + # nt.reviewservice.network: ############################################################################################################### diff --git a/server/nt.microservice/infrastructure/nt.gateway/ocelot.json b/server/nt.microservice/infrastructure/nt.gateway/ocelot.json index e7643aec..30c4f964 100644 --- a/server/nt.microservice/infrastructure/nt.gateway/ocelot.json +++ b/server/nt.microservice/infrastructure/nt.gateway/ocelot.json @@ -256,7 +256,7 @@ "BaseUrl": "http://localhost:8001", "ServiceDiscoveryProvider": { "Scheme": "http", - "Host": "localhost", + "Host": "host.docker.internal", "Port": 9500, "Type": "Consul" } From 974e086d2ee86ca655e4eed5c189566877e5f947 Mon Sep 17 00:00:00 2001 From: Anu Viswan Date: Sun, 3 Aug 2025 19:46:30 +0530 Subject: [PATCH 6/6] temp fix for aspire --- server/nt.microservice/infrastructure/nt.gateway/ocelot.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/nt.microservice/infrastructure/nt.gateway/ocelot.json b/server/nt.microservice/infrastructure/nt.gateway/ocelot.json index 30c4f964..e7643aec 100644 --- a/server/nt.microservice/infrastructure/nt.gateway/ocelot.json +++ b/server/nt.microservice/infrastructure/nt.gateway/ocelot.json @@ -256,7 +256,7 @@ "BaseUrl": "http://localhost:8001", "ServiceDiscoveryProvider": { "Scheme": "http", - "Host": "host.docker.internal", + "Host": "localhost", "Port": 9500, "Type": "Consul" }