MarkSthFun manages recurring payments via Stripe.
MarkSthFun is running on PostgreSQL 12 as of 2019.
1. MarkSthFun is a monolithic app, hosting in a single repo. It'll be deployed as a web app, a worker app, a blog app, etc.
2. Sys dependencies are explicitly specified in ansible/dockerfile. App dependencies are specified in pyproject.toml.
3. Use .env widely. Terraform and ansible shares the same .env file. Docker-compose reads envvars from env_files. Flask reads envvars by `load_dotenv(find_dotenv())`. In production, /var/www/shire/shared/.env contains all envvars app needs.
4. Backing services are merely some envvars for each service.
5. Deploy code in a capistrano-style convention directory.
6. No containers, just processes.
7. Applications are bound to $PORT.
8. Terraform/Ansible provision and setup servers quickly by server roles. A new server will be quickly added to the server pool.
9. Graceful shutdown (gunicorn)
10. Dev env: local docker-compose. Staging env: heroku. Prod env: digitalocean.
11. For troubleshooting, just tail -f.
12. Admin process: poetry run flask shell.
MarkSthFun runs everything in docker-compose locally, using poetry as the dep manager and honcho as the process starter.
Ansistrano comes from Ansible + Capistrano. I made similar stuff, fapistrano, a Fabric-based Capistrano Python-clone two years ago, but ansistrano is much better by leveraging Ansible, which has larger community and ecosystem.
MarkSthFun manages hosts by Ansible.
* It gets a list of hosts by a dynamic inventory python script, an unmodified version of contrib/inventory/digital_ocean.py.
* Host groups are defined as DigitalOcean tags.
* Ansible-galaxy and ansible-console are heavily used on a daily basis.
Provision cloud services in minutes without clicking this and that. Type `terraform apply`, you get all cloud resources. Type `terraform destroy`, boom, all are gone. Very handy tool in modern days.
MarkSthFun applied Flask factory pattern. It uses a bunch of extensions, such as Flask-SQLAlchemy, Flask-Bcrypt, Whitenoises, etc.