Automated CI/CD deployment to Fly.io. Push to master and your app deploys in ~2 minutes.
Sign up at https://fly.io and install the CLI:
# macOS
brew install flyctl
# Linux/WSL
curl -L https://fly.io/install.sh | shLogin:
flyctl auth loginflyctl apps create your-app-name# Create database
flyctl postgres create --name your-app-name-db --region iad --initial-cluster-size 1 --vm-size shared-cpu-1x --volume-size 1
# Attach to your app (sets DATABASE_URL automatically)
flyctl postgres attach your-app-name-db -a your-app-name# Required secrets
flyctl secrets set -a your-app-name \
SECRET_KEY="$(openssl rand -hex 32)" \
SECURITY_PASSWORD_SALT="$(openssl rand -hex 32)" \
SECURITY_TOTP_SECRETS="$(openssl rand -hex 32)"
# Fix database URL (Fly uses postgres://, SQLAlchemy needs postgresql://)
# Get the DATABASE_URL from: flyctl secrets list -a your-app-name
# Then set SQLALCHEMY_DATABASE_URI with postgresql:// prefix:
flyctl secrets set -a your-app-name \
SQLALCHEMY_DATABASE_URI="postgresql://user:pass@your-app-name-db.flycast:5432/your-app-name?sslmode=disable"Edit fly.toml and change the app name:
app = 'your-app-name' # Change this-
Create deploy token:
flyctl tokens create deploy -x 999h -a your-app-name
-
Add to GitHub:
- Go to your repo → Settings → Secrets and variables → Actions
- New repository secret:
FLY_API_TOKEN= (paste token)
Go to Actions tab in your GitHub repo → "Deploy to Fly.io" → "Run workflow"
Your app will be live at: https://your-app-name.fly.dev
Optional: Auto-deploy on push
Edit .github/workflows/deploy-fly.yml and uncomment the push trigger:
on:
workflow_dispatch:
push:
branches: [master]SSH into your app and create the admin:
flyctl ssh console -a your-app-name
python -c "from run import app; from enferno.commands import create_db, install; app.app_context().push(); create_db(); install()"Or run interactively:
flyctl ssh console -a your-app-name -C "flask create-db && flask install"For sessions and Celery background tasks:
flyctl redis create --name your-app-name-redis --region iad --no-replicasThen set the Redis secrets:
flyctl secrets set -a your-app-name \
REDIS_URL="redis://..." \
CELERY_BROKER_URL="redis://..." \
CELERY_RESULT_BACKEND="redis://..."flyctl logs -a your-app-nameflyctl ssh console -a your-app-nameflyctl status -a your-app-nameflyctl deploy -a your-app-name