Add healthcheck to Dockerfiles

Add healthcheck to hotspot.

Add healthcheck to graalvm.

Add the healthcheck script.
This commit is contained in:
Kavin 2023-08-23 21:00:13 +01:00
parent 63891ae0e2
commit bfdf1a567e
No known key found for this signature in database
GPG Key ID: 6E4598CA5C92C41F
7 changed files with 68 additions and 4 deletions

View File

@ -9,9 +9,17 @@ RUN --mount=type=cache,target=/root/.gradle/caches/ \
FROM eclipse-temurin:17-jre FROM eclipse-temurin:17-jre
RUN --mount=type=cache,target=/var/cache/apt/ \
apt-get update && \
apt-get install -y --no-install-recommends \
curl \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app/ WORKDIR /app/
COPY hotspot-entrypoint.sh / COPY hotspot-entrypoint.sh docker-healthcheck.sh /
COPY --from=build /app/build/libs/piped-1.0-all.jar /app/piped.jar COPY --from=build /app/build/libs/piped-1.0-all.jar /app/piped.jar
@ -19,4 +27,5 @@ COPY VERSION .
EXPOSE 8080 EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 CMD /docker-healthcheck.sh
ENTRYPOINT ["/hotspot-entrypoint.sh"] ENTRYPOINT ["/hotspot-entrypoint.sh"]

View File

@ -9,9 +9,17 @@ RUN --mount=type=cache,target=/root/.gradle/caches/ \
FROM azul/zulu-openjdk:17-jre-headless-latest FROM azul/zulu-openjdk:17-jre-headless-latest
RUN --mount=type=cache,target=/var/cache/apt/ \
apt-get update && \
apt-get install -y --no-install-recommends \
curl \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app/ WORKDIR /app/
COPY hotspot-entrypoint.sh / COPY hotspot-entrypoint.sh docker-healthcheck.sh /
COPY --from=build /app/build/libs/piped-1.0-all.jar /app/piped.jar COPY --from=build /app/build/libs/piped-1.0-all.jar /app/piped.jar
@ -19,4 +27,5 @@ COPY VERSION .
EXPOSE 8080 EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 CMD /docker-healthcheck.sh
ENTRYPOINT ["/hotspot-entrypoint.sh"] ENTRYPOINT ["/hotspot-entrypoint.sh"]

View File

@ -1,8 +1,16 @@
FROM azul/zulu-openjdk:17-jre-headless-latest FROM azul/zulu-openjdk:17-jre-headless-latest
RUN --mount=type=cache,target=/var/cache/apt/ \
apt-get update && \
apt-get install -y --no-install-recommends \
curl \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app/ WORKDIR /app/
COPY hotspot-entrypoint.sh / COPY hotspot-entrypoint.sh docker-healthcheck.sh /
COPY ./piped.jar /app/piped.jar COPY ./piped.jar /app/piped.jar
@ -10,4 +18,5 @@ COPY VERSION .
EXPOSE 8080 EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 CMD /docker-healthcheck.sh
ENTRYPOINT ["/hotspot-entrypoint.sh"] ENTRYPOINT ["/hotspot-entrypoint.sh"]

View File

@ -1,8 +1,16 @@
FROM eclipse-temurin:17-jre FROM eclipse-temurin:17-jre
RUN --mount=type=cache,target=/var/cache/apt/ \
apt-get update && \
apt-get install -y --no-install-recommends \
curl \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app/ WORKDIR /app/
COPY hotspot-entrypoint.sh / COPY hotspot-entrypoint.sh docker-healthcheck.sh /
COPY ./piped.jar /app/piped.jar COPY ./piped.jar /app/piped.jar
@ -10,4 +18,5 @@ COPY VERSION .
EXPOSE 8080 EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 CMD /docker-healthcheck.sh
ENTRYPOINT ["/hotspot-entrypoint.sh"] ENTRYPOINT ["/hotspot-entrypoint.sh"]

View File

@ -17,16 +17,27 @@ RUN jlink \
FROM debian:stable-slim FROM debian:stable-slim
RUN --mount=type=cache,target=/var/cache/apt/ \
apt-get update && \
apt-get install -y --no-install-recommends \
curl \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV JAVA_HOME=/opt/java/openjdk ENV JAVA_HOME=/opt/java/openjdk
ENV PATH "${JAVA_HOME}/bin:${PATH}" ENV PATH "${JAVA_HOME}/bin:${PATH}"
COPY --from=build /javaruntime $JAVA_HOME COPY --from=build /javaruntime $JAVA_HOME
WORKDIR /app/ WORKDIR /app/
COPY docker-healthcheck.sh /
COPY --from=build /app/build/libs/piped-1.0-all.jar /app/piped.jar COPY --from=build /app/build/libs/piped-1.0-all.jar /app/piped.jar
COPY VERSION . COPY VERSION .
EXPOSE 8080 EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 CMD /docker-healthcheck.sh
CMD java -jar /app/piped.jar CMD java -jar /app/piped.jar

View File

@ -10,16 +10,27 @@ RUN jlink \
FROM debian:stable-slim FROM debian:stable-slim
RUN --mount=type=cache,target=/var/cache/apt/ \
apt-get update && \
apt-get install -y --no-install-recommends \
curl \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV JAVA_HOME=/opt/java/openjdk ENV JAVA_HOME=/opt/java/openjdk
ENV PATH "${JAVA_HOME}/bin:${PATH}" ENV PATH "${JAVA_HOME}/bin:${PATH}"
COPY --from=build /javaruntime $JAVA_HOME COPY --from=build /javaruntime $JAVA_HOME
WORKDIR /app/ WORKDIR /app/
COPY docker-healthcheck.sh /
COPY ./piped.jar /app/piped.jar COPY ./piped.jar /app/piped.jar
COPY VERSION . COPY VERSION .
EXPOSE 8080 EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 CMD /docker-healthcheck.sh
CMD java -jar /app/piped.jar CMD java -jar /app/piped.jar

6
docker-healthcheck.sh Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env sh
# If PORT env var is set, use it, otherwise default to 8080
PORT=${PORT:-8080}
curl -f http://localhost:$PORT/healthcheck || exit 1