A quick start template with some examples.
python3 -m venv env
source env/bin/activate
pip install -r requirements.txtexport FLASK_APP=src/server.py
export FLASK_ENV=development
flask run -h 127.0.0.1 -p 8888black .mypy .Using docker compose to start all related services.
# build
docker-compose build
# run
docker-compose up
# or run in detached mode
docker-compose up -d
# logs
docker-compose logs -f
# tear down
docker-compose downSelect Local configuration to debug flask app locally.
If you want to debug flask app running in the container, you need select Remote Attach(Container) configuration and modify the docker-compose.yml:
environment:
- FLASK_ENV=development
# - DEBUG=True
# ports:
# - "5678:5678"change to:
environment:
# - FLASK_ENV=development
- DEBUG=True
ports:
- "5678:5678"gunicorn server:app
# run in background
gunicorn -D server:appUsing crontab to schedule jobs.
Cronjob image is described in cronjobs/Dockerfile.
Cronjob setting is described in cronjobs/cron.
An example job is located in cronjobs/job.py.