Skip to content

Commit 210aeea

Browse files
committed
Add docker healthcheck support
1 parent 4dc5f74 commit 210aeea

File tree

7 files changed

+14
-3
lines changed

7 files changed

+14
-3
lines changed

Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,8 @@ VOLUME ["/etc/pokertime"]
5757
# Set some defaults for a "direct run" experience
5858
ENV DATABASE__DATABASE "/app/data.db"
5959
ENV DATABASE__DATABASEPROVIDER Sqlite
60+
61+
# ... health check
62+
HEALTHCHECK CMD curl --fail http://localhost/health || exit
63+
6064
ENTRYPOINT [ "./launch", "run" ]

distscripts/ubuntu/launch

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function run {
1313

1414
echo Starting application
1515
cd $POKERTIME_APP_DIR
16-
./PokerTime.Web
16+
exec ./PokerTime.Web
1717

1818
exit $?
1919
}

src/PokerTime.Persistence/PokerTime.Persistence.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" />
1717
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.3" />
1818
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.3" />
19+
20+
<!-- Health checks for Docker -->
21+
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="3.1.3"/>
1922
</ItemGroup>
2023

2124
<ItemGroup>

src/PokerTime.Persistence/ServiceCollectionExtensions.cs

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public static IServiceCollection AddPersistence(this IServiceCollection services
1919
services.ChainInterfaceImplementation<IEntityStateFacilitator, PokerTimeDbContext>();
2020
services.ChainInterfaceImplementation<IPokerTimeDbContextFactory, PokerTimeDbContext>();
2121

22+
services.AddHealthChecks().AddDbContextCheck<PokerTimeDbContext>();
23+
2224
return services;
2325
}
2426
}

src/PokerTime.Web/PokerTime.Web.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<PropertyGroup>
33
<KeepOutputPath>True</KeepOutputPath>
44
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>

src/PokerTime.Web/Startup.cs

+2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF
9393
app.UseRouting();
9494

9595
app.UseEndpoints(endpoints => {
96+
endpoints.MapHealthChecks("/health");
97+
9698
endpoints.MapBlazorHub();
9799

98100
endpoints.MapFallbackToPage("/_Host");

utils/install-app-prereqs.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ function ensure_success {
1010

1111
echo "Installing app prerequisites..."
1212
apt-get -qqy update
13-
apt-get -qqy install libgdiplus
13+
apt-get -qqy install libgdiplus curl
1414
ensure_success

0 commit comments

Comments
 (0)