Python web deployment automation

Capistrano-style deployments for Django and FastAPI apps

Define repeatable SSH-based deployment workflows for Django and FastAPI projects with simple YAML playbooks.

  • YAML configs live with your deployment files
  • Setup and deploy over SSH
  • Release directories keep recovery options visible
pystrano deploy production api
$ pystrano deploy production api
✓ Connecting to production api (app1.example.com)
✓ Prepared release directory
✓ Pulled branch main
✓ Synced shared assets and env file
✓ Installed Python dependencies
✓ Applied migrations and refreshed static assets
✓ Promoted release to current
✓ Restarted gunicorn.service
✅ Deployment completed in 42s
Pystrano 2 supports framework-specific workflows for Django and FastAPI, including pip and uv dependency installation.
Why Pystrano?

A small tool for repeatable Python web deploys.

Pystrano automates the SSH deployment steps you would otherwise keep in shell notes: prepare a server, create timestamped releases, install dependencies, run framework steps, update the active release, and restart the app service.

YAML configuration

Keep common defaults and server overrides in deploy/<app>/<environment>/deployment.yml.

Framework deployment steps

Run setup once, then deploy releases that install dependencies with pip or uv, run framework tasks, and restart systemd.

Rollback-aware structure

Deploys create timestamped release directories and promote the active release with a current symlink. A rollback CLI command is not exposed yet.

Workflow

Configure, preview, deploy.

Pystrano assumes you already have SSH access to a VPS-style server and know where your app should live.

1
Create deployment config

Use pystrano init production api to build a version 2 config, deployment settings, and a starter systemd service file.

2
Run setup

Use pystrano setup production api to create the deploy user, directories, packages, virtualenv, known hosts, and optional service files.

3
Deploy releases

Use pystrano deploy production api to clone code, install dependencies, run framework tasks, promote the release, and prune old releases.

Documentation

Start with your framework path.

The docs cover supported Django and FastAPI deployments over SSH with systemd on VPS-style servers.

Configuration sample
config_version: 2

common:
  source_code_url: "git@github.com:example/example-django-app.git"
  framework: "django"
  project_root: "apps/example-django-app"
  project_user: "deploy"
  venv_dir: ".venv"
  package_manager: "pip"
  dependency_file: "requirements.txt"
  keep_releases: 5
  system_packages: |
    libpq-dev
    python3-dev
    build-essential
  env_file: "./deploy/api/production/.env"
  ssh_known_hosts: "github.com"
  service_file: "./deploy/api/production/gunicorn.service"
  branch: "main"
  clone_depth: 1

servers:
  - host: "app1.example.com"
    port: 22
    run_migrations: true
    collect_static_files: true
pystrano setup production api --dry-run
pystrano deploy production api --dry-run

Build a repeatable Django or FastAPI deploy.

Install Pystrano, create a deployment config, preview the remote commands, then run setup and deploy when your server is ready.