From 5df60cb11f0b6606b5e54d5c1f00db331bb57323 Mon Sep 17 00:00:00 2001 From: Darren Reid Date: Tue, 26 Nov 2024 16:41:33 +1100 Subject: [PATCH 1/2] feat: add Kamal deployment configuration --- MyApp/Configure.HealthChecks.cs | 37 +++++++++++++++++++++++++++++++++ config/deploy.yml | 5 ----- 2 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 MyApp/Configure.HealthChecks.cs diff --git a/MyApp/Configure.HealthChecks.cs b/MyApp/Configure.HealthChecks.cs new file mode 100644 index 0000000..dbbb700 --- /dev/null +++ b/MyApp/Configure.HealthChecks.cs @@ -0,0 +1,37 @@ +using Microsoft.Extensions.Diagnostics.HealthChecks; + +[assembly: HostingStartup(typeof(MyApp.HealthChecks))] + +namespace MyApp; + +public class HealthChecks : IHostingStartup +{ + public class HealthCheck : IHealthCheck + { + public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken token = default) + { + // Perform health check logic here + return HealthCheckResult.Healthy(); + } + } + + public void Configure(IWebHostBuilder builder) + { + builder.ConfigureServices(services => + { + services.AddHealthChecks() + .AddCheck("HealthCheck"); + + services.AddTransient(); + }); + } + + public class StartupFilter : IStartupFilter + { + public Action Configure(Action next) + => app => { + app.UseHealthChecks("/up"); + next(app); + }; + } +} \ No newline at end of file diff --git a/config/deploy.yml b/config/deploy.yml index f3143af..2bab8a4 100644 --- a/config/deploy.yml +++ b/config/deploy.yml @@ -25,11 +25,6 @@ proxy: # kamal-proxy connects to your container over port 80, use `app_port` to specify a different port. app_port: 8080 - healthcheck: - interval: 3 - path: /metadata - timeout: 3 - # Credentials for your image host. registry: # Specify the registry server, if you're not using Docker Hub From 6a0597190ea1f35f7c11667afba855e50a053216 Mon Sep 17 00:00:00 2001 From: Darren Reid Date: Tue, 26 Nov 2024 17:06:57 +1100 Subject: [PATCH 2/2] Update workflows --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7f5dcd2..a2dd9ca 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -101,4 +101,4 @@ jobs: - name: Deploy with Kamal run: | kamal lock release -v - kamal deploy -P --version latest \ No newline at end of file + kamal deploy -P --version latest