Skip to content

Commit b8acc18

Browse files
authored
🔥 Drop support for Python 3.7 and 3.8 (#388)
1 parent 9ce71e2 commit b8acc18

34 files changed

+9
-543
lines changed

.github/workflows/deploy.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ jobs:
2323
python_version: "3.10"
2424
- name: python3.9
2525
python_version: "3.9"
26-
- name: python3.8
27-
python_version: "3.8"
28-
- name: python3.7
29-
python_version: "3.7"
3026
fail-fast: true
3127
runs-on: ubuntu-latest
3228
steps:

.github/workflows/test.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ jobs:
2727
python_version: "3.10"
2828
- name: python3.9
2929
python_version: "3.9"
30-
- name: python3.8
31-
python_version: "3.8"
32-
- name: python3.7
33-
python_version: "3.7"
3430
fail-fast: true
3531
runs-on: ubuntu-latest
3632
steps:

README.md

Lines changed: 9 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,22 @@
66
* [`python3.11`, _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.11.dockerfile)
77
* [`python3.10` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.10.dockerfile)
88
* [`python3.9`, _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.9.dockerfile)
9-
* [`python3.8`, _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.8.dockerfile)
10-
* [`python3.7`, _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.7.dockerfile)
119

1210
## Deprecated tags
1311

1412
🚨 These tags are no longer supported or maintained, they are removed from the GitHub repository, but the last versions pushed might still be available in Docker Hub if anyone has been pulling them:
1513

14+
* `python3.8`
1615
* `python3.8-alpine`
16+
* `python3.7`
1717
* `python3.6`
1818
* `python2.7`
1919

2020
The last date tags for these versions are:
2121

22+
* `python3.8-2024-10-28`
2223
* `python3.8-alpine-2024-03-11`
24+
* `python3.7-2024-10-28`
2325
* `python3.6-2022-11-25`
2426
* `python2.7-2022-11-25`
2527

@@ -35,30 +37,11 @@ The last date tags for these versions are:
3537

3638
This [**Docker**](https://www.docker.com/) image allows you to create [**Flask**](http://flask.pocoo.org/) web applications in [**Python**](https://www.python.org/) that run with [**uWSGI**](https://uwsgi-docs.readthedocs.org/en/latest/) and [**Nginx**](http://nginx.org/en/) in a single container.
3739

38-
The combination of uWSGI with Nginx is a [common way to deploy Python Flask web applications](http://flask.pocoo.org/docs/1.0/deploying/uwsgi/). It is widely used in the industry and would give you decent performance. (*)
39-
40-
There is also an Alpine version. If you want it, check the tags from above.
41-
42-
### * Note on performance and features
43-
44-
If you are starting a new project, you might benefit from a newer and faster framework based on ASGI instead of WSGI (Flask and Django are WSGI-based).
45-
46-
You could use an ASGI framework like:
47-
48-
* [**FastAPI**](https://github.com/tiangolo/fastapi) (which is based on Starlette) with this Docker image: [**tiangolo/uvicorn-gunicorn-fastapi**](https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker).
49-
* [**Starlette**](https://github.com/encode/starlette) directly, with this Docker image: [**tiangolo/uvicorn-gunicorn-starlette**](https://github.com/tiangolo/uvicorn-gunicorn-starlette-docker).
50-
51-
FastAPI, or Starlette, would give you about 800% (8x) the performance achievable with Flask using this image (**tiangolo/uwsgi-nginx-flask**). [You can see the third-party benchmarks here](https://www.techempower.com/benchmarks/#section=test&runid=a979de55-980d-4721-a46f-77298b3f3923&hw=ph&test=fortune&l=zijzen-7).
52-
53-
Also, if you want to use new technologies like WebSockets it would be easier (and *possible*) with a newer framework based on ASGI, like FastAPI or Starlette. As the standard ASGI was designed to be able to handle asynchronous code like the one needed for WebSockets.
54-
55-
#### If you need Flask
56-
57-
If you need to use Flask (instead of something based on ASGI) and you need to have the best performance possible, you can use the alternative image: [**tiangolo/meinheld-gunicorn-flask**](https://github.com/tiangolo/meinheld-gunicorn-flask-docker).
40+
The combination of uWSGI with Nginx is a [common way to deploy Python Flask web applications](http://flask.pocoo.org/docs/1.0/deploying/uwsgi/).
5841

59-
**tiangolo/meinheld-gunicorn-flask** will give you about 400% (4x) the performance of this image (**tiangolo/uwsgi-nginx-flask**).
42+
### Alternative - FastAPI
6043

61-
It is very similar to **tiangolo/uwsgi-nginx-flask**, so you can still use many of the ideas described here.
44+
If you are starting a new project, you might want to try [**FastAPI**](https://github.com/tiangolo/fastapi), which I created, and where I spend most of my time now. It also doesn't need a custom base image, there are instructions in the docs to build your own `Dockerfile`.
6245

6346
---
6447

@@ -93,7 +76,7 @@ threads = 3
9376
And then you could have a `Dockerfile` with:
9477

9578
```Dockerfile
96-
FROM python:3.9
79+
FROM python:3.12
9780

9881
WORKDIR /code
9982

@@ -120,7 +103,7 @@ You could be deploying to a **single server** (not a cluster) with **Docker Comp
120103

121104
Then you could want to have **a single container** with a **process manager** starting **several worker processes** inside, as this Docker image does.
122105

123-
### Prometheus and Other Reasons
106+
### Other Reasons
124107

125108
You could also have **other reasons** that would make it easier to have a **single container** with **multiple processes** instead of having **multiple containers** with **a single process** in each of them.
126109

@@ -134,20 +117,6 @@ Then, in that case, it could be simpler to have **one container** with **multipl
134117

135118
Read more about it all in the [FastAPI documentation about: FastAPI in Containers - Docker](https://fastapi.tiangolo.com/deployment/docker/), as the same concepts apply to other web applications in containers.
136119

137-
## Examples (simple project templates)
138-
139-
* **`python3.8`** tag: general Flask web application:
140-
141-
[**example-flask-python3.8.zip**](https://github.com/tiangolo/uwsgi-nginx-flask-docker/releases/download/1.4.0/example-flask-python3.8.zip)
142-
143-
* **`python3.8`** tag: general Flask web application, structured as a package, for bigger Flask projects, with different submodules. Use it only as an example of how to import your modules and how to structure your own project:
144-
145-
[**example-flask-package-python3.8.zip**](https://github.com/tiangolo/uwsgi-nginx-flask-docker/releases/download/1.4.0/example-flask-package-python3.8.zip)
146-
147-
* **`python3.8`** tag: `static/index.html` served directly in `/`, e.g. for [Vue](https://vuejs.org/), [React](https://reactjs.org/), [Angular](https://angular.io/), or any other Single-Page Application that uses a static `index.html`, not modified by Python:
148-
149-
[**example-flask-python3.8-index.zip**](https://github.com/tiangolo/uwsgi-nginx-flask-docker/releases/download/1.4.0/example-flask-python3.8-index.zip)
150-
151120
## General Instructions
152121

153122
You don't have to clone this repo.
@@ -168,18 +137,10 @@ COPY ./app /app
168137

169138
There are several image tags available but for new projects you should use the latest version available.
170139

171-
There are several template projects that you can download (as a `.zip` file) to bootstrap your project in the section "**Examples (project templates)**" above.
172-
173140
This Docker image is based on [**tiangolo/uwsgi-nginx**](https://hub.docker.com/r/tiangolo/uwsgi-nginx/). That Docker image has uWSGI and Nginx installed in the same container and was made to be the base of this image.
174141

175142
## Quick Start
176143

177-
**Note**: You can download the **example-flask-python3.8.zip** project example and use it as the template for your project from the section **Examples** above.
178-
179-
---
180-
181-
Or you may follow the instructions to build your project from scratch:
182-
183144
* Go to your project directory
184145
* Create a `Dockerfile` with:
185146

@@ -235,69 +196,6 @@ docker run -d --name mycontainer -p 80:80 myimage
235196

236197
You should be able to check it in your Docker container's URL, for example: <a href="http://192.168.99.100" target="_blank">http://192.168.99.100</a> or <a href="http://127.0.0.1" target="_blank">http://127.0.0.1</a>
237198

238-
## Project Generators
239-
240-
There are several project generators that you can use to start your project, with everything already configured.
241-
242-
### Server set up
243-
244-
All these project generators include automatic and free HTTPS certificates generation provided by:
245-
246-
* [Traefik](https://traefik.io/) and
247-
* [Let's Encrypt](https://letsencrypt.org/)
248-
249-
...using the ideas from [DockerSwarm.rocks](https://dockerswarm.rocks).
250-
251-
It would take about 20 minutes to read that guide and have a Docker cluster (of one or more servers) up and running ready for your projects.
252-
253-
You can have several projects in the same cluster, all with automatic HTTPS, even if they have different domains or sub-domains.
254-
255-
### Generate a project
256-
257-
Then you can use one of the following project generators.
258-
259-
It would take about 5 extra minutes to generate one of these projects.
260-
261-
### Deploy
262-
263-
And it would take about 3 more minutes to deploy them in your cluster.
264-
265-
---
266-
267-
In total, about 28 minutes to start from scratch and get an HTTPS Docker cluster with your full application(s) ready.
268-
269-
---
270-
271-
These are the project generators:
272-
273-
### flask-frontend-docker
274-
275-
Project link: [https://github.com/tiangolo/flask-frontend-docker](https://github.com/tiangolo/flask-frontend-docker)
276-
277-
Minimal project generator with a Flask backend, a modern frontend (Vue, React or Angular) using Docker multi-stage building and Nginx, a Traefik load balancer with HTTPS, Docker Compose (and Docker Swarm mode) etc.
278-
279-
### full-stack
280-
281-
Project Link: [https://github.com/tiangolo/full-stack](https://github.com/tiangolo/full-stack)
282-
283-
Full stack project generator with Flask backend, PostgreSQL DB, PGAdmin, SQLAlchemy, Alembic migrations, Celery asynchronous jobs, API testing, CI integration, Docker Compose (and Docker Swarm mode), Swagger, automatic HTTPS, Vue.js, etc.
284-
285-
### full-stack-flask-couchbase
286-
287-
Project Link: [https://github.com/tiangolo/full-stack-flask-couchbase](https://github.com/tiangolo/full-stack-flask-couchbase)
288-
289-
Full stack project generator with Flask backend, Couchbase, Couchbase Sync Gateway, Celery asynchronous jobs, API testing, CI integration, Docker Compose (and Docker Swarm mode), Swagger, automatic HTTPS, Vue.js, etc.
290-
291-
Similar to the one above (`full-stack`), but with Couchbase instead of PostgreSQL, and some more features.
292-
293-
### full-stack-flask-couchdb
294-
295-
Project Link: [https://github.com/tiangolo/full-stack-flask-couchdb](https://github.com/tiangolo/full-stack-flask-couchdb)
296-
297-
Full stack project generator with Flask backend, CouchDB, Celery asynchronous jobs, API testing, CI integration, Docker Compose (and Docker Swarm mode), Swagger, automatic HTTPS, Vue.js, etc.
298-
299-
Similar to `full-stack-flask-couchbase`, but with CouchDB instead of Couchbase (or PostgreSQL).
300-
301199
## Quick Start for SPAs *
302200

303201
### Modern Single Page Applications
@@ -353,16 +251,8 @@ In this scenario, you would have 3 Docker containers:
353251
* Frontend (Vue.js, Angular, React or any other)
354252
* Traefik (load balancer, HTTPS)
355253

356-
### Deprecated Single Page Applications guide
357-
358-
If you want to check the previous (deprecated) documentation on adding a frontend to the same container, you can [read the deprecated guide for single page apps](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/deprecated-single-page-apps-in-same-container.md).
359-
360254
## Quick Start for bigger projects structured as a Python package
361255

362-
**Note**: You can download the **example-flask-package-python3.8.zip** project example and use it as an example or template for your project from the section **Examples** above.
363-
364-
---
365-
366256
You should be able to follow the same instructions as in the "**QuickStart**" section above, with some minor modifications:
367257

368258
* Instead of putting your code in the `app/` directory, put it in a directory `app/app/`.
@@ -842,8 +732,6 @@ if __name__ == "__main__":
842732

843733
...and you could run it with `python main.py`. But that will only work when you are not using a package structure and don't plan to do it later. In that specific case, if you didn't add the code block above, your app would only listen to `localhost` (inside the container), in another port (5000) and not in debug mode.
844734

845-
**Note**: The example project **example-flask-python3.8** includes a `docker-compose.yml` and `docker-compose.override.yml` with all these configurations, if you are using Docker Compose.
846-
847735
---
848736

849737
Also, if you want to do the same live debugging using the environment variable `STATIC_INDEX=1` (to serve `/app/static/index.html` directly when requested for `/`) your Nginx won't serve it directly as it won't be running (only your Python Flask app in debug mode will be running).
@@ -884,8 +772,6 @@ def route_frontend(path):
884772

885773
That's how it is written in the tutorial above and is included in the downloadable examples.
886774

887-
**Note**: The example project **example-flask-python3.8-index** includes a `docker-compose.yml` and `docker-compose.override.yml` with all these configurations, if you are using Docker Compose.
888-
889775
## More advanced development instructions
890776

891777
If you follow the instructions above, it's probable that at some point, you will write code that will break your Flask debugging server and it will crash.
@@ -924,34 +810,10 @@ flask run --host=0.0.0.0 --port=80
924810

925811
You will see your Flask debugging server start, you will see how it sends responses to every request, you will see the errors thrown when you break your code, and how they stop your server, and you will be able to re-start it very fast, by just running the command above again.
926812

927-
## 🚨 Alpine Python Warning
928-
929-
In short: You probably shouldn't use Alpine for Python projects, instead use the `slim` Docker image versions.
930-
931-
---
932-
933-
Do you want more details? Continue reading 👇
934-
935-
Alpine is more useful for other languages where you build a static binary in one Docker image stage (using multi-stage Docker building) and then copy it to a simple Alpine image, and then just execute that binary. For example, using Go.
936-
937-
But for Python, as Alpine doesn't use the standard tooling used for building Python extensions, when installing packages, in many cases Python (`pip`) won't find a precompiled installable package (a "wheel") for Alpine. And after debugging lots of strange errors you will realize that you have to install a lot of extra tooling and build a lot of dependencies just to use some of these common Python packages. 😩
938-
939-
This means that, although the original Alpine image might have been small, you end up with a an image with a size comparable to the size you would have gotten if you had just used a standard Python image (based on Debian), or in some cases even larger. 🤯
940-
941-
And in all those cases, it will take much longer to build, consuming much more resources, building dependencies for longer, and also increasing its carbon footprint, as you are using more CPU time and energy for each build. 🌳
942-
943-
If you want slim Python images, you should instead try and use the `slim` versions that are still based on Debian, but are smaller. 🤓
944-
945813
## Tests
946814

947815
All the image tags, configurations, environment variables and application options are tested.
948816

949-
## Updates
950-
951-
Updates are announced in the releases.
952-
953-
You can click the "watch" button at the top right and select "Releases only" to receive an email notification when there's a new release.
954-
955817
## Release Notes
956818

957819
### Latest Changes

deprecated-single-page-apps-in-same-container.md

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)