From f2a867aff4673e42172f0fbba5ef8f3dbeff00f9 Mon Sep 17 00:00:00 2001 From: Bruno Brito Date: Thu, 12 Jan 2023 23:11:12 -0300 Subject: [PATCH] feat: status page (#26) * fix: remove smalltalk * fix: smalltalk try 2 * Update .gitattributes * fix: removing smalltalk * fix: copy hook * feat: disable https redirection * fix: connection error * feat: status page, ssl changes * fix: remove crt --- DevStore.sln | Bin 25204 -> 13258 bytes docker/docker-compose-local-light.yml | 62 ++++++++----- docker/docker-compose-local.yml | 62 +++++++++---- docker/docker-compose.yml | 28 +++--- docker/nginx/devstore.conf | 43 ++++++++- .../Configuration/ApiConfig.cs | Bin 3758 -> 6000 bytes .../DevStore.Bff.Checkout.csproj | Bin 3030 -> 3188 bytes .../Services/OrderService.cs | Bin 4766 -> 4772 bytes .../appsettings.Docker.json | 12 +-- .../appsettings.Production.json | 12 +-- .../Properties/launchSettings.json | 12 +++ .../DevStore.MessageBus/MessageBus.cs | Bin 7118 -> 7258 bytes .../Configuration/DbHealthChecker.cs | 3 - .../EasyNetQRabbitHealthCheck.cs | 53 +++++++++++ .../Configuration/GenericHealthCheck.cs | 82 ++++++++++++++++-- .../DatabaseFlavor/DatabaseType.cs | 1 + .../DatabaseFlavor/ProviderConfiguration.cs | 19 ++-- .../DatabaseFlavor/ProviderSelector.cs | 18 ++-- .../DevStore.WebAPI.Core.csproj | Bin 2284 -> 3522 bytes .../Extensions/HttpExtensions.cs | Bin 1482 -> 3836 bytes .../Identity/JwtConfig.cs | Bin 3264 -> 3234 bytes .../Configuration/ApiConfig.cs | Bin 4292 -> 4298 bytes .../DevStore.Billing.API.csproj | Bin 3332 -> 2472 bytes .../appsettings.Docker.json | 2 +- .../appsettings.Production.json | 2 +- .../Properties/launchSettings.json | 12 +++ .../Configuration/ApiConfig.cs | Bin 4034 -> 4040 bytes .../DevStore.Catalog.API.csproj | Bin 3126 -> 2238 bytes .../appsettings.Docker.json | 2 +- .../appsettings.Production.json | 2 +- .../Configuration/ApiConfig.cs | Bin 4048 -> 4054 bytes .../DevStore.Customers.API.csproj | Bin 3574 -> 2686 bytes .../appsettings.Development.json | 2 +- .../appsettings.Docker.json | 2 +- .../appsettings.Production.json | 2 +- .../Configuration/ApiConfig.cs | Bin 2988 -> 3104 bytes .../DevStore.Identity.API.csproj | Bin 3548 -> 2662 bytes src/services/DevStore.Identity.API/Program.cs | Bin 1584 -> 1626 bytes .../appsettings.Development.json | 2 +- .../Configuration/ApiConfig.cs | Bin 4042 -> 4044 bytes .../Controllers/OrderController.cs | Bin 3286 -> 3510 bytes .../Controllers/VoucherController.cs | Bin 2138 -> 2142 bytes .../appsettings.Docker.json | 2 +- .../appsettings.Production.json | 2 +- .../Properties/launchSettings.json | 12 +++ .../Configuration/ApiConfig.cs | 4 +- .../DevStore.ShoppingCart.API.csproj | 7 -- .../appsettings.Docker.json | 2 +- .../appsettings.Production.json | 2 +- .../appsettings.json | 3 +- .../Configuration/WebAppConfig.cs | Bin 4030 -> 4146 bytes .../Properties/launchSettings.json | 8 -- .../appsettings.Docker.json | 8 +- .../appsettings.Production.json | 8 +- src/web/DevStore.WebApp.MVC/appsettings.json | 3 +- .../DevStore.WebApp.Status.csproj | 51 +++++++++++ src/web/DevStore.WebApp.Status/Dockerfile | 24 +++++ .../Dockerfile.original | 22 +++++ src/web/DevStore.WebApp.Status/Program.cs | 67 ++++++++++++++ .../Properties/launchSettings.json | 14 +++ .../appsettings.Development.json | 43 +++++++++ .../appsettings.Docker.json | 32 +++++++ .../appsettings.Production.json | 32 +++++++ .../DevStore.WebApp.Status/appsettings.json | 6 ++ src/web/DevStore.WebApp.Status/devstore.css | 8 ++ 65 files changed, 669 insertions(+), 126 deletions(-) create mode 100644 src/building-blocks/DevStore.Core/Properties/launchSettings.json create mode 100644 src/building-blocks/DevStore.WebAPI.Core/Configuration/EasyNetQRabbitHealthCheck.cs create mode 100644 src/services/DevStore.Billing.DevsPay/Properties/launchSettings.json create mode 100644 src/services/DevStore.Orders.Domain/Properties/launchSettings.json create mode 100644 src/web/DevStore.WebApp.Status/DevStore.WebApp.Status.csproj create mode 100644 src/web/DevStore.WebApp.Status/Dockerfile create mode 100644 src/web/DevStore.WebApp.Status/Dockerfile.original create mode 100644 src/web/DevStore.WebApp.Status/Program.cs create mode 100644 src/web/DevStore.WebApp.Status/Properties/launchSettings.json create mode 100644 src/web/DevStore.WebApp.Status/appsettings.Development.json create mode 100644 src/web/DevStore.WebApp.Status/appsettings.Docker.json create mode 100644 src/web/DevStore.WebApp.Status/appsettings.Production.json create mode 100644 src/web/DevStore.WebApp.Status/appsettings.json create mode 100644 src/web/DevStore.WebApp.Status/devstore.css diff --git a/DevStore.sln b/DevStore.sln index 152cd3498490d654b3a651fb7a50bc261db6b5d6..8f21fab5e79d7c6f2ac78c7b0db878b45cbe8865 100644 GIT binary patch literal 13258 zcmcIr%W@mJ6t;)yD%Og6Kjq?XJKEvoqNjEnJ?Wsy(H zFXW<02~Cg`(LGGL$|OPf+;dOkaqs2zfB*fTi;t7L`D`(JSYG}-S**s>%bVruelokf znN3&A$?WMeOs38Emti*lJcc>Vd=UppHNyDfPuahD{Z?FTz&2Pf!#`XSF~TEC>WYji zj=}cR5**}}R<#$)>iqzOsN|6lCB35aN6cY>)O;ybu(3%jTRV@{&YAz8IoFnOYKwQ_J1ng_esxz>;Y35%hcTG#9`+n`X z_S#vDu(K6nCJ>}3t`VagR0$S)&(C20AI)u4VEY1ID;vD#NHZ!BV@@Mg5sJK*Mhd2= z6!Z*MKioG@%gORVx+G>L>c0aU2G5Tv_*HO9U1O!-a5eZG1?*QHJt0# z1!RN~NX4Vh*H|0%f4yNiRuzLkuv;|Ta70PCZ(#?;HHB-nZouAO4v`$-LJD%dz5wGuY-?!$SWjOtzawR0QWCkeQ?oJMSKv} zAB}tlE$Gc5c49fFNu9-<2D?ky)>e9_6(T~wjueC-V>LmZa&M$$QsJXv!w?6$7s1+$|6%9=%|OIM7}&C(igZC(%!1UG_?u3hrTyJcsOuVfafsDUs$CT#Q}`C6Asd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*3nB#`pR-^u9scXn!~fqU(!pv zwJq)GWmh!jaIB-3mh_e7)?6>Uq&0_UnZKl$cI$iE)61@C%;8u^FD>aS%dNRyc1ddv z&oX~OFPpD;I$R$XcFX!nYlhfI+yAJG6s{K;+4_o|3>&Yk&t9!_C{8@FjH*43L zbMTF)k(GakyMNWC+;Xq2z@_ExX2}BC?S|DRm8|_`kC5hjShY!|-7Zs+N;~N!iQDZB z6{)n7PNI_Uv-lFC`CdwqN;|$2m8?g%+5IR|36?fH^d&0o_9Kc^wxO4BZnJApn^fBE z>(e%sHoNb%NhMljvsX@=RNAd+j8xj`Q0n7$JG?|H+pt8;liKXP(k7LB55`v$&38nJ zRNC!Jni&WbA+}?{_1Wc9B7% z(k=@eskDo-5|ws2!APZDWDuxqo=@Ale=75LsV_PCzY(76U>{NT?%w}$azD3L{^Id4 zANa_BqxSM9AGp&uue~kTX-oZajQ9%N|sm&Gp?P-ioi!`M#f?626~hPnhtv Me|-c#M~P?u5A9t|SpWb4 diff --git a/docker/docker-compose-local-light.yml b/docker/docker-compose-local-light.yml index a691a1f..352dff9 100644 --- a/docker/docker-compose-local-light.yml +++ b/docker/docker-compose-local-light.yml @@ -10,13 +10,15 @@ services: dockerfile: ./web/DevStore.WebApp.MVC/Dockerfile restart: always environment: - - ASPNETCORE_ENVIRONMENT=Docker - - ASPNETCORE_URLS=http://*:5001 - - LC_ALL=en_US.UTF-8 - - LANG=en_US.UTF-8 + ASPNETCORE_ENVIRONMENT: Docker + ASPNETCORE_URLS: "https://+:443;http://+:80" + ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe + ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx + LC_ALL: "en_US.UTF-8" + LANG: "en_US.UTF-8" # Change the two lines above to your culture (ex pt_BR) volumes: - - dpkeys:/var/data_protection_keys/ + - ./certs:/https:ro depends_on: - api-catalog - api-identity @@ -28,7 +30,9 @@ services: image: rabbitmq:3-management container_name: devstore-rabbit expose: + ports: - 5672 + - 15672 environment: RABBITMQ_DEFAULT_USER: "devstore" RABBITMQ_DEFAULT_PASS: "devstore" @@ -45,14 +49,14 @@ services: api-identity: image: desenvolvedorio/devstore-api-identity:latest - container_name: devstore-api-identity + container_name: devstore-api-identity build: context: ../src dockerfile: ./services/DevStore.Identity.API/Dockerfile restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5101;http://+5102 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx CUSTOMCONNSTR_DefaultConnection: "Server=database-devstore;Database=DSUsers;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" @@ -73,7 +77,7 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5201;http://+5202 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx CUSTOMCONNSTR_DefaultConnection: "Server=database-devstore;Database=DSShoppingCart;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" @@ -95,7 +99,7 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5301;http://+5302 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx CUSTOMCONNSTR_DefaultConnection: "Server=database-devstore;Database=DSCatalog;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" @@ -116,7 +120,7 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5401;http://+5402 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx CUSTOMCONNSTR_DefaultConnection: "Server=database-devstore;Database=DSCustomers;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" @@ -138,7 +142,7 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5501;http://+5502 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx volumes: @@ -160,7 +164,7 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5601;http://+5602 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx CUSTOMCONNSTR_DefaultConnection: "Server=database-devstore;Database=DSBilling;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" @@ -183,7 +187,7 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5701;http://+5702 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx CUSTOMCONNSTR_DefaultConnection: "Server=database-devstore;Database=DSOrders;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" @@ -196,6 +200,27 @@ services: - api-identity - generate-pfx + web-status: + image: desenvolvedorio/devstore-web-status:latest + container_name: devstore-web-status + build: + context: ../src + dockerfile: ./web/DevStore.WebApp.Status/Dockerfile + restart: always + environment: + ASPNETCORE_ENVIRONMENT: Docker + ASPNETCORE_URLS: https://+:443;http://+:80 + CUSTOMCONNSTR_DefaultConnection: "Server=database-devstore;Database=DSStatus;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" + ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe + ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx + AppSettings__DatabaseType: SqlServer + USE_HTTPS_REDIRECTION: "false" + volumes: + - ./certs:/https:ro + depends_on: + - database-devstore + + generate-pfx: image: emberstack/openssl container_name: generate-pfx @@ -207,13 +232,10 @@ services: openssl genrsa -out devstore.rsa 2048 && openssl req -sha256 -new -key devstore.rsa -out devstore.csr -subj '/CN=localhost' && openssl x509 -req -sha256 -days 365 -in devstore.csr -signkey devstore.rsa -out devstore.crt && - openssl pkcs12 -export -out /https/devstore.academy-localhost.pfx -inkey devstore.rsa -in devstore.crt -password pass:9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe && - rm devstore.rsa devstore.csr devstore.crt)" + openssl pkcs12 -export -out /https/devstore.academy-localhost.pfx -inkey devstore.rsa -in devstore.crt -password pass:9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe)" seq: image: datalust/seq:latest - expose: - - 5341 ports: - 5341:80 environment: @@ -230,9 +252,9 @@ services: ports: - "7500:80" - "7501:443" + - "7510:8080" + - "7511:4443" depends_on: - web-mvc -volumes: - dpkeys: - + diff --git a/docker/docker-compose-local.yml b/docker/docker-compose-local.yml index 070674b..23fef49 100644 --- a/docker/docker-compose-local.yml +++ b/docker/docker-compose-local.yml @@ -10,13 +10,15 @@ services: dockerfile: ./web/DevStore.WebApp.MVC/Dockerfile restart: always environment: - - ASPNETCORE_ENVIRONMENT=Docker - - ASPNETCORE_URLS=http://*:5001 - - LC_ALL=en_US.UTF-8 - - LANG=en_US.UTF-8 + ASPNETCORE_ENVIRONMENT: Docker + ASPNETCORE_URLS: "https://+:443;http://+:80" + ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe + ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx + LC_ALL: "en_US.UTF-8" + LANG: "en_US.UTF-8" # Change the two lines above to your culture (ex pt_BR) volumes: - - dpkeys:/var/data_protection_keys/ + - ./certs:/https:ro depends_on: - api-catalog - api-identity @@ -53,7 +55,7 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5101;http://+5102 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx CUSTOMCONNSTR_DefaultConnection: "Server=database-identity;Database=DSUsers;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" @@ -83,7 +85,7 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5201;http://+5202 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx CUSTOMCONNSTR_DefaultConnection: "Server=database-cart;Database=DSShoppingCart;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" @@ -114,7 +116,7 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5301;http://+5302 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx CUSTOMCONNSTR_DefaultConnection: "Server=database-catalog;Database=DSCatalog;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" @@ -144,7 +146,7 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5401;http://+5402 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx CUSTOMCONNSTR_DefaultConnection: "Server=database-customers;Database=DSCustomers;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" @@ -166,7 +168,7 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5501;http://+5502 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx volumes: @@ -198,11 +200,11 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5601;http://+5602 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx CUSTOMCONNSTR_DefaultConnection: "Server=database-billing;Port=5432;Database=DSBilling;User Id=sa;Password=MyDB@123" - AppSettings__DatabaseType: Postgre + AppSettings__DatabaseType: SqlServer volumes: - ./certs:/https:ro depends_on: @@ -230,7 +232,7 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5701;http://+5702 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx CUSTOMCONNSTR_DefaultConnection: "Server=database-order;Database=DSOrders;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" @@ -252,6 +254,38 @@ services: environment: ACCEPT_EULA: "Y" + + database-status: + image: mcr.microsoft.com/mssql/server:2017-latest + container_name: devstore-database-status + expose: + - 1433 + environment: + SA_PASSWORD: "MyDB@123" + ACCEPT_EULA: "Y" + + + web-status: + image: desenvolvedorio/devstore-web-status:latest + container_name: devstore-web-status + build: + context: ../src + dockerfile: ./web/DevStore.WebApp.Status/Dockerfile + restart: always + environment: + ASPNETCORE_ENVIRONMENT: Docker + ASPNETCORE_URLS: https://+:443;http://+:80 + CUSTOMCONNSTR_DefaultConnection: "Server=database-status;Database=DSOrders;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" + ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe + ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx + AppSettings__DatabaseType: SqlServer + USE_HTTPS_REDIRECTION: "false" + volumes: + - ./certs:/https:ro + - ./certs/devstore.crt:/usr/local/share/ca-certificates/devstore.crt + depends_on: + - database-status + # This service is used to generate the PFX file for gRPC communication generate-pfx: image: emberstack/openssl @@ -280,6 +314,4 @@ services: depends_on: - web-mvc -volumes: - dpkeys: diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 90b8aeb..d165cab 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -30,10 +30,12 @@ services: container_name: devstore-web-mvc-ecommerce restart: always environment: - - ASPNETCORE_ENVIRONMENT=Docker - - ASPNETCORE_URLS=http://*:5001 - - LC_ALL=en_US.UTF-8 - - LANG=en_US.UTF-8 + ASPNETCORE_ENVIRONMENT: Docker + ASPNETCORE_URLS: "https://+:443;http://+:80" + ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe + ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx + LC_ALL: "en_US.UTF-8" + LANG: "en_US.UTF-8" # Change the two lines above to your culture (ex pt_BR) volumes: - dpkeys:/var/data_protection_keys/ @@ -59,7 +61,7 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5101;http://+5102 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx CUSTOMCONNSTR_DefaultConnection: "Server=database-identity;Database=DSUsers;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" @@ -86,7 +88,7 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5201;http://+5202 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx CUSTOMCONNSTR_DefaultConnection: "Server=database-cart;Database=DSShoppingCart;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" @@ -114,7 +116,7 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5301;http://+5302 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx CUSTOMCONNSTR_DefaultConnection: "Server=database-catalog;Database=DSCatalog;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" @@ -141,7 +143,7 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5401;http://+5402 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx CUSTOMCONNSTR_DefaultConnection: "Server=database-customers;Database=DSCustomers;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" @@ -160,7 +162,7 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5501;http://+5502 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx volumes: @@ -188,7 +190,7 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5601;http://+5602 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx CUSTOMCONNSTR_DefaultConnection: "Server=database-billing;Database=DSBilling;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" @@ -217,7 +219,7 @@ services: restart: always environment: ASPNETCORE_ENVIRONMENT: Docker - ASPNETCORE_URLS: https://+:5701;http://+5702 + ASPNETCORE_URLS: https://+:443;http://+:80 ASPNETCORE_Kestrel__Certificates__Default__Password: 9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe ASPNETCORE_Kestrel__Certificates__Default__Path: /https/devstore.academy-localhost.pfx CUSTOMCONNSTR_DefaultConnection: "Server=database-order;Database=DSOrders;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" @@ -232,8 +234,6 @@ services: seq: image: datalust/seq:latest - expose: - - 5341 ports: - 5341:80 environment: @@ -249,6 +249,8 @@ services: ports: - "7500:80" - "7501:443" + - "7510:8080" + - "7511:4443" depends_on: - web-mvc diff --git a/docker/nginx/devstore.conf b/docker/nginx/devstore.conf index 749de3e..dff369e 100644 --- a/docker/nginx/devstore.conf +++ b/docker/nginx/devstore.conf @@ -1,12 +1,18 @@ upstream web-mvc { - server web-mvc:5001; + server web-mvc; +} +upstream web-status { + server web-status; } server { listen 80; - server_name localhost; + server_name $hostname; + location /status { + rewrite ^/status(.*)$ http://localhost:7510/status$1 redirect; + } location / { proxy_pass http://web-mvc; } @@ -16,6 +22,15 @@ server { # } } +server { + listen 8080; + server_name $hostname; + + location / { + proxy_pass http://web-status; + } +} + server { listen 443 ssl; server_name $hostname; @@ -24,6 +39,9 @@ server { ssl_ciphers HIGH:!aNULL:!MD5; ssl_certificate /etc/nginx/nerdstore-certificate.pem; ssl_certificate_key /etc/nginx/nerdstore-certificate.key; + location /status { + rewrite ^/status(.*)$ https://localhost:7511/status$1 redirect; + } location / { proxy_pass http://web-mvc; proxy_redirect off; @@ -35,4 +53,25 @@ server { proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Host $server_name; } +} + +server { + listen 4443 ssl; + server_name $hostname; + + ssl_protocols TLSv1.2 TLSv1.3; + ssl_ciphers HIGH:!aNULL:!MD5; + ssl_certificate /etc/nginx/nerdstore-certificate.pem; + ssl_certificate_key /etc/nginx/nerdstore-certificate.key; + location / { + proxy_pass http://web-status; + proxy_redirect off; + proxy_http_version 1.1; + proxy_set_header Connection keep-alive; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Host $server_name; + } } \ No newline at end of file diff --git a/src/api-gateways/DevStore.Bff.Checkout/Configuration/ApiConfig.cs b/src/api-gateways/DevStore.Bff.Checkout/Configuration/ApiConfig.cs index 3a9b5182b2b94c3f576438d01b75126642901301..49b30e3e95d1569e07f5b2f32faa5e4c825e1c0f 100644 GIT binary patch literal 6000 zcmeHLT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#h_Zql9!;=F<5Z5Z6atd{fZ&`!y;>RkSa{_Y0s=mz1rWfNzqs3-b31}4A zd=?>P*goc&vyj>CDG1b*&IkN1-J*4QUiP3H?dIl9ZdT*(2;R|$Er|BC35~BSW~<`< Tvzh8YO>VQHt^T>AcN6&w>UEp9 delta 129 zcmeyMw@!9L57TBpW;xc$9AYw)b6ABG9T`%9(48TbArFX)7%~}>89acjM1~xO5{3*0 t=gH>cnv;)-ifrZ)6kxN&qY$V#6{tCzL4!ewK_AS68B)cdG}%#H9{{f$8}k4F diff --git a/src/api-gateways/DevStore.Bff.Checkout/DevStore.Bff.Checkout.csproj b/src/api-gateways/DevStore.Bff.Checkout/DevStore.Bff.Checkout.csproj index 74634dd338a90711ccacd058bc79b62bef0ebbd3..906e0c0238251a53a6ae184a4903f8ab0074c367 100644 GIT binary patch delta 84 zcmca6{zYPg1hc6lLoq`EgC9dGLkWX3Lq00NMY}H`+Lmm;pnR@d720SR9d-V3AT1vDhdUlbi<_lVS%Pvm6()1U8cnc>n+a delta 23 fcmca*an5|gjEQ&RHfJ$%iA^?>w%UA5d rabbitHealthCheck); + + return healthChecksBuilder.Add(new HealthCheckRegistration( + "RabbitMQ", + sp => sp.GetRequiredService(), + default, + tags: new[] { "infra" }, + default)); + } + + private static IConnectionFactory CreateConnectionFactory(ConnectionConfiguration configuration) + { + var connectionFactory = new ConnectionFactory + { + AutomaticRecoveryEnabled = true, + TopologyRecoveryEnabled = false, + VirtualHost = configuration.VirtualHost, + UserName = configuration.UserName, + Password = configuration.Password, + Port = configuration.Port, + RequestedHeartbeat = configuration.RequestedHeartbeat, + ClientProperties = configuration.ClientProperties, + AuthMechanisms = configuration.AuthMechanisms, + ClientProvidedName = configuration.Name, + NetworkRecoveryInterval = configuration.ConnectIntervalAttempt, + ContinuationTimeout = configuration.Timeout, + DispatchConsumersAsync = true, + ConsumerDispatchConcurrency = configuration.PrefetchCount, + }; + + if (configuration.Hosts.Count > 0) + connectionFactory.HostName = configuration.Hosts[0].Host; + + return connectionFactory; + } +} \ No newline at end of file diff --git a/src/building-blocks/DevStore.WebAPI.Core/Configuration/GenericHealthCheck.cs b/src/building-blocks/DevStore.WebAPI.Core/Configuration/GenericHealthCheck.cs index f4ff9fe..f565b6d 100644 --- a/src/building-blocks/DevStore.WebAPI.Core/Configuration/GenericHealthCheck.cs +++ b/src/building-blocks/DevStore.WebAPI.Core/Configuration/GenericHealthCheck.cs @@ -1,18 +1,90 @@ -using Microsoft.AspNetCore.Builder; +using DevStore.Core.Utils; +using DevStore.WebAPI.Core.DatabaseFlavor; +using EasyNetQ; +using EasyNetQ.ConnectionString; +using HealthChecks.RabbitMQ; +using HealthChecks.UI.Client; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Diagnostics.HealthChecks; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Diagnostics.HealthChecks; +using NetDevPack.Utilities; +using RabbitMQ.Client; +using static DevStore.WebAPI.Core.DatabaseFlavor.ProviderConfiguration; namespace DevStore.WebAPI.Core.Configuration { public static class GenericHealthCheck { - public static void AddGenericHealthCheck(this IServiceCollection services) + + public static IHealthChecksBuilder AddDefaultHealthCheck( + this IServiceCollection services, + IConfiguration configuration) { - services.AddHealthChecks(); + var (database, connString) = DetectDatabase(configuration); + var checkBuilder = services + .AddHealthChecks() + .AddCheck("self", () => HealthCheckResult.Healthy(), tags: new[] { "api" }); + + var rabbitConnStr = configuration.GetMessageQueueConnection("MessageBus"); + + // We need to parse EasyNetQ Connection String to RabbitMQ native connectionstring + // before send it to Health check + if (rabbitConnStr.IsPresent()) + checkBuilder.AddEasyNetQRabbitHealthCheck(rabbitConnStr); + + + return database switch + { + DatabaseType.SqlServer => checkBuilder.AddSqlServer(connString, name: "SqlServer", tags: new[] { "infra" }), + DatabaseType.MySql => checkBuilder.AddMySql(connString, name: "MySql", tags: new[] { "infra" }), + DatabaseType.Postgre => checkBuilder.AddNpgSql(connString, name: "Postgre", tags: new[] { "infra" }), + DatabaseType.Sqlite => checkBuilder.AddSqlite(connString, name: "Sqlite", tags: new[] { "infra" }), + _ => checkBuilder + }; } - public static void UseGenericHealthCheck(this WebApplication app, string path) + private static IConnectionFactory CreateConnectionFactory(ConnectionConfiguration configuration) { - app.MapHealthChecks(path); + var connectionFactory = new ConnectionFactory + { + AutomaticRecoveryEnabled = true, + TopologyRecoveryEnabled = false, + VirtualHost = configuration.VirtualHost, + UserName = configuration.UserName, + Password = configuration.Password, + Port = configuration.Port, + RequestedHeartbeat = configuration.RequestedHeartbeat, + ClientProperties = configuration.ClientProperties, + AuthMechanisms = configuration.AuthMechanisms, + ClientProvidedName = configuration.Name, + NetworkRecoveryInterval = configuration.ConnectIntervalAttempt, + ContinuationTimeout = configuration.Timeout, + DispatchConsumersAsync = true, + ConsumerDispatchConcurrency = configuration.PrefetchCount, + }; + + if (configuration.Hosts.Count > 0) + connectionFactory.HostName = configuration.Hosts[0].Host; + + return connectionFactory; + } + + public static IApplicationBuilder UseDefaultHealthcheck(this IApplicationBuilder app) + { + app.UseHealthChecks("/healthz", new HealthCheckOptions + { + Predicate = r => r.Tags.Contains("api"), + ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse + }); + app.UseHealthChecks("/healthz-infra", new HealthCheckOptions + { + Predicate = r => r.Tags.Contains("infra"), + ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse + }); + + return app; } } } diff --git a/src/building-blocks/DevStore.WebAPI.Core/DatabaseFlavor/DatabaseType.cs b/src/building-blocks/DevStore.WebAPI.Core/DatabaseFlavor/DatabaseType.cs index 50b674e..fc1cabd 100644 --- a/src/building-blocks/DevStore.WebAPI.Core/DatabaseFlavor/DatabaseType.cs +++ b/src/building-blocks/DevStore.WebAPI.Core/DatabaseFlavor/DatabaseType.cs @@ -2,6 +2,7 @@ public enum DatabaseType { + None, SqlServer, MySql, Postgre, diff --git a/src/building-blocks/DevStore.WebAPI.Core/DatabaseFlavor/ProviderConfiguration.cs b/src/building-blocks/DevStore.WebAPI.Core/DatabaseFlavor/ProviderConfiguration.cs index eab8b2d..0ef1f22 100644 --- a/src/building-blocks/DevStore.WebAPI.Core/DatabaseFlavor/ProviderConfiguration.cs +++ b/src/building-blocks/DevStore.WebAPI.Core/DatabaseFlavor/ProviderConfiguration.cs @@ -9,16 +9,20 @@ namespace DevStore.WebAPI.Core.DatabaseFlavor; public class ProviderConfiguration { private readonly string _connectionString; - public static ProviderConfiguration With; + public ProviderConfiguration With() => this; private static readonly string MigrationAssembly = typeof(ProviderConfiguration).GetTypeInfo().Assembly.GetName().Name; - public static void Build(string connString) + public static ProviderConfiguration Build(string connString) { - if (With is null) - With = new ProviderConfiguration(connString); + return new ProviderConfiguration(connString); } - public ProviderConfiguration(string connString) => _connectionString = connString; + + + public ProviderConfiguration(string connString) + { + _connectionString = connString; + } public Action SqlServer => options => options.UseSqlServer(_connectionString, sql => sql.MigrationsAssembly(MigrationAssembly)); @@ -27,7 +31,8 @@ public static void Build(string connString) options => options.UseMySql(_connectionString, ServerVersion.AutoDetect(_connectionString), sql => sql.MigrationsAssembly(MigrationAssembly)); public Action Postgre => - options => { + options => + { options.UseNpgsql(_connectionString, sql => sql.MigrationsAssembly(MigrationAssembly)); AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); }; @@ -41,6 +46,6 @@ public static void Build(string connString) /// Trying to improve readability at ConfigureServices /// public static (DatabaseType, string) DetectDatabase(IConfiguration configuration) => ( - configuration.GetValue("AppSettings:DatabaseType"), + configuration.GetValue("AppSettings:DatabaseType", DatabaseType.None), configuration.GetConnectionString("DefaultConnection")); } \ No newline at end of file diff --git a/src/building-blocks/DevStore.WebAPI.Core/DatabaseFlavor/ProviderSelector.cs b/src/building-blocks/DevStore.WebAPI.Core/DatabaseFlavor/ProviderSelector.cs index bf3b13f..d8b619c 100644 --- a/src/building-blocks/DevStore.WebAPI.Core/DatabaseFlavor/ProviderSelector.cs +++ b/src/building-blocks/DevStore.WebAPI.Core/DatabaseFlavor/ProviderSelector.cs @@ -12,13 +12,12 @@ public static class ProviderSelector (DatabaseType, string) options) where TContext : DbContext { var (database, connString) = options; - Build(connString); return database switch { - DatabaseType.SqlServer => services.PersistStore(With.SqlServer), - DatabaseType.MySql => services.PersistStore(With.MySql), - DatabaseType.Postgre => services.PersistStore(With.Postgre), - DatabaseType.Sqlite => services.PersistStore(With.Sqlite), + DatabaseType.SqlServer => services.PersistStore(Build(connString).With().SqlServer), + DatabaseType.MySql => services.PersistStore(Build(connString).With().MySql), + DatabaseType.Postgre => services.PersistStore(Build(connString).With().Postgre), + DatabaseType.Sqlite => services.PersistStore(Build(connString).With().Sqlite), _ => throw new ArgumentOutOfRangeException(nameof(database), database, null) }; @@ -27,13 +26,12 @@ public static class ProviderSelector public static Action WithProviderAutoSelection((DatabaseType, string) options) { var (database, connString) = options; - Build(connString); return database switch { - DatabaseType.SqlServer => With.SqlServer, - DatabaseType.MySql => With.MySql, - DatabaseType.Postgre => With.Postgre, - DatabaseType.Sqlite => With.Sqlite, + DatabaseType.SqlServer => Build(connString).With().SqlServer, + DatabaseType.MySql => Build(connString).With().MySql, + DatabaseType.Postgre => Build(connString).With().Postgre, + DatabaseType.Sqlite => Build(connString).With().Sqlite, _ => throw new ArgumentOutOfRangeException(nameof(database), database, null) }; diff --git a/src/building-blocks/DevStore.WebAPI.Core/DevStore.WebAPI.Core.csproj b/src/building-blocks/DevStore.WebAPI.Core/DevStore.WebAPI.Core.csproj index c2e0770b9b7e08cac6ecb050a8ee83651e8d2ac9..67cc58628f90ddd0e06d926c62881a56cfc9f624 100644 GIT binary patch delta 493 zcmaDOcu0D~GDdz^hD3&9hDruMhE#?UhQP^M>x~Q9SuQn>NUNOOkW}&GQ4=kk{YG%ZGRDaYOur@{V)mK*fL&~J4f8H0AjfZV3tJka@#I7%@5yHDag(nwf~3=c WGD4HJSS=5dWG(C4j8$Q&eYG9CZ}+V3v}1dAxRT}oPK9;sHQ&M} zE9v{tC&1j31`#K8M4EUuMJbO^~?9>NBe($P(pk4@G-*`-dH&Nn&5%_AcDG z2sVv4bKT_M463hTZxZNJq7d)*xi!YJ6b>Kwo>~{4d#rl%{VMIn^;d{p3tsx0;L%f) z{DhU_D<8#G!v280DJLGKI}TxCj%v=%qgjGe z$u{NdW#F5JvCGaUWGHLo#e-{kidw>+YGuTo3=KWIlIysHfK9PQXEVq4Ulz7L#6e1%denfd@M=o700ZoDNThjz^D#NKc!{8BDm zus*3lg=shwj-J6)^;m=*VX}06urh9LohnMNi*81gRF3@rR!Y}PVvti;3u~L=>8R%M z)C)fi^&+1~tWmz-1+JBGL-;O)TblkhXqc(Tu0TN#NiU6>XnHYq1QC}Wc96% z?UOxv7Y1bFb|aFxUOwt2%&91St0nc|tC|>7ZK@<`He~cypcnQosIAzKL<`zfLF~zn z;r$IBv9ij@yp6qH0dal~7j=tTO^_M8iWwD=^QU~9k|C=R+wJplv#9y41S_IGdTo4u zw4_%D{K&68w9meJjp%_z|LFH_Q;O@tyT{xg?ZoInV-sf&GY`rS@H<+-Ak5?nL{)ZCgslO90sEWG8RvD!Z bwaeKo^!d%`Rz@`8OOu{;Q7z|0TwU2;!8tN0 delta 57 zcmew(dy0F4)xgxkz%tg~{)jv?hOG6q$U1iEZPNG7feRh7uqwnEakmeDVfH0mjtHo}AK*8k0A& PDNg>tA+cG9YYGzpoN^RN delta 187 zcmZ1^c|dZ)h0O|#SseU%45V3nyr5s+;~K#>xlc|{C)LO^Z_kWmU0vIeqi8EPjha++`Egf`lli$cCvOoD000+S76t$S delta 105 zcmX@5ctml73ftsW>=v7^uvIWm-oU27>&}qMkO#y?44DkclM~q_C(jX(n=Hd4GP#OH qZF3LTD^^S;;z|tq3>iR8i3~XmB|ugcgA#)#gZ1P>4$;Y51jGPD4I5bi diff --git a/src/services/DevStore.Billing.API/DevStore.Billing.API.csproj b/src/services/DevStore.Billing.API/DevStore.Billing.API.csproj index 6d09d19c43c3bee6c1670b2f70a15c2b97c3b85b..3e4eb5819351563111a45ed2795de0162a321932 100644 GIT binary patch delta 16 XcmZpXS|PmQAM<1#W~t33>=Rf4H3|i) delta 516 zcmZ1>+#!I2?}p%|zN zq#_xtBcCB}ay_%;20^OPlbbT=prUKc;Ky`^gn{ya!81(U~ zLN?747)r@NJ*5mO7^W35l-5H75fpUR3<|)YDg|1e15^y+<$)amatuT^85pRbKu-me zX<(J9K!<_UCW2Mx03)LcC|?8>MVJSPfIOf$D9Rva+AwJ9GvIR}%qKt}PZnfVoLs=- Ku=y49K2`u{?Pm%A diff --git a/src/services/DevStore.Billing.API/appsettings.Docker.json b/src/services/DevStore.Billing.API/appsettings.Docker.json index 1da4472..eee4280 100644 --- a/src/services/DevStore.Billing.API/appsettings.Docker.json +++ b/src/services/DevStore.Billing.API/appsettings.Docker.json @@ -29,7 +29,7 @@ "MessageBus": "host=devstore-rabbit:5672;publisherConfirms=true;timeout=30;username=devstore;password=devstore" }, "AppSettings": { - "JwksUri": "https://devstore-api-identity:5101/jwks", + "JwksUri": "https://devstore-api-identity/jwks", "Issuer": "https://devstore.academy", "Audience": "DevStore" }, diff --git a/src/services/DevStore.Billing.API/appsettings.Production.json b/src/services/DevStore.Billing.API/appsettings.Production.json index 3023dd0..001bde6 100644 --- a/src/services/DevStore.Billing.API/appsettings.Production.json +++ b/src/services/DevStore.Billing.API/appsettings.Production.json @@ -29,7 +29,7 @@ "MessageBus": "host=devstore-rabbit:5672;publisherConfirms=true;timeout=30;username=devstore;password=devstore" }, "AppSettings": { - "JwksUri": "https://devstore-api-identity:5101/jwks", + "JwksUri": "https://devstore-api-identity/jwks", "Issuer": "https://devstore.academy", "Audience": "DevStore" }, diff --git a/src/services/DevStore.Billing.DevsPay/Properties/launchSettings.json b/src/services/DevStore.Billing.DevsPay/Properties/launchSettings.json new file mode 100644 index 0000000..e147a5c --- /dev/null +++ b/src/services/DevStore.Billing.DevsPay/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "DevStore.Billing.DevsPay": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:56386;http://localhost:56395" + } + } +} \ No newline at end of file diff --git a/src/services/DevStore.Catalog.API/Configuration/ApiConfig.cs b/src/services/DevStore.Catalog.API/Configuration/ApiConfig.cs index 59d2ec616b312151cbac8f3be5c02bba2b12a6a4..4fb8d7ab44a5addb5b25d26425b5c067339278bd 100644 GIT binary patch delta 89 zcmX>ke?or4Ck|d0hE#?$hD3%^h8%{H$^SVdCqH75VYHsy$R@hkfK!W28btwv2T*w; bNGU@GL-J%^PE7#?1_-QW;AP-qsAT{EKn@fj delta 80 zcmX>he@K4ACk|eBhE#?;ATDCaWJsR;pF?u;EPlDo0h}sqm{P(@4EhWiK*fm+ISeI0 QRuzNNWJ6B*$vgN30F<{B$p8QV diff --git a/src/services/DevStore.Catalog.API/DevStore.Catalog.API.csproj b/src/services/DevStore.Catalog.API/DevStore.Catalog.API.csproj index 67ce04af765a4a4cf03c404c17f5d90660ec52bb..251cf7510adb29f8c19320ca89410338b3b7a836 100644 GIT binary patch delta 12 Tcmdlcu}^SA9?Rxu>;WtQA`1kx delta 558 zcma)3OKJi^6fBu`6L292(VcpLB#>-ER1l-!A|c=bWE|Tt#I!n-54!OXz3~`Az-7n{ za-^hQj}RwhMF_-2&CfcW}F={wJh}!4ua*hEjUojNUWr{RnI2p4H z_l9ByjD&;_-Jfw%L{gFsICjBnw~riBEJ~%%n24NX!F;rh{_!PGR5wh>t0tu4=byrq Tz+FGY+HX~{U#jylRrl%_S1D`| diff --git a/src/services/DevStore.Catalog.API/appsettings.Docker.json b/src/services/DevStore.Catalog.API/appsettings.Docker.json index 0916730..17b9143 100644 --- a/src/services/DevStore.Catalog.API/appsettings.Docker.json +++ b/src/services/DevStore.Catalog.API/appsettings.Docker.json @@ -29,7 +29,7 @@ "MessageBus": "host=devstore-rabbit:5672;publisherConfirms=true;timeout=30;username=devstore;password=devstore" }, "AppSettings": { - "JwksUri": "https://devstore-api-identity:5101/jwks", + "JwksUri": "https://devstore-api-identity/jwks", "Issuer": "https://devstore.academy", "Audience": "DevStore" } diff --git a/src/services/DevStore.Catalog.API/appsettings.Production.json b/src/services/DevStore.Catalog.API/appsettings.Production.json index 81bca98..f1ee6b3 100644 --- a/src/services/DevStore.Catalog.API/appsettings.Production.json +++ b/src/services/DevStore.Catalog.API/appsettings.Production.json @@ -29,7 +29,7 @@ "MessageBus": "host=devstore-rabbit:5672;publisherConfirms=true;timeout=30;username=devstore;password=devstore" }, "AppSettings": { - "JwksUri": "https://devstore-api-identity:5101/jwks", + "JwksUri": "https://devstore-api-identity/jwks", "Issuer": "https://devstore.academy", "Audience": "DevStore" } diff --git a/src/services/DevStore.Customers.API/Configuration/ApiConfig.cs b/src/services/DevStore.Customers.API/Configuration/ApiConfig.cs index 338e09c688ef9b0d41903d23331f4b74622fd42e..9a04b055eb2405c7e231ee91acd67f66e7cba2ee 100644 GIT binary patch delta 98 zcmca0e@%YF9}Z;~hE#?$hD3%^h8%_x1`i-F5zNY9aAwE=@{$>{C+}yK->kyv5n58zSa73BVn}4jWk_WxXUGS#vl*PhbSi@$gCj!{LorYl zNJTPOM?OQ|WPcV(PBWma0T7!^j%V|pypKi1l2|i?844M47=nTJ6)}{7$jN~$;+W>C z5@p_GepcOj69y#)I|g0`E(Qf8Xu}Wyv>_8{M1YDpfDt0LBVMabW9RZBonAS1I|bwpNM^`p&|pwv V&>r@o$@`fVCvRYO0fy`~Sm;XX0YfSYXe`8nWU$#FXM)2T8WRDmVw<^GV%Pva3|LP9 diff --git a/src/services/DevStore.Identity.API/Program.cs b/src/services/DevStore.Identity.API/Program.cs index ce963e8791e55adf1b588170cdf2ebce0b6fa88f..af7ccd31317d0a0f87c97f8fe5628ab146335ff8 100644 GIT binary patch delta 20 ccmdnMbBkw#3-e?)7PHCgm^C(6Fz;Xj07`!b!2kdN delta 16 Ycmcb`vw>%W3-jbN%qE)`G4Egk060VjLI3~& diff --git a/src/services/DevStore.Identity.API/appsettings.Development.json b/src/services/DevStore.Identity.API/appsettings.Development.json index f5b6caa..5e1a3db 100644 --- a/src/services/DevStore.Identity.API/appsettings.Development.json +++ b/src/services/DevStore.Identity.API/appsettings.Development.json @@ -37,6 +37,6 @@ }, "MessageQueueConnection": { - "MessageBus": "host=localhost:5672;publisherConfirms=true;timeout=10;username=devstore;password=devstore" + "MessageBus": "host=localhost:5672;publisherConfirms=true;timeout=10;username=guest;password=guest" } } diff --git a/src/services/DevStore.Orders.API/Configuration/ApiConfig.cs b/src/services/DevStore.Orders.API/Configuration/ApiConfig.cs index b1bbc394a3fce5d7d84f5b311f5114cdbaa0a2c5..c238713fc93c6085aa049b8e977b94c01a0ba144 100644 GIT binary patch delta 100 zcmX>le@1@8Hx6DGhE#?$hD3%^h8%{H$%_1vjLDM&nI)Mu8LTHC#Ni4VJb>B~L0T9x7?LLoatcrO;!~Mi#jiH`7>58*6Wion`~m=jm>a_Y delta 134 zcmX>je@cGCHx6ZYhE#?;ATDCaWJqT40J0Jpau`Y&G8mkJI29RX q0hUDP_n7Ye{5C0$Y#87@$G++?tpM8BbouV*mhyqAwx< delta 74 zcmdlceNB?-|G&uvOmZ93G?+F&W4gpP`2@S%<`A88UO&)7#98j diff --git a/src/services/DevStore.Orders.API/Controllers/VoucherController.cs b/src/services/DevStore.Orders.API/Controllers/VoucherController.cs index a9fdb11cf5a0d331fd29ca099a7bec56201a963b..d07bf2246524e28dd6c2e462ec2e081388c0242b 100644 GIT binary patch delta 48 pcmca5a8F>v4OU)fhJ1!Rh7yKU5IOlgi{$1%tnV1nguk+<0sw(64@>|6 delta 44 pcmca7a7$pr4OZ?F1~-O$hEj$+hLp+YStK|AV|~YnBKVU%6#!5Q4tM|n diff --git a/src/services/DevStore.Orders.API/appsettings.Docker.json b/src/services/DevStore.Orders.API/appsettings.Docker.json index 3982aa5..0d10e28 100644 --- a/src/services/DevStore.Orders.API/appsettings.Docker.json +++ b/src/services/DevStore.Orders.API/appsettings.Docker.json @@ -30,7 +30,7 @@ "MessageBus": "host=devstore-rabbit:5672;publisherConfirms=true;timeout=30;username=devstore;password=devstore" }, "AppSettings": { - "JwksUri": "https://devstore-api-identity:5101/jwks", + "JwksUri": "https://devstore-api-identity/jwks", "Issuer": "https://devstore.academy", "Audience": "DevStore" } diff --git a/src/services/DevStore.Orders.API/appsettings.Production.json b/src/services/DevStore.Orders.API/appsettings.Production.json index cc96e44..f94478b 100644 --- a/src/services/DevStore.Orders.API/appsettings.Production.json +++ b/src/services/DevStore.Orders.API/appsettings.Production.json @@ -30,7 +30,7 @@ "MessageBus": "host=devstore-rabbit:5672;publisherConfirms=true;timeout=30;username=devstore;password=devstore" }, "AppSettings": { - "JwksUri": "https://devstore-api-identity:5101/jwks", + "JwksUri": "https://devstore-api-identity/jwks", "Issuer": "https://devstore.academy", "Audience": "DevStore" } diff --git a/src/services/DevStore.Orders.Domain/Properties/launchSettings.json b/src/services/DevStore.Orders.Domain/Properties/launchSettings.json new file mode 100644 index 0000000..54e7ecd --- /dev/null +++ b/src/services/DevStore.Orders.Domain/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "DevStore.Orders.Domain": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:56390;http://localhost:56394" + } + } +} \ No newline at end of file diff --git a/src/services/DevStore.ShoppingCart.API/Configuration/ApiConfig.cs b/src/services/DevStore.ShoppingCart.API/Configuration/ApiConfig.cs index 15a1801..6134547 100644 --- a/src/services/DevStore.ShoppingCart.API/Configuration/ApiConfig.cs +++ b/src/services/DevStore.ShoppingCart.API/Configuration/ApiConfig.cs @@ -24,7 +24,7 @@ public static void AddApiConfiguration(this IServiceCollection services, IConfig .AllowAnyHeader()); }); - services.AddGenericHealthCheck(); + services.AddDefaultHealthCheck(configuration); } public static void UseApiConfiguration(this WebApplication app, IWebHostEnvironment env) @@ -47,7 +47,7 @@ public static void UseApiConfiguration(this WebApplication app, IWebHostEnvironm app.MapGrpcService().RequireCors("Total"); - app.UseGenericHealthCheck("/healthz"); + app.UseDefaultHealthcheck(); } } } \ No newline at end of file diff --git a/src/services/DevStore.ShoppingCart.API/DevStore.ShoppingCart.API.csproj b/src/services/DevStore.ShoppingCart.API/DevStore.ShoppingCart.API.csproj index c0396b3..0d77293 100644 --- a/src/services/DevStore.ShoppingCart.API/DevStore.ShoppingCart.API.csproj +++ b/src/services/DevStore.ShoppingCart.API/DevStore.ShoppingCart.API.csproj @@ -11,13 +11,6 @@ - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/src/services/DevStore.ShoppingCart.API/appsettings.Docker.json b/src/services/DevStore.ShoppingCart.API/appsettings.Docker.json index f5aa360..9bd3c24 100644 --- a/src/services/DevStore.ShoppingCart.API/appsettings.Docker.json +++ b/src/services/DevStore.ShoppingCart.API/appsettings.Docker.json @@ -29,7 +29,7 @@ "MessageBus": "host=devstore-rabbit:5672;publisherConfirms=true;timeout=30;username=devstore;password=devstore" }, "AppSettings": { - "JwksUri": "https://devstore-api-identity:5101/jwks", + "JwksUri": "https://devstore-api-identity/jwks", "Issuer": "https://devstore.academy", "Audience": "DevStore" } diff --git a/src/services/DevStore.ShoppingCart.API/appsettings.Production.json b/src/services/DevStore.ShoppingCart.API/appsettings.Production.json index 09828c8..72c2cb9 100644 --- a/src/services/DevStore.ShoppingCart.API/appsettings.Production.json +++ b/src/services/DevStore.ShoppingCart.API/appsettings.Production.json @@ -29,7 +29,7 @@ "MessageBus": "host=devstore-rabbit:5672;publisherConfirms=true;timeout=30;username=devstore;password=devstore" }, "AppSettings": { - "JwksUri": "https://devstore-api-identity:5101/jwks", + "JwksUri": "https://devstore-api-identity/jwks", "Issuer": "https://devstore.academy", "Audience": "DevStore" } diff --git a/src/services/DevStore.ShoppingCart.API/appsettings.json b/src/services/DevStore.ShoppingCart.API/appsettings.json index 1e32362..88d07e2 100644 --- a/src/services/DevStore.ShoppingCart.API/appsettings.json +++ b/src/services/DevStore.ShoppingCart.API/appsettings.json @@ -3,5 +3,6 @@ "Issuer": "https://devstore.academy", "Audience": "DevStore", "DatabaseType": "SqlServer" - } + }, + "USE_HTTPS_REDIRECTION": "true" } diff --git a/src/web/DevStore.WebApp.MVC/Configuration/WebAppConfig.cs b/src/web/DevStore.WebApp.MVC/Configuration/WebAppConfig.cs index 366cf3a703f60a7da9e372dd9525a0e1025f5129..92d65da6a7133caaf59218a39aeb2843d5bb4fe4 100644 GIT binary patch delta 110 zcmdldze!<&25$g^Cxae?GebT@5ku%x%Akj9Y6P|A?Q yP%`;EyZGb=c9qSa*vr@^ak43+$TD~U)h2?}F=Q|#192*l%%1GXr#tx=-wyyAZXAIC delta 103 zcmdm_uup!1#>To8?2;Y~sSJq>ISeHX84S)qoXU{Qkj+rcps_iXqn^#s7bsc4fKw5J Z5`#Wi6U>OJ$%b6=lNa!EOg7>F2LKYM7&`y} diff --git a/src/web/DevStore.WebApp.MVC/Properties/launchSettings.json b/src/web/DevStore.WebApp.MVC/Properties/launchSettings.json index ae6c796..dcb3487 100644 --- a/src/web/DevStore.WebApp.MVC/Properties/launchSettings.json +++ b/src/web/DevStore.WebApp.MVC/Properties/launchSettings.json @@ -1,12 +1,4 @@ { - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:52608", - "sslPort": 44303 - } - }, "profiles": { "SelfHosting - Dev": { "commandName": "Project", diff --git a/src/web/DevStore.WebApp.MVC/appsettings.Docker.json b/src/web/DevStore.WebApp.MVC/appsettings.Docker.json index 06f0f4f..10e8952 100644 --- a/src/web/DevStore.WebApp.MVC/appsettings.Docker.json +++ b/src/web/DevStore.WebApp.MVC/appsettings.Docker.json @@ -22,9 +22,9 @@ "Application": "DevStoreWeb" } }, - "AuthUrl": "https://devstore-api-identity:5101", - "CatalogUrl": "https://devstore-api-catalog:5301", - "CustomerUrl": "https://devstore-api-customers:5401", - "CheckoutBffUrl": "https://devstore-api-bff-checkout:5501" + "AuthUrl": "https://devstore-api-identity", + "CatalogUrl": "https://devstore-api-catalog", + "CustomerUrl": "https://devstore-api-customers", + "CheckoutBffUrl": "https://devstore-api-bff-checkout" } \ No newline at end of file diff --git a/src/web/DevStore.WebApp.MVC/appsettings.Production.json b/src/web/DevStore.WebApp.MVC/appsettings.Production.json index f6fd49a..7eebbef 100644 --- a/src/web/DevStore.WebApp.MVC/appsettings.Production.json +++ b/src/web/DevStore.WebApp.MVC/appsettings.Production.json @@ -22,9 +22,9 @@ "Application": "DevStoreWeb" } }, - "AuthUrl": "https://devstore-api-identity:5101", - "CatalogUrl": "https://devstore-api-catalog:5301", - "CustomerUrl": "https://devstore-api-customers:5401", - "CheckoutBffUrl": "https://devstore-api-bff-checkout:5501", + "AuthUrl": "https://devstore-api-identity", + "CatalogUrl": "https://devstore-api-catalog", + "CustomerUrl": "https://devstore-api-customers", + "CheckoutBffUrl": "https://devstore-api-bff-checkout", } \ No newline at end of file diff --git a/src/web/DevStore.WebApp.MVC/appsettings.json b/src/web/DevStore.WebApp.MVC/appsettings.json index 4faf77a..3d3da2e 100644 --- a/src/web/DevStore.WebApp.MVC/appsettings.json +++ b/src/web/DevStore.WebApp.MVC/appsettings.json @@ -1,3 +1,4 @@ { - "AllowedHosts": "*" + "AllowedHosts": "*", + "USE_HTTPS_REDIRECTION": "true" } diff --git a/src/web/DevStore.WebApp.Status/DevStore.WebApp.Status.csproj b/src/web/DevStore.WebApp.Status/DevStore.WebApp.Status.csproj new file mode 100644 index 0000000..39a811b --- /dev/null +++ b/src/web/DevStore.WebApp.Status/DevStore.WebApp.Status.csproj @@ -0,0 +1,51 @@ + + + + net6.0 + enable + enable + 0ab5617d-1cdf-455d-b9e2-e9f76e347af1 + Linux + ..\..\.. + + + + + + + + + + + + + + + + + + + + PreserveNewest + true + PreserveNewest + + + PreserveNewest + true + PreserveNewest + + + PreserveNewest + true + PreserveNewest + + + + + + Always + + + + diff --git a/src/web/DevStore.WebApp.Status/Dockerfile b/src/web/DevStore.WebApp.Status/Dockerfile new file mode 100644 index 0000000..4289ac9 --- /dev/null +++ b/src/web/DevStore.WebApp.Status/Dockerfile @@ -0,0 +1,24 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +WORKDIR /src +COPY ["web/DevStore.WebApp.Status/DevStore.WebApp.Status.csproj", "web/DevStore.WebApp.Status/"] +COPY ["building-blocks/DevStore.WebAPI.Core/DevStore.WebAPI.Core.csproj", "building-blocks/DevStore.WebAPI.Core/"] +COPY ["building-blocks/DevStore.Core/DevStore.Core.csproj", "building-blocks/DevStore.Core/"] +RUN dotnet restore "web/DevStore.WebApp.Status/DevStore.WebApp.Status.csproj" +COPY . . +WORKDIR "web/DevStore.WebApp.Status" +RUN dotnet build "DevStore.WebApp.Status.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "DevStore.WebApp.Status.csproj" -c Release -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "DevStore.WebApp.Status.dll"] \ No newline at end of file diff --git a/src/web/DevStore.WebApp.Status/Dockerfile.original b/src/web/DevStore.WebApp.Status/Dockerfile.original new file mode 100644 index 0000000..66d4a89 --- /dev/null +++ b/src/web/DevStore.WebApp.Status/Dockerfile.original @@ -0,0 +1,22 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +WORKDIR /src +COPY ["src/web/DevStore.WebApp.Status/DevStore.WebApp.Status.csproj", "src/web/DevStore.WebApp.Status/"] +RUN dotnet restore "src/web/DevStore.WebApp.Status/DevStore.WebApp.Status.csproj" +COPY . . +WORKDIR "/src/src/web/DevStore.WebApp.Status" +RUN dotnet build "DevStore.WebApp.Status.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "DevStore.WebApp.Status.csproj" -c Release -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "DevStore.WebApp.Status.dll"] \ No newline at end of file diff --git a/src/web/DevStore.WebApp.Status/Program.cs b/src/web/DevStore.WebApp.Status/Program.cs new file mode 100644 index 0000000..1c24e67 --- /dev/null +++ b/src/web/DevStore.WebApp.Status/Program.cs @@ -0,0 +1,67 @@ +using DevStore.WebAPI.Core.DatabaseFlavor; +using Serilog; +using DevStore.WebAPI.Core.Extensions; +using static DevStore.WebAPI.Core.DatabaseFlavor.ProviderConfiguration; + +var builder = WebApplication.CreateBuilder(args); + +builder.Logging.AddSerilog(new LoggerConfiguration() + .ReadFrom.Configuration(builder.Configuration) + .CreateLogger()); + +var healthCheckBuilder = builder.Services.AddHealthChecksUI(setupSettings: setup => +{ + setup.SetHeaderText("DevStore - Status Page"); + var endpoints = builder.Configuration.GetSection("ENDPOINTS").Get>(); + + foreach (var endpoint in endpoints) + { + var name = endpoint.Split(';')[0]; + var uri = endpoint.Split(';')[1]; + + setup.AddHealthCheckEndpoint(name, uri); + } + + setup.UseApiEndpointHttpMessageHandler(sp => HttpExtensions.ConfigureClientHandler()); +}); +var (database, connString) = DetectDatabase(builder.Configuration); + +switch (database) +{ + case DatabaseType.None: + healthCheckBuilder.AddInMemoryStorage(); + break; + case DatabaseType.SqlServer: + healthCheckBuilder.AddSqlServerStorage(connString); + break; + case DatabaseType.MySql: + healthCheckBuilder.AddMySqlStorage(connString); + break; + case DatabaseType.Postgre: + healthCheckBuilder.AddPostgreSqlStorage(connString); + break; + case DatabaseType.Sqlite: + healthCheckBuilder.AddSqliteStorage(connString); + break; + default: + healthCheckBuilder.AddInMemoryStorage(); + break; +} + +var app = builder.Build(); + +// Under certain scenarios, e.g minikube / linux environment / behind load balancer +// https redirection could lead dev's to over complicated configuration for testing purpouses +// In production is a good practice to keep it true +if (app.Configuration["USE_HTTPS_REDIRECTION"] == "true") +{ + app.UseHttpsRedirection(); + app.UseHsts(); +} + +app.MapHealthChecksUI(setup => +{ + setup.AddCustomStylesheet("devstore.css"); + setup.UIPath = "/status"; +}); +app.Run(); diff --git a/src/web/DevStore.WebApp.Status/Properties/launchSettings.json b/src/web/DevStore.WebApp.Status/Properties/launchSettings.json new file mode 100644 index 0000000..c8731b9 --- /dev/null +++ b/src/web/DevStore.WebApp.Status/Properties/launchSettings.json @@ -0,0 +1,14 @@ +{ + "profiles": { + "SelfHosting - Dev": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "status", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "dotnetRunMessages": true, + "applicationUrl": "https://localhost:4211;http://localhost:4210" + } + } +} \ No newline at end of file diff --git a/src/web/DevStore.WebApp.Status/appsettings.Development.json b/src/web/DevStore.WebApp.Status/appsettings.Development.json new file mode 100644 index 0000000..3f9bca5 --- /dev/null +++ b/src/web/DevStore.WebApp.Status/appsettings.Development.json @@ -0,0 +1,43 @@ +{ + "Serilog": { + "Using": [ "Serilog.Sinks.Console" ], + "MinimumLevel": { + "Default": "Information", + "Override": { + "Microsoft.AspNetCore": "Warning", + "Microsoft.EntityFrameworkCore": "Information" + } + }, + "WriteTo": [ + { "Name": "Console" } + ], + "Enrich": [ "FromLogContext" ], + "Properties": { + "Application": "DevStoreWeb" + } + }, + "ConnectionStrings": { + // Sql Server Connection + "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=DSStatus;Trusted_Connection=True;MultipleActiveResultSets=true" + + // Postgre Connection + //"DefaultConnection": "Server=localhost;Port=5432;Database=DSStatus;User Id=sa;Password=MyDB@123;" + + // MySql Connection + //"DefaultConnection": "server=localhost,port=3306;database=DSStatus;user=sa;password=MyDB@123" + + // SQLite Connection + //"DefaultConnection": "Data Source=DSStatus.db" + + }, + "ENDPOINTS": [ + "Frontend Web;https://localhost:5401/healthz-infra", + "Shopping Cart API;https://localhost:5411/healthz-infra", + "Identity API;https://localhost:5421/healthz-infra", + "Catalog API;https://localhost:5431/healthz-infra", + "Customer API;https://localhost:5441/healthz-infra", + "BFF Checkout;https://localhost:5451/healthz-infra", + "Billing API;https://localhost:5461/healthz-infra", + "Order API;https://localhost:5471/healthz-infra" + ] +} diff --git a/src/web/DevStore.WebApp.Status/appsettings.Docker.json b/src/web/DevStore.WebApp.Status/appsettings.Docker.json new file mode 100644 index 0000000..fbe44c1 --- /dev/null +++ b/src/web/DevStore.WebApp.Status/appsettings.Docker.json @@ -0,0 +1,32 @@ +{ + "Serilog": { + "Using": [ "Serilog.Sinks.Console" ], + "MinimumLevel": { + "Default": "Information", + "Override": { + "Microsoft.AspNetCore": "Warning", + "Microsoft.EntityFrameworkCore": "Information" + } + }, + "WriteTo": [ + { "Name": "Console" } + ], + "Enrich": [ "FromLogContext" ], + "Properties": { + "Application": "DevStoreWeb" + } + }, + "ConnectionStrings": { + "DefaultConnection": "Server=database-status;Database=DSStatus;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" + }, + "ENDPOINTS": [ + "Identity API;https://api-identity/healthz-infra", + "BFF Checkout;https://api-bff-checkout/healthz-infra", + "Frontend Web;https://web-mvc/healthz-infra", + "Shopping Cart API;https://api-cart/healthz-infra", + "Catalog API;https://api-catalog/healthz-infra", + "Customer API;https://api-customers/healthz-infra", + "Billing API;https://api-billing/healthz-infra", + "Order API;https://api-order/healthz-infra" + ] +} \ No newline at end of file diff --git a/src/web/DevStore.WebApp.Status/appsettings.Production.json b/src/web/DevStore.WebApp.Status/appsettings.Production.json new file mode 100644 index 0000000..32d4cf0 --- /dev/null +++ b/src/web/DevStore.WebApp.Status/appsettings.Production.json @@ -0,0 +1,32 @@ +{ + "Serilog": { + "Using": [ "Serilog.Sinks.Console" ], + "MinimumLevel": { + "Default": "Warning", + "Override": { + "Microsoft.AspNetCore": "Warning", + "Microsoft.EntityFrameworkCore": "Error" + } + }, + "WriteTo": [ + { "Name": "Console" } + ], + "Enrich": [ "FromLogContext" ], + "Properties": { + "Application": "DevStoreWeb" + } + }, + "ConnectionStrings": { + "DefaultConnection": "Server=database-status;Database=DSStatus;MultipleActiveResultSets=true;User Id=sa;Password=MyDB@123" + }, + "ENDPOINTS": [ + "Frontend Web;https://web-devstore-ecommerce/healthz-infra", + "Identity API;https://api-identity/healthz-infra", + "BFF Checkout;https://api-bff-checkout/healthz-infra", + "Shopping Cart API;https://api-cart/healthz-infra", + "Catalog API;https://api-catalog/healthz-infra", + "Customer API;https://api-customers/healthz-infra", + "Billing API;https://api-billing/healthz-infra", + "Order API;https://api-orders/healthz-infra" + ] +} \ No newline at end of file diff --git a/src/web/DevStore.WebApp.Status/appsettings.json b/src/web/DevStore.WebApp.Status/appsettings.json new file mode 100644 index 0000000..db4af7c --- /dev/null +++ b/src/web/DevStore.WebApp.Status/appsettings.json @@ -0,0 +1,6 @@ +{ + "AllowedHosts": "*", + "AppSettings": { + "DatabaseType": "SqlServer" + } +} diff --git a/src/web/DevStore.WebApp.Status/devstore.css b/src/web/DevStore.WebApp.Status/devstore.css new file mode 100644 index 0000000..dbc9a2a --- /dev/null +++ b/src/web/DevStore.WebApp.Status/devstore.css @@ -0,0 +1,8 @@ +:root { + --primaryColor: #525AF2; + --secondaryColor: #F2F2F2; + --bgMenuActive: #797FF2; + --bgButton: #A2A6F2; + --logoImageUrl: url('https://devstore.academy/images/favicon.png'); + --bgAside: var(--primaryColor); +}