From 0f5be130004114ea5f9efe280fc4729f8f2ae9ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Sun, 8 Sep 2024 23:08:29 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20Python=203.12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 4 +++- .github/workflows/test.yml | 4 +++- README.md | 13 +++++----- docker-images/python3.12.dockerfile | 37 +++++++++++++++++++++++++++++ scripts/process_all.py | 3 ++- 5 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 docker-images/python3.12.dockerfile diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c66801c..f2c790d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 371821e..ff05f9e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/README.md b/README.md index 6182b85..0030c25 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 @@ -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 ``` @@ -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 @@ -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 @@ -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 diff --git a/docker-images/python3.12.dockerfile b/docker-images/python3.12.dockerfile new file mode 100644 index 0000000..da03cc3 --- /dev/null +++ b/docker-images/python3.12.dockerfile @@ -0,0 +1,37 @@ +FROM tiangolo/uwsgi-nginx:python3.12 + +LABEL maintainer="Sebastian Ramirez " + +# 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 +# Absolute path in where the static files wil be +ENV STATIC_PATH /app/static + +# If STATIC_INDEX is 1, serve / with /static/index.html directly (or the static URL configured) +# ENV STATIC_INDEX 1 +ENV STATIC_INDEX 0 + +# 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"] diff --git a/scripts/process_all.py b/scripts/process_all.py index eb4782a..15d9a16 100644 --- a/scripts/process_all.py +++ b/scripts/process_all.py @@ -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"},