1
0
forked from finn/site
site/backend
2024-08-04 13:14:58 -07:00
..
app mgt c9 complete 2024-08-04 13:14:58 -07:00
migrations mgt c6 done 2024-08-03 05:34:12 -07:00
.dockerignore mgt c8 checkpoint at tests 2024-08-04 05:44:20 -07:00
.flaskenv mgt c7 finish 2024-08-03 11:45:37 -07:00
config.py mgt c9 complete 2024-08-04 13:14:58 -07:00
dbdb.sh mgt c8 finish 2024-08-04 09:40:09 -07:00
Dockerfile mgt c8 finish 2024-08-04 09:40:09 -07:00
microblog.py mgt c4 2024-08-01 06:35:28 -07:00
oldapp.py begin mg tut framework in be 2024-07-31 23:56:27 -07:00
README.md mgt c8 checkpoint at tests 2024-08-04 05:44:20 -07:00
requirements.txt mgt c8 checkpoint at tests 2024-08-04 05:44:20 -07:00
tests.py mgt c8 checkpoint after tests 2024-08-04 05:48:02 -07:00

Workflow:

  • should work with flask run locally and dockerfile build
  • local dev
  • local / venv pip install
  • record versionless pips manually here
  • pip freeze snapshots into project requirements
  • docker build then copies frozen requirements

pip:

mariadb may take extra work: gcc, libmariadb-dev

pip install flask
pip install python-dotenv
pip install flask-wtf
pip install flask-sqlalchemy
pip install flask-migrate
pip install flask-login
pip install email-validator
pip install pydenticon
Prod only, require sys packages:
pip install mariadb
pip install uwsgi
...

Freeze/requirements.txt. Better to audit this inside python:3-bookworm-slim container.

pip freeze > requirements.txt

db cheat:

After db schema change:

flask db migrate -m "add users table"
flask db upgrade

Dump data if db in good state:

flask db downgrade base
flask db upgrade

Full reset or maria init:

sql:
drop table users;
drop table posts;
rm app.db
rm -r migrations
flask db init
flask db migrate
flask db upgrade

build notes:

Dockerfile needs dockerignore or preferably explicitly defined copies for:

  • app
  • config
  • project dir
  • requirements
  • not dotflaskenv, vars set with dockerfile

docker setup:

  • py logger handler StreamHandler is buggy to the point of being useless. Use logfile and link to stdout in Docker build

notes:

  • compose has entry that overrides flask with uwsgi for prod
  • miminal environment vars come through project env, pass through compose
  • no dotenv here, dotflaskenv goes into image
  • keep env untracked but templated, dotflaskenv is tracked and public