I deploy container generated by spring-boot:build-image to AWS ECS and I want to enable health check:
healthCheck = {
command = [
"CMD-SHELL",
"curl --fail --silent http://localhost:8080/actuator/health || exit 1",
]
interval = 5
retries = 2
startPeriod = 60
timeout = 5
}
Problem is that image does not contain curl command so health check is failing.
I had to create new image add install curl
as is described here: https://stackoverflow.com/questions/62484649/how-to-add-extra-linux-dependencies-into-a-spring-boot-buildpack-image/70858933#70858933
I think that curl
(or some other mechanism to do health-check) should be provided in container out of the box.
Comment From: snicoll
Thanks for the report but that's not something Spring Boot could do. spring-boot-build-image
relies on Packeto that determines what gets shipped in the container. If you want to pursue this, please raise an issue on the Packeto issue tracker.
Comment From: scottfrederick
@bassmake The set of packages available in the built image is dependent on the CNB run image that is used. By default, Spring Boot uses the Paketo builder paketobuildpacks/builder:base
, which includes the paketobuildpacks/run:base-cnb
run image. Paketo provides other builder and run images that you can configure the Spring Boot plugins to use. You can try using the paketobuildpacks/builder:full
builder instead of the default to see if the paketobuildpacks/run:full-cnb
run image includes curl
. If it doesn't, there is some Paketo documentation on creating a custom stack.
Comment From: ghost
Thank you @scottfrederick, I understand that I can create custom stack. But the point is that image built by spring boot plugin does not provide tools to do health check on endpoint provided by spring boot actuator.
Or what is the recommended way to implement health check for image built by spring boot maven plugin?
Comment From: scottfrederick
@bassmake My apologies, I completely missed the part of your original question where you stated that you'd created a custom run image.
I think it is unusual to implement a health check by running a command in the container that the application is running in. Spring Boot has implemented features like liveness and readiness probes to give processes outside the container a way to inspect the health of the container, and provides recommendations on how these probes can be used.
Comment From: ghost
@scottfrederick Probes are related to Kubernetes and external health checks in general. But I would like to have container health checks enabled as well: - https://aws.amazon.com/about-aws/whats-new/2018/03/amazon-ecs-supports-container-health-checks-and-task-health-mana/ - https://docs.docker.com/engine/reference/run/#healthcheck