hapifhir / hapi-fhir-jpaserver-starter

Apache License 2.0
379 stars 1.02k forks source link

Unable to Perform Health Checks with Hapi FHIR in Docker Swarm #646

Open brett-onions opened 7 months ago

brett-onions commented 7 months ago

Issue Description: We are currently using Hapi Fhir (specifically the Hapi Fhir Starter) within Docker Swarm to manage our services. Our objective is to conduct health checks to monitor the current state of the service. Hapi FHIR provides a designated endpoint for health checks at /actuator/health, which we intend to utilize for this purpose.

However, we encountered a challenge while attempting to implement this. Our preference was to utilize the official image hapiproject/hapi. Regrettably, we encountered difficulty performing curl or wget commands to access the health check endpoint due to the absence of these applications within the image.

//docker-compose.yaml

healthcheck:
      test: /bin/curl --no-verbose --tries=1 --spider http://localhost:8080/actuator/health
      interval: 30s
      timeout: 5s
      retries: 5
      start_period: 2m

I seeking guidance on how to effectively conduct the health check without resorting to the creation of a separate image solely for the installation of curl or wget.

jkiddo commented 5 months ago

@brett-onions which version of HAPI FHIR starter are you using?

brett-onions commented 5 months ago

@jkiddo I am using Hapi FHIR v7.0.3

jkiddo commented 5 months ago

@brett-onions I think you got the hostname wrong. If you wan't to use e.g. curl in a separate container that queries the HAPI FHIR container then you need to use the service name as hostname. If I start up a regular HAPI FHIR starter using e.g. docker run -p 8080:8080 hapiproject/hapi:latest then I can invoke curl http://localhost:8080/actuator/health with success. If I where to do it in e.g. a docker compose/swarm setting then the curl command would be e.g. curl http://<service-name>:8080/actuator/health