What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The safest FastAPI deployment pipeline builds and tests every change, publishes an immutable container image, deploys that image to staging, verifies the running API, and promotes the same image to production only after approval. GitHub Actions supplies the automation; environments, secrets, concurrency controls, and a deliberate rollback path supply the safety.

What the pipeline should do

Continuous deployment means automatically publishing and deploying an update after automated build and test steps. For a FastAPI service, separate validation from release promotion:

  1. Pull request validation: install a pinned Python version, run formatting and lint checks, execute API tests, and optionally build the Docker image.
  2. Release build: on a protected branch or release tag, rebuild the image and tag it with the commit SHA (or release tag).
  3. Staging deployment: push the image to a registry, update the staging service, run a health or smoke check, and retain the resulting image digest and logs.
  4. Production promotion: require approval for the production environment, then deploy the already-built digest rather than rebuilding different bits.
  5. Rollback: keep the previous digest or release tag and expose rollback as a separate, manually dispatched operation.

This arrangement makes a failed test stop before publication and makes a failed staging check stop before production.

Package FastAPI as a deployable image

FastAPI’s documented container pattern starts with the official Python image, installs dependencies in a cache-friendly layer, copies application code, and launches FastAPI with an exec-form command. The current example uses Python 3.14, /code as the working directory, and port 80.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
FROM python:3.14

WORKDIR /code

COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

COPY ./app /code/app

CMD ["fastapi", "run", "app/main.py", "--port", "80"]

Why the Dockerfile is ordered this way

  • Copying requirements.txt before application files lets Docker reuse the dependency layer when only source code changes.
  • The exec form of CMD starts the server as the container’s main process, allowing graceful shutdown and FastAPI lifespan events to run correctly.
  • Build from the official Python image for new deployments. The deprecated tiangolo/uvicorn-gunicorn-fastapi image should not be selected for a new service.

Pin dependencies in your requirements file and keep the image tag tied to a source revision. A mutable tag such as latest is useful for local experimentation but is not a reliable production release identifier.

Design the repository workflow

A minimal repository might contain app/main.py, requirements.txt, tests, a Dockerfile, and workflows under .github/workflows/. The following workflow demonstrates pull-request checks, a protected release, staging deployment, and production promotion. Replace the placeholder commands with the commands for your registry and service.

name: fastapi-deploy

on:
  pull_request:
  push:
    branches: [main]
    tags: ['v*.*.*']
  workflow_dispatch:
    inputs:
      rollback_digest:
        description: 'Optional image digest to redeploy'
        required: false
        type: string

permissions:
  contents: read
  packages: write

concurrency:
  group: fastapi-${{ github.event.inputs.environment || 'production' }}
  cancel-in-progress: false

jobs:
  test:
    if: github.event_name == 'pull_request'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.13'
          cache: pip
      - run: pip install -r requirements.txt
      - run: ruff check .
      - run: pytest -q
      - run: docker build --tag fastapi:ci .

  build:
    if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
    runs-on: ubuntu-latest
    outputs:
      image: ${{ steps.image.outputs.image }}
    steps:
      - uses: actions/checkout@v4
      - id: image
        run: echo "image=${{ secrets.REGISTRY }}/fastapi:${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
      - run: docker build --tag "${{ steps.image.outputs.image }}" .
      - run: echo "Push the image and record its immutable digest here"

  staging:
    needs: build
    runs-on: ubuntu-latest
    environment: staging
    steps:
      - run: echo "Update the staging service to ${{ needs.build.outputs.image }}"
      - run: curl --fail --retry 10 --retry-delay 5 https://staging.example.com/health

  production:
    needs: staging
    runs-on: ubuntu-latest
    environment: production
    steps:
      - run: echo "Deploy the exact image digest tested in staging"

The sample intentionally leaves registry and platform commands as deployment-specific steps. Do not copy credentials into those commands or into the repository.

Rank #2
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
  • Easily store and access 5TB of content on the go with the Seagate portable drive, a USB external hard Drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Triggers and branch policy

  • pull_request runs checks before merge.
  • push to a protected branch or a version tag starts a release.
  • workflow_dispatch supports an operator-triggered deployment or rollback.

Protect the release branch so production cannot be changed by an unreviewed push. If you release from tags, protect tag creation as well.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Build, publish, and promote one immutable image

Use a deterministic tag

Tag each release with the commit SHA or an immutable release tag. After pushing, capture the registry digest (for example, a content-addressed sha256 value) and pass that digest between jobs. Staging and production should reference the same digest; rebuilding during promotion can introduce untested dependency or base-image changes.

Authenticate without long-lived keys

Put registry credentials, cloud role information, deploy tokens, application IDs, database URLs, and signing keys in GitHub repository or environment secrets. Environment secrets are preferable for production because they can be restricted to the production environment and its approval rules. Never commit a secret to YAML, a Dockerfile, test fixtures, or an image layer.

Rank #3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
  • Easily store and access 1TB to content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop. Reformatting may be required for Mac
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Verify the running service

Expose a lightweight health endpoint that checks process readiness and, where appropriate, required dependencies. After the staging service reports healthy, exercise one representative API request. Keep deployment logs and the image digest so an incident can be mapped to the exact release.

A concrete AWS route: ECR to ECS

A common managed-container path is:

  1. Build the FastAPI image in GitHub Actions.
  2. Authenticate to Amazon Elastic Container Registry (ECR).
  3. Push the SHA-tagged image and record its digest.
  4. Update the staging Amazon Elastic Container Service (ECS) task or service to that digest.
  5. Wait for the service to become healthy and run the staging smoke check.
  6. After the production environment approval, update the production ECS service to the same digest.

Keep staging and production as separate ECS services, task definitions, configuration, and secrets. The workflow’s cloud identity needs only the permissions required to push to ECR and update the relevant ECS services. Prefer short-lived identity federation where your AWS setup supports it instead of storing a permanent access key.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What the workflow must retain

  • The ECR repository and immutable image digest.
  • The ECS task-definition revision used in each environment.
  • Health-check output and deployment logs.
  • The preceding production digest for immediate rollback.

Protect production with environments and concurrency

Create staging and production environments in repository settings. Allow staging to deploy automatically. Configure production with required reviewers or other protection rules, and attach production-only secrets there.

Rank #4
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue
  • Easily store and access 4TB of content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Set a concurrency group keyed to the environment. A second production deployment should wait for (or replace, according to your policy) the first rather than racing it. Serializing deployments prevents an older workflow from finishing after a newer release and silently reverting the service.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Rollback without rebuilding

  1. Identify the currently running digest and the last known-good digest from deployment records.
  2. Dispatch the rollback workflow with the known-good digest (or select the previous release tag).
  3. Deploy that exact digest to staging first when time permits; otherwise use your incident policy for an emergency production rollback.
  4. Run the health and smoke checks, then record the incident, failed release, and restored digest.

Rollback is not a new build. Keeping old registry images available and retaining the previous task-definition revision makes recovery a change of reference, not a race against a broken source tree.

Choose where the container runs

Target Operational ownership Scaling and resilience Complexity and cost considerations
Single VM with Docker Compose You patch the host, manage TLS, backups, restarts, and monitoring. Simple vertical scaling; replication and failover are your responsibility. Lowest platform complexity, but staff time and outage risk can be higher.
Managed container service such as ECS The platform schedules tasks and handles many restart and capacity concerns. Built-in service replication and integration with load balancing vary by configuration. Moderate configuration and usage cost; less host maintenance.
Kubernetes You operate cluster policies, networking, upgrades, and observability. Flexible replication, rollout, and placement controls. Highest operational complexity; justified when platform requirements demand it.
Managed FastAPI service The provider manages much of the runtime and deployment surface. Scaling, regions, and rollback depend on the provider’s features. Fastest route to operation, with provider-specific limits and recurring service cost.

Compare candidates on operational ownership, replication, approval workflow, observability, rollback speed, regional availability, and total cost—not just the first deployment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Production checklist

  • Tests and linting pass on every pull request.
  • Dependencies and the runtime version are pinned and reproducible.
  • The image is tagged by commit or release and promoted by digest.
  • Staging deploys before production and performs a real smoke check.
  • Production requires an environment approval or equivalent protection.
  • Secrets live in GitHub or cloud secret configuration, never source control.
  • Concurrency prevents overlapping deployments per environment.
  • Logs, health results, task revisions, and image digests are retained.
  • A manually dispatched rollback can redeploy the previous known-good digest.

The Bottom Line

Use GitHub Actions to make every FastAPI release reproducible: test first, build once, promote the same image digest through staging and approved production, and keep the previous digest ready for rollback.

Quick Recap

SaleBestseller No. 1
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.99
Bestseller No. 2
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$229.99
Bestseller No. 3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.80
Bestseller No. 4
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$189.98

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.