You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Docker** image with **uWSGI** and **Nginx** for **Flask** web applications in **Python** running in a single container.
14
+
**Docker** image with **uWSGI** and **Nginx** for **Flask** web applications in **Python 2.7** and **Python 3.5** running in a single container.
11
15
12
16
## Description
13
17
@@ -21,53 +25,55 @@ uWSGI with Nginx is one of the best ways to deploy a Python web application, so
21
25
22
26
## Examples (project templates)
23
27
24
-
***`flask`** tag (general Flask web application): [**example-flask**](<https://github.com/tiangolo/uwsgi-nginx-flask-docker/releases/download/v0.1.2/example-flask.zip>)
28
+
***`flask`** tag (general Flask web application): [**example-flask**](<>)
25
29
26
-
***`flask-upload`** tag (general Flask web application. Allowing uploads of up to 100 MB.): [**example-flask-upload**](<https://github.com/tiangolo/uwsgi-nginx-flask-docker/releases/download/v0.1.2/example-flask-upload.zip>)
30
+
**`flask-python3.5`* tag (the equivalent as above, using Python 3.5): [**example-flask-python3.5**](<>)
27
31
28
-
***`flask-index`** tag (`static/index.html` served directly in `/`, e.g. for Angular JS): [**example-flask-index**](<https://github.com/tiangolo/uwsgi-nginx-flask-docker/releases/download/v0.1.2/example-flask-index.zip>)
32
+
***`flask-upload`** tag (general Flask web application. Allowing uploads of up to 100 MB.): [**example-flask-upload**](<>)
29
33
30
-
***`flask-index-upload`** tag (`static/index.html` served directly in `/`, e.g. for Angular JS. Allowing uploads of up to 100 MB.): [**example-flask-index-upload**](<https://github.com/tiangolo/uwsgi-nginx-flask-docker/releases/download/v0.1.2/example-flask-index-upload.zip>)
34
+
**`flask-python3.5-upload`* tag (the equivalent as above, using Python 3.5): [**example-flask-python3.5-upload**](<>)
35
+
36
+
***`flask-index`** tag (`static/index.html` served directly in `/`, e.g. for Angular JS): [**example-flask-index**](<>)
37
+
38
+
**`flask-python3.5-index`* tag (the equivalent as above, using Python 3.5): [**example-flask-python3.5-index**](<>)
39
+
40
+
***`flask-index-upload`** tag (`static/index.html` served directly in `/`, e.g. for Angular JS. Allowing uploads of up to 100 MB.): [**example-flask-index-upload**](<>)
41
+
42
+
**`flask-python3.5-index-upload`* tag (the equivalent as above, using Python 3.5): [**example-flask-python3.5-index-upload**](<>)
31
43
32
44
## General Instructions
33
45
34
46
You don't have to clone this repo, you should be able to use this image as a base image for your project.
35
47
36
-
There are four image tags:
48
+
There are several image tags, for each one, there's a template repo (a `.zip` file that you can download from above, in the "**Examples**" section):
37
49
38
-
***`flask`** (also `latest`): An image based on the [**tiangolo/uwsgi-nginx**](https://hub.docker.com/r/tiangolo/uwsgi-nginx/) image. This image includes Flask and a sample app.
50
+
***`flask`** (also `latest` and `flask-python2.7`): An image based on the [**tiangolo/uwsgi-nginx**](https://hub.docker.com/r/tiangolo/uwsgi-nginx/) image. This image includes Flask and a sample app.
39
51
40
52
The image [**tiangolo/uwsgi-nginx**](https://hub.docker.com/r/tiangolo/uwsgi-nginx/) has uWSGI and Nginx installed in the same container and is made to be the base of this image.
41
53
42
54
Use `FROM tiangolo/uwsgi-nginx-flask:flask` in your `Dockerfile` to use this image. (This would be the most general purpose tag image).
43
55
44
-
You can also use the example template project: [**example-flask**](<https://github.com/tiangolo/uwsgi-nginx-flask-docker/releases/download/v0.1.1/example-flask.zip>).
45
-
46
56
***`flask-upload`**: The same as **`flask`** but configuring Nginx to allow uploads of up to 100 MB (the default is 1 MB).
47
57
48
58
Use `FROM tiangolo/uwsgi-nginx-flask:flask-upload` in your `Dockerfile` to use this image. (This would be the most general purpose tag image).
49
59
50
-
You can also use the example template project: [**example-flask-upload**](<https://github.com/tiangolo/uwsgi-nginx-flask-docker/releases/download/v0.1.2/example-flask-upload.zip>).
51
-
52
60
***`flask-index`**: An image based on the **`flask`** image (above), but optimizing the configuration to make Nginx serve `/app/static/index.html` directly (instead of going through uWSGI and your code) when requested for `/`.
53
61
54
62
This is specially helpful (and efficient) if you are building a single-page app without Jinja2 templates (as with Angular JS) and using Flask as an API / back-end.
55
63
56
64
Use `FROM tiangolo/uwsgi-nginx-flask:flask-index` in your `Dockerfile` to use this image.
57
65
58
-
You can also use the example template project: [**example-flask-index**](<https://github.com/tiangolo/uwsgi-nginx-flask-docker/releases/download/v0.1.1/example-flask-index.zip>).
59
-
60
66
***`flask-index-upload`**: The same as **`flask-index`** but configuring Nginx to allow uploads of up to 100 MB (the default is 1 MB).
61
67
62
68
Use `FROM tiangolo/uwsgi-nginx-flask:flask-index-upload` in your `Dockerfile` to use this image. (This would be the most general purpose tag image).
63
69
64
-
You can also use the example template project: [**example-flask-index-upload**](<https://github.com/tiangolo/uwsgi-nginx-flask-docker/releases/download/v0.1.2/example-flask-index-upload.zip>).
70
+
***Python 3.5**: There is a version of all the images and example templates above using Python 3.5. The usage is very similiar to the usage of the normal (Python 2.7) version, but using the equivalent `python3.5` tag (you can see all the available tags on the top). Nevertheless, [Python 2.7 is still the default as the Flask maintainers use it as default and port the code to Python 3.5](http://flask.pocoo.org/docs/0.11/python3/) and Python 2.7 is still the most used and supported version.
65
71
66
72
## Creating a Flask project with Docker
67
73
68
74
**Note**: These instructions are for the `flask` tag and are intended for a general purpose Flask web application.
69
75
70
-
You can download this example and use it as the template for your project: [**example-flask**](<https://github.com/tiangolo/uwsgi-nginx-flask-docker/releases/download/v0.1.1/example-flask.zip>).
76
+
You can download this example and use it as the template for your project: [**example-flask**](<>).
71
77
72
78
---
73
79
@@ -120,7 +126,7 @@ You should be able to check it in your Docker container's URL, for example: <htt
120
126
121
127
**Note**: These instructions are for the `flask-index` tag and are intended for an application that serves a static `index.html` file, as in an Angular JS application.
122
128
123
-
You can download this example and use it as the template for your project: [**example-flask-index**](<https://github.com/tiangolo/uwsgi-nginx-flask-docker/releases/download/v0.1.1/example-flask-index.zip>).
129
+
You can download this example and use it as the template for your project: [**example-flask-index**](<>).
If you only need to configure Nginx to allow uploads of up to 100 MB, you can use one of the example projects:
200
206
201
-
*[**example-flask-upload**](<https://github.com/tiangolo/uwsgi-nginx-flask-docker/releases/download/v0.1.2/example-flask-upload.zip>): With the Docker image tag `flask-upload`, for general purpose Flask web applications with uploads of up to 100 MB (instead of the default 1 MB).
207
+
*[**example-flask-upload**](<>): With the Docker image tag `flask-upload`, for general purpose Flask web applications with uploads of up to 100 MB (instead of the default 1 MB).
202
208
203
-
*[**example-flask-index-upload**](<https://github.com/tiangolo/uwsgi-nginx-flask-docker/releases/download/v0.1.2/example-flask-index-upload.zip>): With the Docker image tag `flask-index-upload`, for Flask web applications that serve `/static/index.html` directly when requested for `/` (useful with Angular JS) and with uploads of up to 100 MB (instead of the default 1 MB).
209
+
*[**example-flask-index-upload**](<>): With the Docker image tag `flask-index-upload`, for Flask web applications that serve `/static/index.html` directly when requested for `/` (useful with Angular JS) and with uploads of up to 100 MB (instead of the default 1 MB).
204
210
205
211
---
206
212
@@ -248,13 +254,13 @@ The image (and tags) created by this repo is based on the image [**tiangolo/uwsg
248
254
249
255
If you follow the instructions and keep the root directory `/app` in your container, with a file named `main.py` and a Flask object named `app` in it, it should "just work".
250
256
251
-
There's already a `uwsgi.ini` file in the `/app` directory with the uWSGI configurations for it to "just work".
257
+
There's already a `uwsgi.ini` file in the `/app` directory with the uWSGI configurations for it to "just work". And even all the other required parameters are in another `uwsgi.ini` file in the image, inside `/etc/uwsgi/`.
252
258
253
-
If you need to change the main file name or the main Flask object, you would have to provide your own `uwsgi.ini` file. You may use the one in this repo as a template to start with (you only would have to change 2 lines).
259
+
If you need to change the main file name or the main Flask object, you would have to provide your own `uwsgi.ini` file. You may use the one in this repo as a template to start with (and you only would have to change the 2 corresponding lines).
254
260
255
261
You can have a `/app/static` directory and those files will be efficiently served by Nginx directly (without going through your Flask code or even uWSGI), it's already configured for you.
256
262
257
-
Supervisord takes care of running uWSGI with the `uwsgi.ini` file in `/app` file and starting Nginx.
263
+
Supervisord takes care of running uWSGI with the `uwsgi.ini` file in `/app` file (including also the file in `/etc/uwsgi/uwsgi.ini`) and starting Nginx.
258
264
259
265
---
260
266
@@ -298,10 +304,6 @@ But first, as you will be completely replacing the directory `/app` in your cont
Now you can edit your Flask code in your local machine and once you refresh your browser, you will see the changes live.
340
342
341
-
Remember that you should use this only for debugging and development, for deployment you shouldn't mount volumes and you should let Supervisord start and let it start uWSGI and Nginx (which is what happens by default).
343
+
Remember that you should use this only for debugging and development, for deployment in production you shouldn't mount volumes and you should let Supervisord start and let it start uWSGI and Nginx (which is what happens by default).
342
344
343
345
For these last steps to work (live debugging and development), your Python Flask code should have that section with:
0 commit comments