The full stack - OpenResty, Circus and Flask

When you release microservices as Docker images, there are two strategies for including a web server.

The first one consists of ignoring it and exposing the Flask application directly. A web server like OpenResty could then run in its docker container, proxying calls to your Flask container.

However, if you are using some power features in nginx, like a Lua-based application firewall as we have seen in Chapter 7, Securing Your Services, it can be better to include everything within the same container, together with a dedicated process manager.

In the diagram that follows, the docker container implements the second strategy, and runs both the web server and the Flask service. Circus is used to launch and watch one nginx process and a few Flask processes:

In this section, we will implement this container by adding in our Dockerfile the following steps:

  1. Download, compile, and install OpenResty.
  2. Add an nginx configuration file.
  3. Download and install Circus and Chaussette.
  4. Add a Circus configuration file to run nginx and the Flask app.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset