This project demonstrates how to use Docker Compose to manage multiple services that interact with each other through Docker networking. It includes two Node.js projects (producer and consumer) written in TypeScript.
- Docker
- Docker Compose
- Node.js
- npm
- Visual Studio Code or another code editor
Before running the services, make sure to install the necessary dependencies for both projects.
Navigate to the producer directory and install the dependencies:
cd producer
npm installNavigate to the consumer directory and install the dependencies:
cd consumer
npm installRunning the Projects You can use Docker Compose to build and run the projects.
docker-compose up --buildThis command will:
Build the Docker images for both the producer and consumer services. Start the services and make them available on ports 3000 and 4000, respectively.
Once the services are running, you can interact with them using a web browser or a tool like curl.
To send a message from the producer to the consumer, access the following URL:
curl http://localhost:3000/sendYou should receive a response indicating that the producer successfully communicated with the consumer.
This is an alternative approach to the docker-compose.
Follow this article: https://gist.github.com/genedy2017/142861e20a7c88b3ac7a78c86e09a5da
Start Minikube using Docker as the driver and configure Docker environment:
minikube start --driver=docker
eval $(minikube -p minikube docker-env)Build the Docker images locally for producer and consumer services:
docker build -t producer:local -f producer/Dockerfile --no-cache ./producer
docker build -t consumer:local -f consumer/Dockerfile --no-cache ./consumerForward ports to access the services locally:
kubectl port-forward svc/producer 3000:3000
kubectl port-forward svc/consumer 4000:4000Then, you can test the endpoints
minikube service producer
minikube service consumerkubectl get deployments
kubectl get serviceskubectl delete deployment consumer
kubectl delete deployment producerhelmfile apply
helmfile --log-level=debug apply
helmfile synckubectl describe pods -l app=consumer
kubectl describe pods -l app=producerkubectl logs -l app=consumer
kubectl logs -l app=producerCheck if the Helm releases are actually deployed:
helm ls --namespace defaultThis should list the consumer and producer releases if they are deployed.
helm template ./k8s/helm/consumer -f ./k8s/helm/consumer/values.yaml
helm template ./k8s/helm/producer -f ./k8s/helm/producer/values.yamldocker images | grep local