Create a Flask+uWSGI+Nginx Docker Image
Create a Flask+uWSGI+Nginx Docker Image
In this example, we will create a Docker image for a Flask application using uWSGI and Nginx. The image will be based on the tiangolo/uwsgi-nginx-flask
image, which is a popular choice for deploying Flask applications in production.
Directory Hierarchy
Create a directory for your project. Inside this directory, create a subdirectory for your Flask application and a Dockerfile
in the root directory.
1 | . |
Create Dockerfile
Create a Dockerfile
in the root directory of your project. This file will define the image for your Flask application.
in this case, because we use opencv-python3, we need to install ffmpeg
and libsm6 libxext6
in the image.
1 | FROM tiangolo/uwsgi-nginx-flask:python3.10 |
Customized uwsgi.ini
This image will auto create a uwsgi.ini
file in the /app
directory.
If needed, you can customize the uwsgi.ini
file at ./app
to replace it when build.
1 | [uwsgi] |