Skip to content

feat: Add /healthz/live and /healthz/ready health check endpoints#25

Merged
jthomperoo merged 3 commits intomainfrom
copilot/feature-define-healthcheck
Mar 23, 2026
Merged

feat: Add /healthz/live and /healthz/ready health check endpoints#25
jthomperoo merged 3 commits intomainfrom
copilot/feature-define-healthcheck

Conversation

Copy link
Contributor

Copilot AI commented Mar 22, 2026

The Docker image lacked both health check tooling (curl/wget) and a HEALTHCHECK instruction, making it impossible for orchestrators to determine service readiness without custom workarounds.

Changes

  • Program.cs — Registers ASP.NET Core built-in health checks and maps two endpoints:

    • GET /healthz/live — liveness probe (app process is running; never checks external dependencies)
    • GET /healthz/ready — readiness probe (app is ready to serve requests; additionally verifies SQLite database connectivity when Database.SqliteFile is configured)
  • Dockerfile — Installs curl in the runtime stage; adds HEALTHCHECK using it:

    HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
        CMD curl -f http://localhost:${DevOidcToolkit__Port}/healthz/live || exit 1
  • DevOidcToolkit.csproj — Adds Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore to support AddDbContextCheck.

  • Docs — New health-checks.md page covering endpoint reference, the liveness/readiness distinction, database check behaviour, and a Docker Compose depends_on: condition: service_healthy example; linked from the docs index and README features list.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature] Define HEALTHCHECK</issue_title>
<issue_description>### Feature description

The image doesn't have curl or wget to ping the server with. Please define a HEALTHCHECK in the Dockerfile that works with the programs available on the image.

Motivation

So other services can wait for this service to be healthy before starting.

Alternatives considered

I tried writing my own in docker-compose.yml. Looking in /bin, the only obvious program that could be used to write my own health check is perl, and I did not want to spend my time doing that. Probably you as the developer have a better idea of what counts as health in any case.</issue_description>

<agent_instructions>Add /healthz/live and /healthz/ready endpoints

https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks?view=aspnetcore-10.0

Add curl to the runtime docker container, set up HEALTHCHECK using it.

Document this in the README and user docs.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] Add HEALTHCHECK to Dockerfile for service health monitoring feat: Add /healthz/live and /healthz/ready health check endpoints Mar 22, 2026
Copilot AI requested a review from jthomperoo March 22, 2026 08:46
Copy link
Member

@jthomperoo jthomperoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not have ready check DB is reachable? I'm aware it's just SQLite supported, but if SQLite is set up should we not check it's available and reachable?

Copy link
Contributor Author

Copilot AI commented Mar 22, 2026

Should we not have ready check DB is reachable? I'm aware it's just SQLite supported, but if SQLite is set up should we not check it's available and reachable?

Done in 460b394. When Database.SqliteFile is set, AddDbContextCheck<DevOidcToolkitContext> is registered with a "ready" tag so /healthz/ready verifies DB connectivity while /healthz/live remains a pure process-up check. When the in-memory database is used, both endpoints behave identically.

Copilot AI requested a review from jthomperoo March 22, 2026 14:08
@jthomperoo jthomperoo marked this pull request as ready for review March 23, 2026 07:30
Copy link
Member

@jthomperoo jthomperoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jthomperoo jthomperoo merged commit d340e98 into main Mar 23, 2026
7 checks passed
@jthomperoo jthomperoo deleted the copilot/feature-define-healthcheck branch March 23, 2026 07:31
@rainhead
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Define HEALTHCHECK

3 participants