hyness / spring-cloud-config-server

Docker build of the spring-cloud-config-server
Apache License 2.0
74 stars 54 forks source link

Doesn't clear how to use health check #113

Closed kamorozov closed 1 year ago

kamorozov commented 1 year ago

Hi!

I want to add health check for docker container, but container doesn't have curl and I don't know how to add.

My implementation:

Dockerfile:

FROM hyness/spring-cloud-config-server:4.0

HEALTHCHECK CMD curl --fail http://localhost:8888/actuator/health || exit 1 

COPY application.yml /config/

docker-compose:

version: '3'
services:
  config-server:
    platform: linux/amd64
    container_name: config-server
    build:
      dockerfile: Dockerfile
      context: .
    ports:
      - "8888:8888"
    environment:
      SPRING_CLOUD_CONFIG_SERVER_GIT_URI: ${REPO_URL}
      SPRING_CLOUD_CONFIG_SERVER_GIT_DEFAULTLABEL: ${BRANCH_NAME:-master}
      MANAGEMENT_ENDPOINT_PROMETHEUS_ENABLED: true
      MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE: "*"
    command:
      - --spring.cloud.config.server.git.search-paths=${STAND_NAME:-dev}
    healthcheck:
      test: curl --fail http://localhost:8888/actuator/health || exit 1
      interval: 60s
      retries: 5
      start_period: 30s
      timeout: 10s
image
hyness commented 1 year ago

Hello @kamorozov,

This project now uses Cloud Native Buildpacks provided by Spring Boot to build a distroless image which is much more secure than the previous images this project previously provided. It's not possible AFAIK to add packages. I'm not sure of your use case that requires the healthcheck to be checked inside the same container. It should be very straightforward to add another container with curl to check the healthcheck since it's a url that can be called from another container. You wouldn't even need to publicly expose the healthcheck to do this. However, if you must, you could look through the history and find the Dockerfiles this project used to use to build the project, fork this project and use them to build custom images for yourself

EDIT: Perhaps I misread your issue, and you are trying to use the healthcheck feature of Docker Compose. This is unnecessary for this image. Spring Cloud Config Server is already integrated with it's own internal healthcheck and will not run the container in an unhealthy state. The answer remains the same as we cannot support this feature