dockerdocker-compose

Why is my service not getting started when added depends on, in docker compose file


angulargenerator service is not getting started even when eurekaserver is UP.

services:

  eurekaserver:
    image: clay404/eurekaserver:v1
    container_name: eurekaserver
    ports:
      - "8070:8070"
    healthcheck:
      test: "curl --fail --silent localhost:8070/actuator/health/readiness | grep UP || exit 1"
      interval: 20s
      timeout: 5s
      retries: 20
      start_period: 10s
    deploy:
      resources:
        limits:
          memory: 700m
    networks:
      - archworker

  angulargenerator:
    image: clay404/angulargenerator:v1
    container_name: angulargenerator
    ports:
      - "9081:9081"
    deploy:
      resources:
        limits:
          memory: 700m
    depends_on:
      eurekaserver:
        condition: service_healthy
    networks:
      - archworker

networks:
  archworker:
    driver: "bridge"

This is returning status UP

curl --fail --silent localhost:8070/actuator/health/readiness | grep UP

if i remove depends on in angulargenerator, both gets started at the same time, which i dont want, i want angulargenerator to wait for eurekaserver to be healthy

This is my properties file of eurekaserver

spring.application.name=eurekaserver

server.port=8070

eureka.instance.hostname=localhost
eureka.client.fetchRegistry=false
eureka.client.registerWithEureka=false
eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/


management.endpoints.web.exposure.include=*
management.health.readiness-state.enabled=true
management.health.liveness-state.enabled=true
management.endpoint.health.probes.enabled=true

and properties of angular

spring.application.name=angulargenerator

server.port=9081

eureka.instance.prefer-ip-address=true
eureka.client.fetchRegistry=true
eureka.client.registerWithEureka=true
eureka.client.serviceUrl.defaultZone=http://localhost:8070/eureka/

management.info.env.enabled=true
management.endpoints.web.exposure.include=*
management.endpoint.shutdown.enabled=true

info.app.name=angulargenerator
info.app.description=This is a sample application for generating Angular microservice
info.app.version=1.0.0


Solution

  • I found the solution Curl was not installed in my image so had to install it.

    FROM openjdk:17-jdk-slim
    
    MAINTAINER shahbytes.com
    
    # Install curl and wget
    RUN apt-get update && apt-get install -y curl wget && apt-get clean && rm -rf /var/lib/apt/lists/*
    
    COPY target/eurekaserver-0.0.1-SNAPSHOT.jar eurekaserver-0.0.1-SNAPSHOT.jar
    
    ENTRYPOINT ["java","-jar","eurekaserver-0.0.1-SNAPSHOT.jar"]