Creating spring boot micro-service with config server.
There are 3 services currently:
- config server
- post service
- user service
Issue is config server is able to start properly but the post and user service can’t.
The following is docker-compose.yml
file:
version: '3.8'
services:
rabbit:
image: rabbitmq:3.12-management
hostname: rabbitmq
ports:
- "5672:5672"
- "15672:15672"
healthcheck:
test: rabbitmq-diagnostics check_port_connectivity
interval: 10s
timeout: 5s
retries: 10
start_period: 5s
networks:
- app-network
postgres:
image: postgres:latest
container_name: postgres
ports:
- "5431:5432"
environment:
POSTGRES_DB: blog
POSTGRES_USER: postgresuser
POSTGRES_PASSWORD: postgrespassword
deploy:
resources:
limits:
memory: 512m
volumes:
- ~/volume/userservice-postgres/data:/var/lib/postgresql/data
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
networks:
- app-network
configserver:
image: example/configserver
container_name: configserver
ports:
- "8071:8071"
deploy:
resources:
limits:
memory: 700m
depends_on:
rabbit:
condition: service_healthy
healthcheck:
test: "curl --fail --silent http://localhost:8071/actuator/health/readiness | grep UP || exit 1"
interval: 10s
timeout: 5s
retries: 10
start_period: 20s
networks:
- app-network
userservice:
image: example/userservice
container_name: userservice
ports:
- "8081:8081"
environment:
SPRING_APPLICATION_NAME: userservice
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5431/userservice
SPRING_DATASOURCE_USERNAME: postgresuser
SPRING_DATASOURCE_PASSWORD: postgrespassword
CONFIG_SERVER: http://configserver:8071
SPRING_PROFILES_ACTIVE: prod
deploy:
resources:
limits:
memory: 700m
depends_on:
configserver:
condition: service_healthy
rabbit:
condition: service_healthy
postgres:
condition: service_started
networks:
- app-network
postservice:
image: example/postservice
container_name: postservice
ports:
- 8082:8082
environment:
SPRING_APPLICATION_NAME: postservice
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5431/postservice
SPRING_DATASOURCE_USERNAME: postgresuser
SPRING_DATASOURCE_PASSWORD: postgrespassword
CONFIG_SERVER: http://configserver:8071
SPRING_PROFILES_ACTIVE: prod
deploy:
resources:
limits:
memory: 700m
depends_on:
configserver:
condition: service_healthy
rabbit:
condition: service_healthy
postgres:
condition: service_started
networks:
- app-network
networks:
app-network:
driver: bridge