Light, fluffy, and always free - The AWS Local Emulator alternative
perf(docker): cut healthy wait from 5 s to 0.1 s (#5447)
TATSUNO “Taz” Yasuhirocc129007e4c4
diff --git a/docker/Dockerfile b/docker/Dockerfileindex 2976bc97df..354de752cc 100644--- a/docker/Dockerfile+++ b/docker/Dockerfile@@ -23,7 +23,7 @@ ENV AWS_SECRET_ACCESS_KEY=testENV AWS_CONFIG_FILE=/etc/floci/aws/config# Privilege drop happens in the entrypoint through coreutils chroot, so no gosu-# download; wget stays for the HEALTHCHECK below.+# download.RUN set -eux; \apt-get update; \apt-get install -y --no-install-recommends ca-certificates passwd python3 python3-pip wget; \@@ -52,7 +52,7 @@ COPY --from=build /build/target/quarkus-app/ quarkus-app/RUN chown -R 1001:root /app/quarkus-appCOPY --chmod=755 docker/entrypoint.sh /usr/local/bin/docker-entrypoint.sh-COPY --chmod=755 docker/localstack-parity.sh /usr/local/bin/localstack-parity.sh+COPY --chmod=755 docker/localstack-parity.sh docker/healthcheck.sh /usr/local/bin/VOLUME /app/data@@ -82,8 +82,10 @@ EXPOSE 6397EXPOSE 6398EXPOSE 6399-HEALTHCHECK --interval=5s --timeout=3s --retries=5 \- CMD wget -q --spider http://localhost:4566/_floci/health || exit 1+# Probe every 50 ms while Floci starts, so a wait for "healthy" ends right after startup instead of+# at the first 5 s check. The start period must stay above the 5 s fallback in healthcheck.sh.+# Docker Engine before 25.0 ignores --start-interval when it runs the image, and cannot build this file.+HEALTHCHECK --interval=5s --timeout=3s --retries=5 --start-period=10s --start-interval=50ms CMD ["/usr/local/bin/healthcheck.sh"]ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]# A published port needs 0.0.0.0 inside the container, which Floci only accepts with explicit consent.diff --git a/docker/Dockerfile.compat b/docker/Dockerfile.compatindex e7e4ba730b..3819bffa93 100644--- a/docker/Dockerfile.compat+++ b/docker/Dockerfile.compat@@ -112,7 +112,10 @@ COPY --chmod=755 docker/healthcheck.sh /usr/local/bin/EXPOSE 4566-HEALTHCHECK --interval=5s --timeout=3s --retries=5 CMD ["/usr/local/bin/healthcheck.sh"]+# Probe every 50 ms while Floci starts, so a wait for "healthy" ends right after startup instead of+# at the first 5 s check. The start period must stay above the 5 s fallback in healthcheck.sh.+# Docker Engine before 25.0 ignores --start-interval when it runs the image, and cannot build this file.+HEALTHCHECK --interval=5s --timeout=3s --retries=5 --start-period=10s --start-interval=50ms CMD ["/usr/local/bin/healthcheck.sh"]ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]# A published port needs 0.0.0.0 inside the container, which Floci only accepts with explicit consent.diff --git a/docker/Dockerfile.jvm-package b/docker/Dockerfile.jvm-packageindex 6dacc19a79..a938c6b803 100644--- a/docker/Dockerfile.jvm-package+++ b/docker/Dockerfile.jvm-package@@ -22,7 +22,7 @@ ENV AWS_SECRET_ACCESS_KEY=testENV AWS_CONFIG_FILE=/etc/floci/aws/config# Privilege drop happens in the entrypoint through coreutils chroot, so no gosu-# download; wget stays for the HEALTHCHECK below.+# download.RUN set -eux; \apt-get update; \apt-get install -y --no-install-recommends ca-certificates passwd python3 python3-pip wget; \@@ -51,7 +51,7 @@ COPY target/quarkus-app/ quarkus-app/RUN chown -R 1001:root /app/quarkus-appCOPY --chmod=755 docker/entrypoint.sh /usr/local/bin/docker-entrypoint.sh-COPY --chmod=755 docker/localstack-parity.sh /usr/local/bin/localstack-parity.sh+COPY --chmod=755 docker/localstack-parity.sh docker/healthcheck.sh /usr/local/bin/VOLUME /app/data@@ -81,8 +81,10 @@ EXPOSE 6397EXPOSE 6398EXPOSE 6399-HEALTHCHECK --interval=5s --timeout=3s --retries=5 \- CMD wget -q --spider http://localhost:4566/_floci/health || exit 1+# Probe every 50 ms while Floci starts, so a wait for "healthy" ends right after startup instead of+# at the first 5 s check. The start period must stay above the 5 s fallback in healthcheck.sh.+# Docker Engine before 25.0 ignores --start-interval when it runs the image, and cannot build this file.+HEALTHCHECK --interval=5s --timeout=3s --retries=5 --start-period=10s --start-interval=50ms CMD ["/usr/local/bin/healthcheck.sh"]ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]# A published port needs 0.0.0.0 inside the container, which Floci only accepts with explicit consent.diff --git a/docker/Dockerfile.native b/docker/Dockerfile.nativeindex 2ddecefae9..51bf9336a1 100644--- a/docker/Dockerfile.native+++ b/docker/Dockerfile.native@@ -36,7 +36,10 @@ VOLUME /app/dataEXPOSE 4566-HEALTHCHECK --interval=5s --timeout=3s --retries=5 CMD ["/usr/local/bin/healthcheck.sh"]+# Probe every 50 ms while Floci starts, so a wait for "healthy" ends right after startup instead of+# at the first 5 s check. The start period must stay above the 5 s fallback in healthcheck.sh.+# Docker Engine before 25.0 ignores --start-interval when it runs the image, and cannot build this file.+HEALTHCHECK --interval=5s --timeout=3s --retries=5 --start-period=10s --start-interval=50ms CMD ["/usr/local/bin/healthcheck.sh"]ARG VERSION=latestENV FLOCI_VERSION=${VERSION}diff --git a/docker/Dockerfile.native-package b/docker/Dockerfile.native-packageindex 00f0968645..804fc8b809 100644--- a/docker/Dockerfile.native-package+++ b/docker/Dockerfile.native-package@@ -45,7 +45,10 @@ LABEL org.opencontainers.image.title="Floci" \EXPOSE 4566-HEALTHCHECK --interval=5s --timeout=3s --retries=5 CMD ["/usr/local/bin/healthcheck.sh"]+# Probe every 50 ms while Floci starts, so a wait for "healthy" ends right after startup instead of+# at the first 5 s check. The start period must stay above the 5 s fallback in healthcheck.sh.+# Docker Engine before 25.0 ignores --start-interval when it runs the image, and cannot build this file.+HEALTHCHECK --interval=5s --timeout=3s --retries=5 --start-period=10s --start-interval=50ms CMD ["/usr/local/bin/healthcheck.sh"]ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]# A published port needs 0.0.0.0 inside the container, which Floci only accepts with explicit consent.diff --git a/docker/healthcheck.sh b/docker/healthcheck.shindex c5487e0934..84e628dd14 100755--- a/docker/healthcheck.sh+++ b/docker/healthcheck.sh@@ -1,6 +1,14 @@#!/bin/bash# Container health probe. Bash only, because ubi9-micro has no curl.exec 3<>/dev/tcp/127.0.0.1/4566 || exit 1-printf 'GET /_floci/health HTTP/1.0\r\nHost: localhost\r\n\r\n' >&3-read -r _proto status _rest <&3-[ "$status" = 200 ]+printf 'GET /_floci/init HTTP/1.0\r\nHost: localhost\r\n\r\n' >&3+IFS= read -r -d '' response <&3+[[ $response == "HTTP/1."?" 200"* ]] || exit 1+[[ $response == *'"ready":true'* ]] && exit 0+# Ready hooks still running. Report healthy 5 s after start anyway, as the first 5 s check always did,+# so a long hook never turns the container unhealthy.+read -r uptime _ < /proc/uptime+stat=$(< /proc/1/stat)+read -ra fields <<< "${stat##*) }"+# Field 22 of /proc/1/stat is the start time in clock ticks, 100 per second like the uptime digits.+(( ${uptime/./} - fields[19] >= 500 ))diff --git a/docs/getting-started/installation.md b/docs/getting-started/installation.mdindex 3eee9e538c..2c02cfda49 100644--- a/docs/getting-started/installation.md+++ b/docs/getting-started/installation.md@@ -58,6 +58,7 @@ Standard and compat have identical startup time (~24 ms) and memory footprint (~- Java 25+- Maven 3.9+- (Optional) GraalVM Mandrel for native compilation+- (Optional) Docker Engine 25.0+ to build the Docker images### Clone and run