Skip to content

Commit 828c7a7

Browse files
committed
Update Docker, health checks, and service configurations
Updated solution to include Docker files and local env file. Replaced `application-docker-compose.yml` with `docker-compose.override.yml` and `docker-compose.yml`. Modified `appsettings.json` for new endpoints, Consul, Fabio, logging, metrics, MongoDB, RabbitMQ, and other services. Updated health check endpoints in `Extensions.cs`. Upgraded Dockerfiles to .NET 9.0. Removed versioning and service definitions for API gateway in Docker Compose files. Changed service ports in `docker-compose.yml`. Updated project files to reference new projects and packages. Configured Consul and Fabio in `Program.cs`. Extensively modified `appsettings.json` for orders and identity services. Updated `.dockerignore` to include various patterns.
1 parent c3c6488 commit 828c7a7

File tree

18 files changed

+262
-118
lines changed

18 files changed

+262
-118
lines changed

genocs.sln

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,11 @@ EndProject
120120
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{B184733D-2415-4517-BC65-26ED22EEB2C2}"
121121
ProjectSection(SolutionItems) = preProject
122122
src\apps\apigateway.dockerfile = src\apps\apigateway.dockerfile
123-
src\apps\application-docker-compose.yml = src\apps\application-docker-compose.yml
123+
src\apps\docker-compose.override.yml = src\apps\docker-compose.override.yml
124+
src\apps\docker-compose.yml = src\apps\docker-compose.yml
124125
src\apps\identity-webapi.dockerfile = src\apps\identity-webapi.dockerfile
125126
src\apps\order-webapi.dockerfile = src\apps\order-webapi.dockerfile
127+
src\apps\local.env = src\apps\local.env
126128
src\apps\product-webapi.dockerfile = src\apps\product-webapi.dockerfile
127129
src\apps\signalr-webapi.dockerfile = src\apps\signalr-webapi.dockerfile
128130
EndProjectSection

src/Genocs.Core.Demo.Worker/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"address": "docker.for.mac.localhost",
4747
"port": "5070",
4848
"pingEnabled": true,
49-
"pingEndpoint": "alive",
49+
"pingEndpoint": "healthz",
5050
"pingInterval": 3,
5151
"removeAfterInterval": 3
5252
},

src/Genocs.Core/Builders/Extensions.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app)
136136
return app;
137137
}
138138

139+
// All health checks must pass for app to be considered ready to accept traffic after starting
140+
app.MapHealthChecks("/healthz");
141+
142+
// Only health checks tagged with the "live" tag must pass for app to be considered alive
143+
app.MapHealthChecks("/alive", new HealthCheckOptions
144+
{
145+
Predicate = r => r.Tags.Contains("live")
146+
});
147+
139148
app.MapGet("/", async context =>
140149
{
141150
// Get the Entry Assembly Name and Version
@@ -146,16 +155,6 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app)
146155

147156
await context.Response.WriteAsync(context.RequestServices.GetService<AppOptions>()?.Name ?? message);
148157
});
149-
150-
// All health checks must pass for app to be considered ready to accept traffic after starting
151-
app.MapHealthChecks("/health");
152-
153-
// Only health checks tagged with the "live" tag must pass for app to be considered alive
154-
app.MapHealthChecks("/alive", new HealthCheckOptions
155-
{
156-
Predicate = r => r.Tags.Contains("live")
157-
});
158-
159158
return app;
160159
}
161160

@@ -165,15 +164,6 @@ private static void Setup(IGenocsBuilder builder)
165164
AppOptions settings = builder.GetOptions<AppOptions>(AppOptions.Position);
166165
builder.Services.AddSingleton(settings);
167166

168-
// Add the health checks
169-
builder.Services
170-
.AddHealthChecks()
171-
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]); // Add a default liveness check to ensure app is responsive
172-
173-
builder.Services.AddMemoryCache();
174-
175-
builder.Services.AddSingleton<IServiceId, ServiceId>();
176-
177167
if (!settings.DisplayBanner || string.IsNullOrWhiteSpace(settings.Name))
178168
{
179169
return;
@@ -185,5 +175,15 @@ private static void Setup(IGenocsBuilder builder)
185175
Console.ForegroundColor = ConsoleColor.Blue;
186176
Console.WriteLine("Runtime Version: {0}", Environment.Version.ToString());
187177
Console.ForegroundColor = current;
178+
179+
// Add the health checks
180+
builder.Services
181+
.AddHealthChecks();
182+
183+
// .AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]); // Add a default liveness check to ensure app is responsive
184+
185+
builder.Services.AddMemoryCache();
186+
187+
builder.Services.AddSingleton<IServiceId, ServiceId>();
188188
}
189189
}

src/apps/.dockerignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
**/[Oo]bj
2+
**/[Bb]in
3+
**/[Ll]ogs
4+
TestResults/
5+
.nuget/
6+
_ReSharper.*/
7+
packages/
8+
artifacts/
9+
PublishProfiles/
10+
*.user
11+
*.suo
12+
*.cache
13+
*.docstates
14+
_ReSharper.*
15+
nuget.exe
16+
*net45.csproj
17+
*k10.csproj
18+
*.psess
19+
*.vsp
20+
*.pidb
21+
*.userprefs
22+
*DS_Store
23+
*.ncrunchsolution
24+
*.*sdf
25+
*.ipch
26+
.vs/

src/apps/apigateway.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
22

3-
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
3+
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
44
WORKDIR /app
55
EXPOSE 80
66
EXPOSE 443
77

8-
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
8+
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build-env
99
WORKDIR /src
1010

1111
COPY ["api-gateway/Genocs.APIGateway", "Genocs.APIGateway/"]

src/apps/docker-compose.override.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.9'
2-
31
services:
42
api-gateway:
53
build:

src/apps/docker-compose.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.9'
2-
31
services:
42
api-gateway:
53
image: genocs/apigateway:${IMAGE_VERSION}
@@ -22,7 +20,7 @@ services:
2220
environment:
2321
- ASPNETCORE_ENVIRONMENT=Docker
2422
ports:
25-
- 5501:80
23+
- 5500:80
2624
networks:
2725
- genocs
2826
# network_mode: bridge
@@ -36,7 +34,7 @@ services:
3634
environment:
3735
- ASPNETCORE_ENVIRONMENT=Docker
3836
ports:
39-
- 5502:80
37+
- 5510:80
4038
#ports:
4139
networks:
4240
- genocs
@@ -51,7 +49,7 @@ services:
5149
environment:
5250
- ASPNETCORE_ENVIRONMENT=Docker
5351
ports:
54-
- 5503:80
52+
- 5530:80
5553
#ports:
5654
networks:
5755
- genocs
@@ -66,7 +64,7 @@ services:
6664
environment:
6765
- ASPNETCORE_ENVIRONMENT=Docker
6866
ports:
69-
- 5504:80
67+
- 5540:80
7068
#ports:
7169
networks:
7270
- genocs

src/apps/identity-webapi.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
22

3-
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
3+
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
44
WORKDIR /app
55
EXPOSE 80
66
EXPOSE 443
77

8-
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
8+
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build-env
99
WORKDIR /src
1010
COPY ["identity/Genocs.Identities.WebApi", "Genocs.Identities.WebApi/"]
1111
COPY ["identity/Genocs.Identities.Application", "Genocs.Identities.Application/"]

src/apps/identity/Genocs.Identities.Application/Genocs.Identities.Application.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
1010
<ProjectReference Include="..\..\..\Genocs.Auth\Genocs.Auth.csproj" />
11+
<ProjectReference Include="..\..\..\Genocs.LoadBalancing.Fabio\Genocs.LoadBalancing.Fabio.csproj" />
1112
<ProjectReference Include="..\..\..\Genocs.Persistence.Redis\Genocs.Persistence.Redis.csproj" />
1213
<ProjectReference Include="..\..\..\Genocs.HTTP\Genocs.HTTP.csproj" />
1314
<ProjectReference Include="..\..\..\Genocs.MessageBrokers.Outbox.MongoDB\Genocs.MessageBrokers.Outbox.MongoDB.csproj" />
@@ -21,6 +22,7 @@
2122

2223
<ItemGroup Condition="'$(Configuration)' == 'Release'">
2324
<PackageReference Include="Genocs.Auth" Version="7.0.0" />
25+
<PackageReference Include="Genocs.LoadBalancing.Fabio" Version="7.0.0" />
2426
<PackageReference Include="Genocs.Persistence.Redis" Version="7.0.0" />
2527
<PackageReference Include="Genocs.HTTP" Version="7.0.0" />
2628
<PackageReference Include="Genocs.MessageBrokers.Outbox.MongoDB" Version="7.0.0" />

src/apps/identity/Genocs.Identities.WebApi/Genocs.Identities.WebApi.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13+
<ProjectReference Include="..\..\..\Genocs.Discovery.Consul\Genocs.Discovery.Consul.csproj" />
1314
<ProjectReference Include="..\Genocs.Identities.Application\Genocs.Identities.Application.csproj" />
1415
</ItemGroup>
1516

0 commit comments

Comments
 (0)