From c22204e2aeaf121d117a8cc3564b5b88b7f4ba87 Mon Sep 17 00:00:00 2001 From: Abdelkader Boudih Date: Thu, 18 Sep 2025 13:47:25 +0100 Subject: [PATCH 1/2] Add healthcheck to Docker images Add HEALTHCHECK instructions to both Dockerfile and Dockerfile.rootless using the existing /api/healthz endpoint to monitor service health. --- Dockerfile | 3 +++ Dockerfile.rootless | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Dockerfile b/Dockerfile index 78a556497a6c0..f0b45cc4a6755 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,6 +46,9 @@ LABEL maintainer="maintainers@gitea.io" EXPOSE 22 3000 +HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ + CMD curl -f http://localhost:3000/api/healthz || exit 1 + RUN apk --no-cache add \ bash \ ca-certificates \ diff --git a/Dockerfile.rootless b/Dockerfile.rootless index e83c1af33b90d..89f71ab25fc40 100644 --- a/Dockerfile.rootless +++ b/Dockerfile.rootless @@ -44,6 +44,9 @@ LABEL maintainer="maintainers@gitea.io" EXPOSE 2222 3000 +HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ + CMD curl -f http://localhost:3000/api/healthz || exit 1 + RUN apk --no-cache add \ bash \ ca-certificates \ From 287a49a67ad272aef60f352887e863a1aec515d4 Mon Sep 17 00:00:00 2001 From: Abdelkader Boudih Date: Thu, 18 Sep 2025 17:16:37 +0100 Subject: [PATCH 2/2] Add Docker healthcheck with migration-friendly timings Add HEALTHCHECK instruction to monitor Gitea service health using the /api/healthz endpoint. Configured with: - interval: 2m (check every 2 minutes, Gitea isn't that sensitive) - start-period: 2m (allows time for migrations during upgrades) - timeout: 10s - retries: 3 This helps container orchestrators detect and restart unhealthy instances while avoiding restarts during normal startup or database migrations. --- Dockerfile | 2 +- Dockerfile.rootless | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index f0b45cc4a6755..a380f5c80763f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,7 +46,7 @@ LABEL maintainer="maintainers@gitea.io" EXPOSE 22 3000 -HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ +HEALTHCHECK --interval=2m --timeout=10s --start-period=2m --retries=3 \ CMD curl -f http://localhost:3000/api/healthz || exit 1 RUN apk --no-cache add \ diff --git a/Dockerfile.rootless b/Dockerfile.rootless index 89f71ab25fc40..59a5529b61819 100644 --- a/Dockerfile.rootless +++ b/Dockerfile.rootless @@ -44,7 +44,7 @@ LABEL maintainer="maintainers@gitea.io" EXPOSE 2222 3000 -HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ +HEALTHCHECK --interval=2m --timeout=10s --start-period=2m --retries=3 \ CMD curl -f http://localhost:3000/api/healthz || exit 1 RUN apk --no-cache add \