Skip to content

Setup CD Pipeline (Containerization and Automated Deployment) #18

@aniebietafia

Description

@aniebietafia

Problem

Currently, the application must be manually deployed to any target environment. There is no Dockerfile for the application, and no automated process to push code from the repository to a running instance. This leads to configuration drift and slow release cycles.

Proposed Solution

Implement a CD pipeline using GitHub Actions that builds a Docker image of the application and deploys it to a target hosting environment (e.g., AWS, GCP, or a VPS). This will include creating a production-ready Dockerfile.

User Stories

  • As a developer, I want my changes to be automatically deployed to a staging environment after passing CI tests.
  • As a maintainer, I want a reliable, reproducible way to package and deploy the application.

Acceptance Criteria

  • Dockerfile and .dockerignore are created for the FastAPI application.
  • GitHub Actions workflow file .github/workflows/cd.yml is created.
  • Workflow triggers on successful completion of the CI workflow on the main branch.
  • Build Step: Builds a Docker image and pushes it to a container registry (e.g., Docker Hub, ECR).
  • Deploy Step: Deploys the new image to the target environment (e.g., via SSH, Terraform, or cloud-specific actions).
  • Health Check: Workflow verifies the deployment with a health check request.
  • Production environment variables are securely managed via GitHub Secrets.

Proposed Technical Details

  • Use multi-stage Docker builds to keep the image size small.
  • Use actions/checkout@v4, docker/setup-buildx-action@v3, and docker/login-action@v3.
  • Configure the workflow to use repository secrets for sensitive data (API keys, DB URLs).
  • Ensure the database migrations (alembic upgrade head) are part of the deployment process.

Tasks

  • Create a production-ready Dockerfile.
  • Create .dockerignore to exclude development files.
  • Initialize .github/workflows/cd.yml.
  • Setup container registry credentials in GitHub Secrets.
  • Implement image build and push logic.
  • Implement deployment logic (e.g., docker-compose up -d on a remote server).
  • Document the CD process in the project's README or a new DEPLOYMENT.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions