Last active
April 20, 2023 10:53
-
-
Save radimih/e16c0e4d1b15f1ee2e77c420e35362ab to your computer and use it in GitHub Desktop.
Spring Boot Actuator based Docker HEALTHCHECK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM openjdk:11-jre-slim | |
EXPOSE 8080 | |
ENV TZ=Europe/Moscow | |
RUN adduser --system --group --home /opt/app appuser | |
RUN apt-get update \ | |
&& apt-get install -y --no-install-recommends curl jq \ | |
&& rm -rf /var/lib/apt/lists/* | |
ARG JAR_FILE=target/*.jar | |
COPY --chown=appuser:appuser ${JAR_FILE} /opt/app/application.jar | |
USER appuser | |
WORKDIR /opt/app | |
ENTRYPOINT ["java", "-jar", "/opt/app/application.jar"] | |
HEALTHCHECK --start-period=30s --interval=30s --timeout=3s --retries=3 \ | |
CMD curl --silent --fail --request GET http://localhost:8080/actuator/health \ | |
| jq --exit-status '.status == "UP"' || exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it's work for me!
test : curl -m 5 --silent --fail --request GET http://localhost:8080/actuator/health | jq --exit-status -n 'inputs | if has("status") then .status=="UP" else false end' > /dev/null || exit 1