From f732c34290352611d5dc340ecb6e8a16b8dd9958 Mon Sep 17 00:00:00 2001 From: Ant Date: Fri, 15 Jul 2022 10:57:07 -0700 Subject: [PATCH 1/6] Create list of removed packages --- generate_requirements.sh | 23 ----------------------- removed-packages.txt | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 23 deletions(-) delete mode 100755 generate_requirements.sh create mode 100755 removed-packages.txt diff --git a/generate_requirements.sh b/generate_requirements.sh deleted file mode 100755 index 2be8553..0000000 --- a/generate_requirements.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - - -pip install \ - fastapi `# Web framework used for all our apps`\ - uvicorn `# ASGI server`\ - watchdog pyyaml argh `# Used to restart the app in development mode when files are saved`\ - loguru `# Enjoyable logging in Python`\ - mypy mypy-extensions `# Optional static type checker`\ - pytest pytest-cov `# Testing suite and utils`\ - pytest-mock `# Provide mocker fixture`\ - pytest-asyncio `# Add async tests to pytest`\ - nest-asyncio `# For the asyncio loop`\ - flake8 `# Linting`\ - isort `# Utility to sort and organize imports into sections and types`\ - flake8-isort `# Plugin to run isort as part of the linting`\ - flake8-quotes `# Plugin to enforce specific quotes convention, which PEP8 doesn't`\ - flake8-print `# Plugin to prevent the use of print statements`\ - black `# Formatting`\ - interrogate `# Checks code base for missing docstrings`\ - - -pip freeze > requirements.txt diff --git a/removed-packages.txt b/removed-packages.txt new file mode 100755 index 0000000..be31d7e --- /dev/null +++ b/removed-packages.txt @@ -0,0 +1,17 @@ +fastapi +uvicorn +loguru +# Dev dependencies below +watchdog pyyaml argh +mypy mypy-extensions +pytest pytest-cov +pytest-mock +pytest-asyncio +nest-asyncio +flake8 +isort +flake8-isort +flake8-quotes +flake8-print +black +interrogate From 0b645ec9c1b9b3041c70238a22b769f062cfb620 Mon Sep 17 00:00:00 2001 From: Ant Date: Fri, 15 Jul 2022 10:58:54 -0700 Subject: [PATCH 2/6] Removed useless commented out line --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6f72308..667a610 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,6 @@ RUN apt-get update && apt-get upgrade -y \ && useradd -u 1000 -ms /bin/bash -d /home/python python \ && mkdir -p /python && chown python:nogroup /python -#RUN pip install uvicorn==0.17.6 # Copy the needed files COPY entrypoint.sh test_suite.sh /python/ From 87de0682f62fad494d141783696fa0f12ad4cd71 Mon Sep 17 00:00:00 2001 From: Ant Date: Fri, 15 Jul 2022 10:59:07 -0700 Subject: [PATCH 3/6] Remove unecessary file --- docker-compose.generate_requirements.yml | 26 ------------------------ 1 file changed, 26 deletions(-) delete mode 100644 docker-compose.generate_requirements.yml diff --git a/docker-compose.generate_requirements.yml b/docker-compose.generate_requirements.yml deleted file mode 100644 index 4d856b4..0000000 --- a/docker-compose.generate_requirements.yml +++ /dev/null @@ -1,26 +0,0 @@ -version: "3.5" - -services: - generate_requirements_3_10: - image: python:3.10.4-slim - command: "/generate_requirements.sh" - volumes: - - ./generate_requirements.sh:/generate_requirements.sh - - ./requirements_3.10.txt:/requirements.txt - tty: true - - generate_requirements_3_9: - image: python:3.9.12-slim - command: "/generate_requirements.sh" - volumes: - - ./generate_requirements.sh:/generate_requirements.sh - - ./requirements_3.9.txt:/requirements.txt - tty: true - - generate_requirements_3_8: - image: python:3.8.13-slim - command: "/generate_requirements.sh" - volumes: - - ./generate_requirements.sh:/generate_requirements.sh - - ./requirements_3.8.txt:/requirements.txt - tty: true From 7c541d3eee291cd594016bf520f1a12728750ad6 Mon Sep 17 00:00:00 2001 From: Ant Date: Fri, 15 Jul 2022 11:13:15 -0700 Subject: [PATCH 4/6] Change migration section, rm requirements upgrade --- README.md | 44 +++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index cfcecfd..0104d39 100644 --- a/README.md +++ b/README.md @@ -15,25 +15,20 @@ one of 3 cases based on the parameter you pass in: 2. `./dev.sh run` runs the main application. 3. `./dev.sh cli` drops you into the cli for the image -## :hourglass_flowing_sand: Migration to version 4 - -The version 4 comes with significant changes: - -* The docker base image was changed from alpine to slim buster - * All the `apk add` commands need to be replaced with equivalent `apt-get` commands - * slim buster has more base packages such as bash so probably less installation - of system packages is needed -* The entrypoint now provides standard commands to run and test the webapp - * No `CMD` is necessary for production as `startapp` is the default - * In development, run the `developapp` command - * See below for testing -* A `config.sh` is expected where environment variables for configuration purposes - can be defined -* The `requirements.txt` has been reduced to the base and development python packages - * Base packages such as FastAPI, pydantic, loguru, ... - * Development pacakages such as watchmedo, pytest, mypy, ... - * Therefore you need to add to your requirements file packages such as pandas - that were included in this image in versions prior to 4 +## :hourglass_flowing_sand: Migration to version > 202205 + +Starting with the version 202207, the docker python base does not contain +any preinstalled python packages. It is now just providing a folder structure +with adequate permissions for the python user, and a standard test suite. + +As a consequence upgrading to version 202207 and latest requires to +add the packages that used to be provided by the docker python base image. +The list of packages in listed in the +[removed-packages.txt](./removed-packages.txt) file. + +The docker python base test image uses now poetry as it is the preferred +way to manage dependencies at Satel. It can be used as an example +on how to use poetry while building a python app image. ## :open_file_folder: Folder structure @@ -51,20 +46,11 @@ such as the `entrypoint.sh`. Then the subfolders organize the app files: 1. Go to docker hub to get the latest patch version for the [python docker image](https://hub.docker.com/_/python/) -2. Then 3 files need to be edited with the latest python minor or patch versions: - 1. `docker-compose.generate_requirements.yml` to generate the requirements files. +2. Then 2 files need to be edited with the latest python minor or patch versions: 1. `.github/workflows/docker_image.yml` to build and push the right images to docker hub. 1. `Dockerfile` to change the default base image version. This is used only for testing while developing but better to keep it up to date. -### Upgrade the requirements files - -Rather simple. Just run the following command at the root of the repo: - -```bash -docker-compose -f docker-compose.generate_requirements.yml up -``` - ## :keyboard: Commands The entrypoint of this docker image provides standard commands for our app's docker From 2fe69a86d8bdd10c675362334451766edb99a046 Mon Sep 17 00:00:00 2001 From: Ant Date: Fri, 15 Jul 2022 11:19:42 -0700 Subject: [PATCH 5/6] Fix title for migration section --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0104d39..ef2c847 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ one of 3 cases based on the parameter you pass in: 2. `./dev.sh run` runs the main application. 3. `./dev.sh cli` drops you into the cli for the image -## :hourglass_flowing_sand: Migration to version > 202205 +## :hourglass_flowing_sand: Migration from version 202205 to above Starting with the version 202207, the docker python base does not contain any preinstalled python packages. It is now just providing a folder structure From 9a1a5166224664af0441af1a513dffc90443afaf Mon Sep 17 00:00:00 2001 From: Ant Date: Tue, 19 Jul 2022 11:40:44 -0700 Subject: [PATCH 6/6] Clarify which Dockerfile to change for updates --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ef2c847..2e48f1b 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,9 @@ such as the `entrypoint.sh`. Then the subfolders organize the app files: the [python docker image](https://hub.docker.com/_/python/) 2. Then 2 files need to be edited with the latest python minor or patch versions: 1. `.github/workflows/docker_image.yml` to build and push the right images to docker hub. - 1. `Dockerfile` to change the default base image version. This is used only for testing - while developing but better to keep it up to date. + 1. `Dockerfile` at the root (not the one in `/tests`) to change the default + base image version. This is used only for testing while developing but + better to keep it up to date. ## :keyboard: Commands