Topic about microservices and their management.
I’m seeking help due to lack of good sources.
I’m building an app based on microservices architecture and, for development, I decided to use docker compose functionality. We have services written in Java Spring for now, but we are going to use different languages as well.
Each service is located in different repository.
Each service has its own Dockerfile and docker-compose.yaml file
When I develop a particular service, I want to run other services in docker environment and communicate with them, using Kafka or gRPC.
I encountered many problems related to environment variables and network/DNS service discovery.
- What should I include in
.envfile? - Where should I put environment file related to a particular service (in its repo or in repo where I launch it?)
- How to manage DNS in docker compose? Sure, I can provide name of the service and it will be resolved, but how to provide, a service running in docker swarm, IP and port of service I’m currently working on?
The question may not be clear, I just want to hear design/folder/project structure, to achieve convenience and flexibility in managing such an app.
Consider, we are in product service repo, we have docker-compose.yaml file to run other service, for example cart-service:
cart-service:
build:
context: ../cart-service
dockerfile: Dockerfile
container_name: cart-service
ports:
- "${CART_SERVICE_PORT:?error}:8080"
env_file:
-
path: ../cart-service/docker/app-env.txt
required: false
depends_on:
cart-service-db:
restart: true
condition: service_healthy
kafka:
condition: service_healthy
#
Is it a good approach? What to change?