Skip to content

Update Dockerfile: Python 3.12, reduce layers, add prestart.sh#59

Open
snowball77 wants to merge 2 commits into
FIUS:masterfrom
snowball77:improve-dockerfile
Open

Update Dockerfile: Python 3.12, reduce layers, add prestart.sh#59
snowball77 wants to merge 2 commits into
FIUS:masterfrom
snowball77:improve-dockerfile

Conversation

@snowball77

Copy link
Copy Markdown

Changes

Python 3.9 → 3.12

Python 3.9 reached end-of-life in October 2025. This updates the base image to python3.12, the latest available tag for tiangolo/uwsgi-nginx-flask.

Reduced layer count

  • Combined Poetry setup (venv create, pip install, config) into a single RUN layer
  • Combined three mkdir calls into one
  • Combined COPY statements where possible

Add docker/prestart.sh

The base image (tiangolo/uwsgi-nginx-flask) automatically executes /app/prestart.sh before starting the server. This is the proper place for DB initialization, rather than running code at module import time (as proposed in #58).

flask db upgrade 2>/dev/null || flask create_db

Tries flask db upgrade first (for setups using Flask-Migrate), falls back to flask create_db if no migrations are present.

- Update base image from python3.9 (EOL) to python3.12
- Combine Poetry setup into a single RUN layer
- Combine mkdir calls into one
- Combine COPY statements where possible
- Add docker/prestart.sh to initialize DB on container start
  (runs 'flask db upgrade' with fallback to 'flask create_db')

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
python3.12 is incompatible with the pinned dependency versions
(python-dateutil requires six, distutils removed). python3.11 is
supported until October 2027 and works with the current poetry.lock.

Upgrading to python3.12 would require updating the dependencies.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@snowball77

Copy link
Copy Markdown
Author

Kurze Erklärung zum Downgrade von 3.12 auf 3.11:

Beim Testen hat sich herausgestellt, dass die aktuell in poetry.lock gepinnten Dependency-Versionen nicht mit Python 3.12 kompatibel sind:

  1. distutils entfernt: Python 3.12 hat distutils aus der Standardbibliothek entfernt, Flask-Babel 2.x nutzt es aber noch beim Kompilieren der Translations.
  2. six nicht gefunden: python-dateutil (transitive Dependency über Flask-Migratealembic) importiert six.moves, was ebenfalls fehlschlägt.

Python 3.11 ist bis Oktober 2027 supported und funktioniert mit dem aktuellen poetry.lock problemlos. Ein Upgrade auf 3.12 würde ein Dependency-Update (u.a. Flask-Babel 3.x+, neueres python-dateutil) erfordern und ist besser als eigener PR scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant