feat: add docker healthcheck to dokku container

The official dokku/dokku image gains a HEALTHCHECK directive backed by a loopback-only HTTP endpoint at `127.0.0.1:18080/_dokku/health`. The endpoint reports 200 once first-boot bootstrap finishes, sshd and nginx are accepting connections, and `dokku ps:restore` completes; otherwise it returns 503. Changes are scoped to the Docker overlay and Dockerfile so debian-package installs are unaffected.
This commit is contained in:
Jose Diaz-Gonzalez
2026-05-10 21:17:09 -04:00
parent a553f04966
commit cc0843391f
5 changed files with 60 additions and 3 deletions

View File

@@ -35,6 +35,9 @@ main() {
support-userns
rm -f /var/run/dokku/ready
mkdir -p /var/run/dokku
if [[ ! -d /mnt/dokku ]]; then
log-info "Creating missing /mnt/dokku"
mkdir -p /mnt/dokku

View File

@@ -0,0 +1,16 @@
# Internal health endpoint for the official dokku/dokku Docker image.
# Bound to loopback so it is reachable only from inside the container
# and never conflicts with user app vhosts on 80/443.
server {
listen 127.0.0.1:18080;
server_name _;
access_log off;
default_type text/plain;
location = /_dokku/health {
if (-f /var/run/dokku/ready) {
return 200 "ok\n";
}
return 503 "not ready\n";
}
}

View File

@@ -10,6 +10,10 @@ if [[ "$1" -ne 0 ]]; then
fi
echo "Done restoring dokku apps."
exec sleep infinity
exit 0
while ! (echo > /dev/tcp/127.0.0.1/22) >/dev/null 2>&1; do sleep 1; done
while ! (echo > /dev/tcp/127.0.0.1/80) >/dev/null 2>&1; do sleep 1; done
touch /var/run/dokku/ready
echo "Dokku is ready."
exec sleep infinity