Browse Source

Add /health endpoint for container health checks

- Add GET /health endpoint returning 'rackpeek' text
- Update Docker Compose examples with healthcheck configuration
- Update install-guide.md with healthcheck example
- Update git-integration.md with --health-cmd flags
- Eliminates need for curl install in container for health monitoring
Tim Jones 13 hours ago
parent
commit
e791223db4

+ 5 - 0
README.md

@@ -52,6 +52,11 @@ services:
     volumes:
       - rackpeek-config:/app/config
     restart: unless-stopped
+    healthcheck:
+      test: ["CMD-SHELL", "curl -s http://localhost:8080 | grep -q 'rackpeek' || exit 1"]
+      interval: 30s
+      timeout: 10s
+      retries: 3
 
 volumes:
   rackpeek-config:

+ 2 - 0
RackPeek.Web/Api/InventoryEndpoints.cs

@@ -5,6 +5,8 @@ namespace RackPeek.Web.Api;
 
 public static class InventoryEndpoints {
     public static void MapInventoryApi(this WebApplication app) {
+        app.MapGet("/health", () => Results.Content("rackpeek", "text/plain"))
+            .DisableAntiforgery();
         app.MapPost("/api/inventory",
                 async (ImportYamlRequest request,
                     UpsertInventoryUseCase useCase) => {

+ 14 - 0
Shared.Rcl/wwwroot/raw_docs/git-integration.md

@@ -41,4 +41,18 @@ docker run -d \
   aptacode/rackpeek:latest
 ```
 
+Or with health check:
+
+```bash
+docker run -d \
+  --name rackpeek \
+  -p 8080:8080 \
+  -v rackpeek-config:/app/config \
+  --health-cmd="curl -s http://localhost:8080 | grep -q 'rackpeek'" \
+  --health-interval=30s \
+  --health-timeout=10s \
+  --health-retries=3 \
+  aptacode/rackpeek:latest
+```
+
 Open RackPeek in the browser, enable Git when prompted, then add the repository remote URL. RackPeek will commit and sync configuration changes automatically.

+ 5 - 0
Shared.Rcl/wwwroot/raw_docs/install-guide.md

@@ -33,6 +33,11 @@ services:
     volumes:
       - rackpeek-config:/app/config
     restart: unless-stopped
+    healthcheck:
+      test: ["CMD-SHELL", "curl -s http://localhost:8080 | grep -q 'rackpeek' || exit 1"]
+      interval: 30s
+      timeout: 10s
+      retries: 3
 
 volumes:
   rackpeek-config: