Browse Source

Merge pull request #279 from Timmoth/feature/268

Add /health endpoint for container health checks
Tim Jones 1 day ago
parent
commit
bdeca08a43

+ 5 - 0
README.md

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

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

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

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

@@ -41,4 +41,18 @@ docker run -d \
   aptacode/rackpeek:latest
   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.
 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:
     volumes:
       - rackpeek-config:/app/config
       - rackpeek-config:/app/config
     restart: unless-stopped
     restart: unless-stopped
+    healthcheck:
+      test: ["CMD-SHELL", "curl -s http://localhost:8080 | grep -q 'rackpeek' || exit 1"]
+      interval: 30s
+      timeout: 10s
+      retries: 3
 
 
 volumes:
 volumes:
   rackpeek-config:
   rackpeek-config: