Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Kamal deployment configuration #3

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ jobs:
- name: Deploy with Kamal
run: |
kamal lock release -v
kamal deploy -P --version latest
kamal deploy -P --version latest
37 changes: 37 additions & 0 deletions MyApp/Configure.HealthChecks.cs
Original file line number Diff line number Diff line change
@@ -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<HealthCheckResult> 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>("HealthCheck");

services.AddTransient<IStartupFilter, StartupFilter>();
});
}

public class StartupFilter : IStartupFilter
{
public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next)
=> app => {
app.UseHealthChecks("/up");
next(app);
};
}
}
5 changes: 0 additions & 5 deletions config/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading