A Flask app that automatically reloads my docker containers
This project arose from the need and want to manage some of my other projects. I like to self host my discord bots to save some money on cloud compute costs. I came up with a lit of other problems I wanted to solve as well.
- I want my projects to automatically update when I push new code
- Changing and reloading my project can be done without direct access to my server
- My app should be secure
- Deploying the project itself shouldn't be too much of a hassle
Should be located in
.env
Note
This file can also be automatically generated by the setup script
FLASK_DEV_FOLDER # Path to directory to host files
FLASK_SECRET_KEY # Key to verify, use src/secret_key.py to generate
FLASK_AUTH_USERNAME # Admin Username
FLASK_AUTH_PASSWORD # Admin Password
FLASK_DOCKER_RELOAD_SCRIPT # Location to docker reload script- Setup
venv
python3 -m venv .venv
source .venv/bin/activate- Install dependencies
pip install -r requirements.txt- Install Gunicorn
pip install gunicorn- Start Gunicorn in the background
nohup gunicorn -w 4 'server.main:app' > gunicorn.log 2>&1 &./scripts/createsocket.sh <username> <server-ip-domain>
source .venv/bin/activate
pip install -r requirements.txt
pip install gunicornpython3 -m flask --app server --debug runnohup gh webhook forward --repo=aaatipamula/REPOSITORY-NAME --events=pull_request --url=http://localhost:5000/webhooks &