1
0
forked from finn/site
site/backend/README.md

65 lines
1.4 KiB
Markdown
Raw Normal View History

2024-08-02 05:21:07 +00: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
2024-08-01 13:35:28 +00:00
2024-08-01 10:53:33 +00:00
2024-08-02 05:21:07 +00:00
## pip:
2024-08-03 15:37:27 +00:00
mariadb may take extra work: gcc, libmariadb-dev
2024-08-01 10:53:33 +00:00
```
2024-08-01 06:56:27 +00:00
pip install flask
pip install python-dotenv
2024-08-01 10:53:33 +00:00
pip install flask-wtf
2024-08-01 13:35:28 +00:00
pip install flask-sqlalchemy
pip install flask-migrate
2024-08-01 18:10:49 +00:00
pip install flask-login
pip install email-validator
2024-08-03 09:14:20 +00:00
pip install pydenticon
2024-08-03 15:37:27 +00:00
pip install mariadb
2024-08-02 05:21:07 +00:00
...
2024-08-01 13:35:28 +00:00
pip freeze > requirements.txt
```
2024-08-02 05:21:07 +00:00
## db cheat:
2024-08-03 12:38:58 +00:00
After db schema change:
2024-08-01 10:53:33 +00:00
```
2024-08-03 12:38:58 +00:00
flask db migrate -m "add users table"
2024-08-01 13:35:28 +00:00
flask db upgrade
2024-08-03 12:38:58 +00:00
```
2024-08-01 13:35:28 +00:00
2024-08-03 12:38:58 +00:00
Dump data if db in good state:
```
flask db downgrade base
2024-08-01 13:35:28 +00:00
flask db upgrade
2024-08-03 12:38:58 +00:00
```
2024-08-03 11:59:05 +00:00
2024-08-03 12:38:58 +00:00
Full reset:
```
2024-08-03 11:59:05 +00:00
rm app.db
rm -r migrations
flask db init
flask db migrate
flask db upgrade
2024-08-01 13:35:28 +00:00
```
2024-08-03 12:38:58 +00:00
2024-08-02 05:21:07 +00:00
## build notes:
Dockerfile needs dockerignore or preferably explicitly defined copies for:
- app
- config
- project dir
- requirements
- not dotflaskenv, vars set with dockerfile
2024-08-03 18:45:37 +00:00
## docker setup:
- py logger handler StreamHandler is buggy to the point of being useless. Use logfile and link to stdout in Docker build
2024-08-02 05:21:07 +00:00
## 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