Creating an API container
At this point, we can only talk to our microservice using AMQP, or by using the Nameko shell or a Nameko ClusterRPCProxy class. So let's put our Flask-RESTful API into another container, run that alongside the other containers, and make REST calls. This will also require that we run an Elasticsearch container, as that API code also communicates with Elasticsearch.
Getting ready
First let's start up Elasticsearch in a container that is attached to the scraper-net network. We can kick that off with the following command:
$ docker run -e ELASTIC_PASSWORD=MagicWord --name=elastic --network scraper-net -p 9200:9200 -p 9300:9300 docker.elastic.co/elasticsearch/elasticsearch:6.1.1
Elasticsearch is now up and running on our scarper-net network. It can be reached by apps in other containers using the name elastic. Now let's move onto creating the container for the API.
How to do it
We proceed with the recipe as follows:
- In the
10/04folder is anapi.pyfile that implements a...