Skip to content

Commit

Permalink
Add docker healthcheck support
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebazzz committed Mar 28, 2020
1 parent 4dc5f74 commit 210aeea
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,8 @@ VOLUME ["/etc/pokertime"]
# Set some defaults for a "direct run" experience
ENV DATABASE__DATABASE "/app/data.db"
ENV DATABASE__DATABASEPROVIDER Sqlite

# ... health check
HEALTHCHECK CMD curl --fail http://localhost/health || exit

ENTRYPOINT [ "./launch", "run" ]
2 changes: 1 addition & 1 deletion distscripts/ubuntu/launch
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function run {

echo Starting application
cd $POKERTIME_APP_DIR
./PokerTime.Web
exec ./PokerTime.Web

exit $?
}
Expand Down
3 changes: 3 additions & 0 deletions src/PokerTime.Persistence/PokerTime.Persistence.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.3" />

<!-- Health checks for Docker -->
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="3.1.3"/>
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/PokerTime.Persistence/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public static IServiceCollection AddPersistence(this IServiceCollection services
services.ChainInterfaceImplementation<IEntityStateFacilitator, PokerTimeDbContext>();
services.ChainInterfaceImplementation<IPokerTimeDbContextFactory, PokerTimeDbContext>();

services.AddHealthChecks().AddDbContextCheck<PokerTimeDbContext>();

return services;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/PokerTime.Web/PokerTime.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<KeepOutputPath>True</KeepOutputPath>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
Expand Down
2 changes: 2 additions & 0 deletions src/PokerTime.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF
app.UseRouting();

app.UseEndpoints(endpoints => {
endpoints.MapHealthChecks("/health");

endpoints.MapBlazorHub();

endpoints.MapFallbackToPage("/_Host");
Expand Down
2 changes: 1 addition & 1 deletion utils/install-app-prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ function ensure_success {

echo "Installing app prerequisites..."
apt-get -qqy update
apt-get -qqy install libgdiplus
apt-get -qqy install libgdiplus curl
ensure_success

0 comments on commit 210aeea

Please sign in to comment.