From 2ce8b73b14bf630345782a2b7f4d2157fabcd947 Mon Sep 17 00:00:00 2001 From: Luciano Vitti Date: Wed, 29 May 2024 14:48:28 -0300 Subject: [PATCH] add support for python3.8.16-slim --- .github/workflows/deploy.yml | 8 ++++--- .github/workflows/test.yml | 4 +++- docker-images/python3.8.16-slim.dockerfile | 28 ++++++++++++++++++++++ scripts/process_all.py | 1 + tests/test_01_main/test_defaults.py | 2 +- tests/test_01_main/test_env_vars_1.py | 2 +- tests/test_01_main/test_env_vars_2.py | 2 +- tests/test_01_main/test_env_vars_3.py | 2 +- tests/test_03_reload/test_defaults.py | 2 +- tests/test_03_reload/test_env_vars_1.py | 2 +- tests/test_03_reload/test_env_vars_2.py | 2 +- tests/utils.py | 2 +- 12 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 docker-images/python3.8.16-slim.dockerfile diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4f6052c0..6442d189 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -33,6 +33,8 @@ jobs: python_version: "3.9" - name: python3.8-slim python_version: "3.8" + - name: python3.8.16-slim + python_version: "3.8.16" fail-fast: true runs-on: ubuntu-latest steps: @@ -58,8 +60,8 @@ jobs: push: true platforms: linux/amd64,linux/arm64 tags: | - tiangolo/uvicorn-gunicorn:${{ matrix.image.name }} - tiangolo/uvicorn-gunicorn:${{ matrix.image.name }}-${{ env.DATE_TAG }} + shiphero/uvicorn-gunicorn:${{ matrix.image.name }} + shiphero/uvicorn-gunicorn:${{ matrix.image.name }}-${{ env.DATE_TAG }} context: ./docker-images/ file: ./docker-images/${{ env.DOCKERFILE_NAME }}.dockerfile - name: Docker Hub Description @@ -67,4 +69,4 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - repository: tiangolo/uvicorn-gunicorn + repository: shiphero/uvicorn-gunicorn diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b175112f..95e0a9d6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,6 +37,8 @@ jobs: python_version: "3.9" - name: python3.8-slim python_version: "3.8" + - name: python3.8.16-slim + python_version: "3.8.16" fail-fast: true runs-on: ubuntu-latest steps: @@ -51,7 +53,7 @@ jobs: uses: docker/build-push-action@v5 with: push: false - tags: tiangolo/uvicorn-gunicorn:${{ matrix.image.name }} + tags: shiphero/uvicorn-gunicorn:${{ matrix.image.name }} context: ./docker-images/ file: ./docker-images/${{ env.DOCKERFILE_NAME }}.dockerfile - name: Set up Python diff --git a/docker-images/python3.8.16-slim.dockerfile b/docker-images/python3.8.16-slim.dockerfile new file mode 100644 index 00000000..3da08c42 --- /dev/null +++ b/docker-images/python3.8.16-slim.dockerfile @@ -0,0 +1,28 @@ +FROM python:3.8.16-slim + +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 + +LABEL maintainer="Sebastian Ramirez " + +COPY requirements.txt /tmp/requirements.txt +RUN pip install --no-cache-dir -r /tmp/requirements.txt + +COPY ./start.sh /start.sh +RUN chmod +x /start.sh + +COPY ./gunicorn_conf.py /gunicorn_conf.py + +COPY ./start-reload.sh /start-reload.sh +RUN chmod +x /start-reload.sh + +COPY ./app /app +WORKDIR /app/ + +ENV PYTHONPATH=/app + +EXPOSE 80 + +# Run the start script, it will check for an /app/prestart.sh script (e.g. for migrations) +# And then will start Gunicorn with Uvicorn +CMD ["/start.sh"] diff --git a/scripts/process_all.py b/scripts/process_all.py index 6537e5b3..abbff3ce 100644 --- a/scripts/process_all.py +++ b/scripts/process_all.py @@ -13,6 +13,7 @@ {"NAME": "python3.10-slim", "PYTHON_VERSION": "3.10"}, {"NAME": "python3.9-slim", "PYTHON_VERSION": "3.9"}, {"NAME": "python3.8-slim", "PYTHON_VERSION": "3.8"}, + {"NAME": "python3.8.16-slim", "PYTHON_VERSION": "3.8.16"}, ] start_with = os.environ.get("START_WITH") diff --git a/tests/test_01_main/test_defaults.py b/tests/test_01_main/test_defaults.py index 42eefe1f..cadad58c 100644 --- a/tests/test_01_main/test_defaults.py +++ b/tests/test_01_main/test_defaults.py @@ -45,7 +45,7 @@ def verify_container(container: Container, response_text: str) -> None: def test_defaults() -> None: name = os.getenv("NAME") - image = f"tiangolo/uvicorn-gunicorn:{name}" + image = f"shiphero/uvicorn-gunicorn:{name}" response_text = get_response_text1() sleep_time = int(os.getenv("SLEEP_TIME", 1)) remove_previous_container(client) diff --git a/tests/test_01_main/test_env_vars_1.py b/tests/test_01_main/test_env_vars_1.py index 07b8a7fb..1bae05f2 100644 --- a/tests/test_01_main/test_env_vars_1.py +++ b/tests/test_01_main/test_env_vars_1.py @@ -42,7 +42,7 @@ def verify_container(container: DockerClient, response_text: str) -> None: def test_env_vars_1() -> None: name = os.getenv("NAME") - image = f"tiangolo/uvicorn-gunicorn:{name}" + image = f"shiphero/uvicorn-gunicorn:{name}" response_text = get_response_text1() sleep_time = int(os.getenv("SLEEP_TIME", 1)) remove_previous_container(client) diff --git a/tests/test_01_main/test_env_vars_2.py b/tests/test_01_main/test_env_vars_2.py index bf501407..9e6946c3 100644 --- a/tests/test_01_main/test_env_vars_2.py +++ b/tests/test_01_main/test_env_vars_2.py @@ -41,7 +41,7 @@ def verify_container(container: Container) -> None: def test_env_vars_2() -> None: name = os.getenv("NAME") - image = f"tiangolo/uvicorn-gunicorn:{name}" + image = f"shiphero/uvicorn-gunicorn:{name}" sleep_time = int(os.getenv("SLEEP_TIME", 1)) remove_previous_container(client) container = client.containers.run( diff --git a/tests/test_01_main/test_env_vars_3.py b/tests/test_01_main/test_env_vars_3.py index 15e6582e..fefbfe1c 100644 --- a/tests/test_01_main/test_env_vars_3.py +++ b/tests/test_01_main/test_env_vars_3.py @@ -39,7 +39,7 @@ def verify_container(container: DockerClient, response_text: str) -> None: def test_env_bind() -> None: name = os.getenv("NAME") - image = f"tiangolo/uvicorn-gunicorn:{name}" + image = f"shiphero/uvicorn-gunicorn:{name}" response_text = get_response_text1() sleep_time = int(os.getenv("SLEEP_TIME", 1)) remove_previous_container(client) diff --git a/tests/test_03_reload/test_defaults.py b/tests/test_03_reload/test_defaults.py index 3332013b..144578b6 100644 --- a/tests/test_03_reload/test_defaults.py +++ b/tests/test_03_reload/test_defaults.py @@ -30,7 +30,7 @@ def verify_container(container: DockerClient, response_text: str) -> None: def test_defaults() -> None: name = os.getenv("NAME") - image = f"tiangolo/uvicorn-gunicorn:{name}" + image = f"shiphero/uvicorn-gunicorn:{name}" response_text = get_response_text1() sleep_time = int(os.getenv("SLEEP_TIME", 1)) remove_previous_container(client) diff --git a/tests/test_03_reload/test_env_vars_1.py b/tests/test_03_reload/test_env_vars_1.py index 87547d4c..bb9c1c96 100644 --- a/tests/test_03_reload/test_env_vars_1.py +++ b/tests/test_03_reload/test_env_vars_1.py @@ -29,7 +29,7 @@ def verify_container(container: DockerClient, response_text: str) -> None: def test_env_vars_1() -> None: name = os.getenv("NAME") - image = f"tiangolo/uvicorn-gunicorn:{name}" + image = f"shiphero/uvicorn-gunicorn:{name}" response_text = get_response_text1() sleep_time = int(os.getenv("SLEEP_TIME", 1)) remove_previous_container(client) diff --git a/tests/test_03_reload/test_env_vars_2.py b/tests/test_03_reload/test_env_vars_2.py index 1a6c01d7..41b08d36 100644 --- a/tests/test_03_reload/test_env_vars_2.py +++ b/tests/test_03_reload/test_env_vars_2.py @@ -21,7 +21,7 @@ def verify_container(container: Container) -> None: def test_env_vars_2() -> None: name = os.getenv("NAME") - image = f"tiangolo/uvicorn-gunicorn:{name}" + image = f"shiphero/uvicorn-gunicorn:{name}" sleep_time = int(os.getenv("SLEEP_TIME", 1)) time.sleep(sleep_time) remove_previous_container(client) diff --git a/tests/utils.py b/tests/utils.py index eec27c2f..82a84258 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -56,6 +56,6 @@ def get_response_text2() -> str: def generate_dockerfile_content(name: str) -> str: - content = f"FROM tiangolo/uvicorn-gunicorn:{name}\n" + content = f"FROM shiphero/uvicorn-gunicorn:{name}\n" content += "COPY ./app /app" return content