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/ diff --git a/README.md b/README.md index cfcecfd..2e48f1b 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 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 +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,19 +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 -``` + 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 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 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