Create and active virtual enviroment using venv library:
python3 -m venv .venv
source .venv/bin/activate (Linux)
.venv\Scripts\activate (Windows)
In some Windows cases before activating venv:
Set-ExecutionPolicy Unrestricted -Scope Process
Linux/MacOS
export FLASK_APP=flaskr/run.py
export FLASK_DEBUG="True"
Windows cmd
set FLASK_APP=flaskr/run.py
set FLASK_DEBUG="True"
Windows powershell
$env:FLASK_APP="flaskr/run.py"
$env:FLASK_DEBUG="True"
Install app as library in development mode using setuptool
python -m pip install -e .[dev]
Build package (run command each time after changes anmd before building image from Dockerfile)
python setup.py bdist_wheel
docker run --name postgres_workshops -e POSTGRES_DB=dev_database -e POSTGRES_USER=dev_user -e POSTGRES_PASSWORD=dev_pass -p 5432:5432 -d postgres:14
flask run
pytest tests
Pytlint
python -m pylint flaskr tests
Black check
python -m black --check .
Black fix
python -m black .
Start all containers
docker-compose up
Stop all containers
docker-compose down
Apply k8 resources
kubectl apply -f .\postgres-config.yaml
kubectl apply -f .\postgres-secret.yaml
kubectl apply -f .\postgres.yaml
kubectl apply -f .\flask-app.yaml
Delete k8 resources
kubectl delete -f .\postgres-config.yaml
kubectl delete -f .\postgres-secret.yaml
kubectl delete -f .\postgres.yaml
kubectl delete -f .\flask-app.yaml
docker build -t flask-app:v1 .
App
http://localhost:5000/