diff --git a/.github/workflows/build-container.yml b/.github/workflows/build-container.yml index 82925e1..66130ac 100644 --- a/.github/workflows/build-container.yml +++ b/.github/workflows/build-container.yml @@ -7,6 +7,9 @@ on: workflows: ["Build"] types: - completed + branches: + - main + - master workflow_dispatch: env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c85c4a6..3ec7198 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,6 +10,9 @@ on: - master types: - completed + branches: + - main + - master workflow_dispatch: env: 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 56e655c..2bab8a4 100644 --- a/config/deploy.yml +++ b/config/deploy.yml @@ -4,6 +4,10 @@ service: my-app # Name of the container image. image: my-user/myapp +# Required for use of ASP.NET Core with Kamal-Proxy. +env: + ASPNETCORE_FORWARDEDHEADERS_ENABLED: true + # Deploy to these servers. servers: # IP address of server, optionally use env variable. @@ -21,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