Coding the microservice
We have the database of the RecommendationService
microservice defined and created in our docker-compose.yml
file. We will now do the same to create a container for the microservice. Again, let's edit the docker-compose.yml
file.
In this code, we have a dependency, the database, and the message broker, besides some definitions of environmental variables, mainly to connect to the database and queues:
recommendation_service: image: recommendation_service build: ./RecommendationService volumes: - './RecommendationService:/app' environment: - QUEUE_HOST=amqp://guest:guest@rabbitmq - DATABASE_URL=http://recommendation_db:7474/db/data - USER_SERVICE_ROUTE=http://172.17.0.1/user/ depends_on: - recommendation_db - rabbitmq links: - recommendation_db - rabbitmq
Now, let's create the RecommendationService
directory and files. At the end, the structure...