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 ...

Get Microservice Patterns and Best Practices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.