mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
perf(docker): cut healthy wait from 5 s to 0.1 s (#5447)
* perf(docker): cut healthy wait from 5 s to 0.1 s * fix(docker): wait up to 5 s for ready hooks before reporting healthy * fix(docker): build without pulling a Dockerfile frontend from Docker Hub
This commit is contained in:
1 parent
4e769484df
commit
cc129007e4
7 files changed
+36
-14
No files matched your search
+6
-4
@@ -23,7 +23,7 @@ ENV AWS_SECRET_ACCESS_KEY=test
|
||||
ENV 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-app
|
||||
|
||||
COPY --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 6397
|
||||
EXPOSE 6398
|
||||
EXPOSE 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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -22,7 +22,7 @@ ENV AWS_SECRET_ACCESS_KEY=test
|
||||
ENV 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-app
|
||||
|
||||
COPY --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 6397
|
||||
EXPOSE 6398
|
||||
EXPOSE 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.
|
||||
|
||||
@@ -36,7 +36,10 @@ VOLUME /app/data
|
||||
|
||||
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"]
|
||||
|
||||
ARG VERSION=latest
|
||||
ENV FLOCI_VERSION=${VERSION}
|
||||
|
||||
@@ -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.
|
||||
|
||||
+11
-3
@@ -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 ))
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user