Skip to main content

CLI tool for setting up deployment of FastAPI applications

Project description

FastAPI Deploy CLI

A command-line tool for setting up automated deployment of FastAPI applications using Docker, Docker Compose, and GitHub Actions.

Features

  • Supports both pip and uv package managers
  • Configures GitHub Actions for CI/CD
  • Support for separate test and production environments
  • Automatic PR creation from test to production
  • Automatically sets up GitHub secrets for deployment
  • Creates Dockerfile and docker-compose.yml files
  • Sets up secure deployment with Traefik
  • Custom domain and port configuration
  • Dynamic environment variable handling
  • Interactive CLI with arrow key selection

Installation

# Install from PyPI
pip install fastapi-deploy-cli

# Or using uv
uv pip install fastapi-deploy-cli

# Or install from source
git clone https://github.com/your-username/fastapi-deploy-cli.git
cd fastapi-deploy-cli
pip install -e .

Usage

Initialize a new deployment setup

# Navigate to your FastAPI project directory
cd your-fastapi-project

# Run the initialization command
fastapi-deploy init

The CLI will guide you through the setup process:

  1. Choose your package manager (pip or uv) using arrow keys
  2. Specify the path to your .env file
  3. Configure application domain and port
  4. Set up production environment (optional)
  5. Set up GitHub repository and Personal Access Token
  6. Add secrets to GitHub repository
  7. Create necessary deployment files

Update deployment files

fastapi-deploy update

The update command allows you to:

  1. Change your package manager
  2. Update your domain and port settings
  3. Update GitHub secrets
  4. Refresh deployment files with the latest configurations

Required Environment Variables

Before using the CLI, create an .env file with the following variables:

SERVER_HOST=your-server-hostname
SERVER_USER=your-server-username
SSH_PRIVATE_KEY=your-private-key
PAT=your-github-personal-access-token  # Required for production branch automation

Additional environment variables will be automatically detected and included in deployment files.

Domain and Port Configuration

The CLI prompts you to specify:

  • Application domain (e.g., api.example.com)
  • Application port (e.g., 8001)

If production environment is enabled:

  • Production domain (e.g., prod-api.example.com)
  • Production port (e.g., 8002)

These settings are automatically applied to:

  • Docker Compose configuration
  • Dockerfile CMD command
  • Traefik routing settings

GitHub Actions Workflow

Standard Deployment

The CLI sets up a GitHub Actions workflow that:

  1. Checks out your code
  2. Prepares files for deployment
  3. Copies files to your server via SSH
  4. Builds and starts Docker containers
  5. Performs cleanup

Production Deployment (Optional)

When enabled, the production deployment workflow:

  1. Performs standard deployment to test environment
  2. Creates or updates a production branch
  3. Generates a Pull Request with domain and port changes for production
  4. When merged, deploys to production environment

This creates a proper CI/CD pipeline with test-to-production promotion via PR review.

Requirements

  • Python 3.8+
  • A FastAPI application
  • A GitHub repository
  • A GitHub Personal Access Token with repo and workflow scopes
  • A server with SSH access and Docker installed
  • Traefik running on your server (for routing)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_deploy_cli-0.2.0.tar.gz (49.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_deploy_cli-0.2.0-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_deploy_cli-0.2.0.tar.gz.

File metadata

  • Download URL: fastapi_deploy_cli-0.2.0.tar.gz
  • Upload date:
  • Size: 49.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for fastapi_deploy_cli-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4d834321a6362f6911839d46a4cc3fd23d51d30074fc9118be0a28327396d6ed
MD5 e0d441db7225b6577502a9d285b76b4b
BLAKE2b-256 4d1b627082f7c4df94e2ced129742663394796a7499aca4f9f88a043ebde4fc1

See more details on using hashes here.

File details

Details for the file fastapi_deploy_cli-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_deploy_cli-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b0b42603b80506ac1e95b199d75d0667c82d6e52d93b1b0c2e5d8dc281ce7b1
MD5 5b32655662ff8e3979d28d709c3d38a1
BLAKE2b-256 343bf00639b3513842435942ca7b3dfac13e539b5dc7747b94c1a2125f8c7862

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page