Skip to content

Commit

Permalink
✨ Add Python 3.12 (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiangolo committed Sep 8, 2024
1 parent 06998f1 commit 6e54bd5
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ jobs:
matrix:
image:
- name: latest
python_version: "3.11"
python_version: "3.12"
- name: python3.12
python_version: "3.12"
- name: python3.11
python_version: "3.11"
- name: python3.10
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ jobs:
matrix:
image:
- name: latest
python_version: "3.11"
python_version: "3.12"
- name: python3.12
python_version: "3.12"
- name: python3.11
python_version: "3.11"
- name: python3.10
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## Supported tags and respective `Dockerfile` links

* [`python3.11`, `latest` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.11.dockerfile)
* [`python3.12`, `latest` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.12.dockerfile)
* [`python3.11`, _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.11.dockerfile)
* [`python3.10` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.10.dockerfile)
* [`python3.9`, _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.9.dockerfile)
* [`python3.8`, _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-flask-docker/blob/master/docker-images/python3.8.dockerfile)
Expand Down Expand Up @@ -156,7 +157,7 @@ You can use this image as a base image for other images.
Assuming you have a file `requirements.txt`, you could have a `Dockerfile` like this:

```Dockerfile
FROM tiangolo/uwsgi-nginx-flask:python3.11
FROM tiangolo/uwsgi-nginx-flask:python3.12

COPY ./requirements.txt /app/requirements.txt

Expand All @@ -183,7 +184,7 @@ Or you may follow the instructions to build your project from scratch:
* Create a `Dockerfile` with:

```Dockerfile
FROM tiangolo/uwsgi-nginx-flask:python3.11
FROM tiangolo/uwsgi-nginx-flask:python3.12

COPY ./app /app
```
Expand Down Expand Up @@ -496,7 +497,7 @@ Have in mind that `UWSGI_CHEAPER` must be lower than `UWSGI_PROCESSES`.
So, if, for example, you need to start with 4 processes and grow to a maximum of 64, your `Dockerfile` could look like:

```Dockerfile
FROM tiangolo/uwsgi-nginx-flask:python3.11
FROM tiangolo/uwsgi-nginx-flask:python3.12

ENV UWSGI_CHEAPER 4
ENV UWSGI_PROCESSES 64
Expand All @@ -523,7 +524,7 @@ To change this behavior, set the `LISTEN_PORT` environment variable. You might a
You can do that in your `Dockerfile`, it would look something like:

```Dockerfile
FROM tiangolo/uwsgi-nginx-flask:python3.11
FROM tiangolo/uwsgi-nginx-flask:python3.12

ENV LISTEN_PORT 8080

Expand Down Expand Up @@ -660,7 +661,7 @@ or you can set it to the keyword `auto` and it will try to auto-detect the numbe
For example, using `auto`, your Dockerfile could look like:

```Dockerfile
FROM tiangolo/uwsgi-nginx-flask:python3.11
FROM tiangolo/uwsgi-nginx-flask:python3.12

ENV NGINX_WORKER_PROCESSES auto

Expand Down
37 changes: 37 additions & 0 deletions docker-images/python3.12.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM tiangolo/uwsgi-nginx:python3.12

LABEL maintainer="Sebastian Ramirez <tiangolo@gmail.com>"

# Install requirements
COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt

# URL under which static (not modified by Python) files will be requested
# They will be served by Nginx directly, without being handled by uWSGI
ENV STATIC_URL /static

Check warning on line 11 in docker-images/python3.12.dockerfile

View workflow job for this annotation

GitHub Actions / deploy (latest, 3.12)

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

Check warning on line 11 in docker-images/python3.12.dockerfile

View workflow job for this annotation

GitHub Actions / deploy (python3.12, 3.12)

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
# Absolute path in where the static files wil be
ENV STATIC_PATH /app/static

Check warning on line 13 in docker-images/python3.12.dockerfile

View workflow job for this annotation

GitHub Actions / deploy (latest, 3.12)

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

Check warning on line 13 in docker-images/python3.12.dockerfile

View workflow job for this annotation

GitHub Actions / deploy (python3.12, 3.12)

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

# If STATIC_INDEX is 1, serve / with /static/index.html directly (or the static URL configured)
# ENV STATIC_INDEX 1
ENV STATIC_INDEX 0

Check warning on line 17 in docker-images/python3.12.dockerfile

View workflow job for this annotation

GitHub Actions / deploy (latest, 3.12)

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

Check warning on line 17 in docker-images/python3.12.dockerfile

View workflow job for this annotation

GitHub Actions / deploy (python3.12, 3.12)

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

# Add demo app
COPY ./app /app
WORKDIR /app

# Make /app/* available to be imported by Python globally to better support several use cases like Alembic migrations.
ENV PYTHONPATH=/app

# Move the base entrypoint to reuse it
RUN mv /entrypoint.sh /uwsgi-nginx-entrypoint.sh
# Copy the entrypoint that will generate Nginx additional configs
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]

# Run the start script provided by the parent image tiangolo/uwsgi-nginx.
# It will check for an /app/prestart.sh script (e.g. for migrations)
# And then will start Supervisor, which in turn will start Nginx and uWSGI
CMD ["/start.sh"]
3 changes: 2 additions & 1 deletion scripts/process_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import sys

environments = [
{"NAME": "latest", "PYTHON_VERSION": "3.11"},
{"NAME": "latest", "PYTHON_VERSION": "3.12"},
{"NAME": "python3.12", "PYTHON_VERSION": "3.12"},
{"NAME": "python3.11", "PYTHON_VERSION": "3.11"},
{"NAME": "python3.10", "PYTHON_VERSION": "3.10"},
{"NAME": "python3.9", "PYTHON_VERSION": "3.9"},
Expand Down

0 comments on commit 6e54bd5

Please sign in to comment.