From a9fa4d2e62b69f39808cf4ea6d6ef587e68c1dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Sun, 17 Mar 2024 07:04:01 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Remove=20support=20for=20Alpine?= =?UTF-8?q?=20(#198)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 2 - .github/workflows/test.yml | 2 - README.md | 16 ++-- docker-images/entrypoint.sh | 9 --- docker-images/install-nginx-alpine.sh | 96 ----------------------- docker-images/python3.8-alpine.dockerfile | 76 ------------------ pyproject.toml | 2 +- scripts/process_all.py | 1 - 8 files changed, 6 insertions(+), 198 deletions(-) delete mode 100644 docker-images/install-nginx-alpine.sh delete mode 100644 docker-images/python3.8-alpine.dockerfile diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2edadfe..a89f611 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,8 +25,6 @@ jobs: python_version: "3.8" - name: python3.7 python_version: "3.7" - - name: python3.8-alpine - python_version: "3.8" fail-fast: true runs-on: ubuntu-latest steps: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 43b19a9..36e8731 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,8 +29,6 @@ jobs: python_version: "3.8" - name: python3.7 python_version: "3.7" - - name: python3.8-alpine - python_version: "3.8" fail-fast: true runs-on: ubuntu-latest steps: diff --git a/README.md b/README.md index 6309e97..e3391d5 100644 --- a/README.md +++ b/README.md @@ -8,21 +8,17 @@ * [`python3.8` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-docker/blob/master/docker-images/python3.8.dockerfile) * [`python3.7`, _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-docker/blob/master/docker-images/python3.7.dockerfile) -## Discouraged tags - -* [`python3.8-alpine` _(Dockerfile)_](https://github.com/tiangolo/uwsgi-nginx-docker/blob/master/docker-images/python3.8-alpine.dockerfile) - -To learn more about why Alpine images are discouraged for Python read the note at the end: [🚨 Alpine Python Warning](#-alpine-python-warning). - ## Deprecated tags -🚨 These tags are no longer supported or maintained, they are removed from the GitHub repository, but the last version pushed is still available in Docker Hub. +🚨 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: +* `python3.8-alpine` * `python3.6` * `python2.7` -The last date tags for deprecated Python versions are: +The last date tags for these versions are: +* `python3.8-alpine-2024-03-11` * `python3.6-2022-11-25` * `python2.7-2022-11-25` @@ -32,7 +28,7 @@ The last date tags for deprecated Python versions are: # uwsgi-nginx -**Docker** image with **uWSGI** and **Nginx** for web applications in **Python** (as **Flask**) in a single container. Optionally with Alpine Linux. +**Docker** image with **uWSGI** and **Nginx** for web applications in **Python** (as **Flask**) in a single container. ## Description @@ -40,8 +36,6 @@ This [**Docker**](https://www.docker.com/) image allows you to create [**Python* The combination of uWSGI with Nginx is a [common way to deploy Python web applications like Flask and Django](http://flask.pocoo.org/docs/1.0/deploying/uwsgi/). It is widely used in the industry and would give you decent performance. (*) -There is also an Alpine version. If you want it, check the tags from above. - This image was created to be the base image for [**tiangolo/uwsgi-nginx-flask**](https://hub.docker.com/r/tiangolo/uwsgi-nginx-flask/) but could be used as the base image for any other (WSGI-based) Python web application, like Django. ### * Note on performance and features diff --git a/docker-images/entrypoint.sh b/docker-images/entrypoint.sh index 5951278..3e3b88c 100644 --- a/docker-images/entrypoint.sh +++ b/docker-images/entrypoint.sh @@ -56,15 +56,6 @@ else # Generate Nginx config for maximum upload file size printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf - - # Remove default Nginx config from Alpine - printf "" > /etc/nginx/conf.d/default.conf fi -# For Alpine: -# Explicitly add installed Python packages and uWSGI Python packages to PYTHONPATH -# Otherwise uWSGI can't import Flask -if [ -n "$ALPINEPYTHON" ] ; then - export PYTHONPATH=$PYTHONPATH:/usr/local/lib/$ALPINEPYTHON/site-packages:/usr/lib/$ALPINEPYTHON/site-packages -fi exec "$@" diff --git a/docker-images/install-nginx-alpine.sh b/docker-images/install-nginx-alpine.sh deleted file mode 100644 index 029618b..0000000 --- a/docker-images/install-nginx-alpine.sh +++ /dev/null @@ -1,96 +0,0 @@ -#! /usr/bin/env sh - -# From official Nginx Docker image, as a script to re-use it, removing internal comments - -# Standard set up Nginx Alpine -# https://github.com/nginxinc/docker-nginx/blob/f958fbacada447737319e979db45a1da49123142/mainline/alpine/Dockerfile - -export NGINX_VERSION=1.21.6 -export NJS_VERSION=0.7.3 -export PKG_RELEASE=1 - -set -x \ - && apkArch="$(cat /etc/apk/arch)" \ - && nginxPackages=" \ - nginx=${NGINX_VERSION}-r${PKG_RELEASE} \ - nginx-module-xslt=${NGINX_VERSION}-r${PKG_RELEASE} \ - nginx-module-geoip=${NGINX_VERSION}-r${PKG_RELEASE} \ - nginx-module-image-filter=${NGINX_VERSION}-r${PKG_RELEASE} \ - nginx-module-njs=${NGINX_VERSION}.${NJS_VERSION}-r${PKG_RELEASE} \ - " \ - && case "$apkArch" in \ - x86_64|aarch64) \ - set -x \ - && KEY_SHA512="e7fa8303923d9b95db37a77ad46c68fd4755ff935d0a534d26eba83de193c76166c68bfe7f65471bf8881004ef4aa6df3e34689c305662750c0172fca5d8552a *stdin" \ - && apk add --no-cache --virtual .cert-deps \ - openssl \ - && wget -O /tmp/nginx_signing.rsa.pub https://nginx.org/keys/nginx_signing.rsa.pub \ - && if [ "$(openssl rsa -pubin -in /tmp/nginx_signing.rsa.pub -text -noout | openssl sha512 -r)" = "$KEY_SHA512" ]; then \ - echo "key verification succeeded!"; \ - mv /tmp/nginx_signing.rsa.pub /etc/apk/keys/; \ - else \ - echo "key verification failed!"; \ - exit 1; \ - fi \ - && apk del .cert-deps \ - && apk add -X "https://nginx.org/packages/mainline/alpine/v$(egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release)/main" --no-cache $nginxPackages \ - ;; \ - *) \ - set -x \ - && tempDir="$(mktemp -d)" \ - && chown nobody:nobody $tempDir \ - && apk add --no-cache --virtual .build-deps \ - gcc \ - libc-dev \ - make \ - openssl-dev \ - pcre-dev \ - zlib-dev \ - linux-headers \ - libxslt-dev \ - gd-dev \ - geoip-dev \ - perl-dev \ - libedit-dev \ - mercurial \ - bash \ - alpine-sdk \ - findutils \ - && su nobody -s /bin/sh -c " \ - export HOME=${tempDir} \ - && cd ${tempDir} \ - && hg clone https://hg.nginx.org/pkg-oss \ - && cd pkg-oss \ - && hg up ${NGINX_VERSION}-${PKG_RELEASE} \ - && cd alpine \ - && make all \ - && apk index -o ${tempDir}/packages/alpine/${apkArch}/APKINDEX.tar.gz ${tempDir}/packages/alpine/${apkArch}/*.apk \ - && abuild-sign -k ${tempDir}/.abuild/abuild-key.rsa ${tempDir}/packages/alpine/${apkArch}/APKINDEX.tar.gz \ - " \ - && cp ${tempDir}/.abuild/abuild-key.rsa.pub /etc/apk/keys/ \ - && apk del .build-deps \ - && apk add -X ${tempDir}/packages/alpine/ --no-cache $nginxPackages \ - ;; \ - esac \ - && if [ -n "$tempDir" ]; then rm -rf "$tempDir"; fi \ - && if [ -n "/etc/apk/keys/abuild-key.rsa.pub" ]; then rm -f /etc/apk/keys/abuild-key.rsa.pub; fi \ - && if [ -n "/etc/apk/keys/nginx_signing.rsa.pub" ]; then rm -f /etc/apk/keys/nginx_signing.rsa.pub; fi \ - && apk add --no-cache --virtual .gettext gettext \ - && mv /usr/bin/envsubst /tmp/ \ - \ - && runDeps="$( \ - scanelf --needed --nobanner /tmp/envsubst \ - | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ - | sort -u \ - | xargs -r apk info --installed \ - | sort -u \ - )" \ - && apk add --no-cache $runDeps \ - && apk del .gettext \ - && mv /tmp/envsubst /usr/local/bin/ \ - && apk add --no-cache tzdata \ - && apk add --no-cache curl ca-certificates \ - && ln -sf /dev/stdout /var/log/nginx/access.log \ - && ln -sf /dev/stderr /var/log/nginx/error.log - -# Standard set up Nginx finished diff --git a/docker-images/python3.8-alpine.dockerfile b/docker-images/python3.8-alpine.dockerfile deleted file mode 100644 index 4a35fd1..0000000 --- a/docker-images/python3.8-alpine.dockerfile +++ /dev/null @@ -1,76 +0,0 @@ -FROM python:3.8-alpine3.13 - -LABEL maintainer="Sebastian Ramirez " - -COPY install-nginx-alpine.sh / - -RUN sh /install-nginx-alpine.sh - -EXPOSE 80 - -# # Expose 443, in case of LTS / HTTPS -EXPOSE 443 - -# Install uWSGI -RUN apk add --no-cache uwsgi-python3 - -# Copy the base uWSGI ini file to enable default dynamic uwsgi process number -COPY uwsgi.ini /etc/uwsgi/ - -# Install Supervisord -RUN apk add --no-cache supervisor -# Custom Supervisord config -COPY supervisord-alpine.ini /etc/supervisor.d/supervisord.ini - -# Copy stop-supervisor.sh to kill the supervisor and substasks on app failure -COPY stop-supervisor.sh /etc/supervisor/stop-supervisor.sh -RUN chmod +x /etc/supervisor/stop-supervisor.sh - -# uWSGI Python plugin -# As an env var to re-use the config file -ENV UWSGI_PLUGIN python3 - -# Which uWSGI .ini file should be used, to make it customizable -ENV UWSGI_INI /app/uwsgi.ini - -# By default, run 2 processes -ENV UWSGI_CHEAPER 2 - -# By default, when on demand, run up to 16 processes -ENV UWSGI_PROCESSES 16 - -# By default, allow unlimited file sizes, modify it to limit the file sizes -# To have a maximum of 1 MB (Nginx's default) change the line to: -# ENV NGINX_MAX_UPLOAD 1m -ENV NGINX_MAX_UPLOAD 0 - -# By default, Nginx will run a single worker process, setting it to auto -# will create a worker for each CPU core -ENV NGINX_WORKER_PROCESSES 1 - -# By default, Nginx listens on port 80. -# To modify this, change LISTEN_PORT environment variable. -# (in a Dockerfile or with an option for `docker run`) -ENV LISTEN_PORT 80 - -# Used by the entrypoint to explicitly add installed Python packages -# and uWSGI Python packages to PYTHONPATH otherwise uWSGI can't import Flask -ENV ALPINEPYTHON python3.8 - -# Copy start.sh script that will check for a /app/prestart.sh script and run it before starting the app -COPY start.sh /start.sh -RUN chmod +x /start.sh - -# Copy the entrypoint that will generate Nginx additional configs -COPY entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh - -ENTRYPOINT ["sh", "/entrypoint.sh"] - -# Add demo app -COPY ./app /app -WORKDIR /app - -# Run the start script, 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/pyproject.toml b/pyproject.toml index 16828be..298b390 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "uwsgi-nginx-docker" version = "0.1.0" -description = "Docker image with uWSGI and Nginx for web applications in Python (as Flask) in a single container. Optionally with Alpine Linux." +description = "Docker image with uWSGI and Nginx for web applications in Python (as Flask) in a single container." authors = ["Sebastián Ramírez "] license = "MIT" diff --git a/scripts/process_all.py b/scripts/process_all.py index 2ee75a9..eb4782a 100644 --- a/scripts/process_all.py +++ b/scripts/process_all.py @@ -9,7 +9,6 @@ {"NAME": "python3.9", "PYTHON_VERSION": "3.9"}, {"NAME": "python3.8", "PYTHON_VERSION": "3.8"}, {"NAME": "python3.7", "PYTHON_VERSION": "3.7"}, - {"NAME": "python3.8-alpine", "PYTHON_VERSION": "3.8"}, ] start_with = os.environ.get("START_WITH")