Skip to content

[feat:ci/cd] Add GitHub Actions for Automated Docker Image Building #124

Description

@majcheradam

🐳 Add GitHub Actions for Automated Docker Image Building

Problem Statement

Currently, the project requires manual Docker image building and distribution. Users need to build images locally using docker-compose.

Proposed Solution

Implement a comprehensive GitHub Actions workflow that automatically builds and publishes Docker images to GitHub Container Registry.

Features to Add

🏗️ Production Dockerfiles

  • Dockerfile - Standard CPU-only image with multi-architecture support (AMD64/ARM64)
  • Dockerfile.gpu - GPU-enabled image with CUDA 11.8 support (AMD64 only)
  • Optimized for production with security best practices

⚙️ GitHub Actions Workflow

  • Automated building on push to main/develop branches
  • Build testing on pull requests (without publishing)
  • Multi-architecture builds (AMD64 + ARM64 for CPU images)
  • Automatic tagging based on Git events:
    • latest for main branch
    • develop for develop branch
    • v1.2.3 for version tags
    • pr-123 for pull requests

📦 Container Registry Integration

  • Publish to GitHub Container Registry (ghcr.io)
  • Proper image tagging and versioning
  • Layer caching for faster builds
  • Security scanning integration

🚀 Production Configurations

  • docker-compose.prod.yml using pre-built images
  • .env.prod.example template for production deployments
  • Health check endpoints for container monitoring

📚 Documentation

  • Comprehensive build guide (DOCKER_BUILD_GUIDE.md)
  • Usage examples and troubleshooting
  • Architecture support matrix

Benefits

  1. 🚀 Faster Deployment: Users can pull pre-built images instead of building locally
  2. 🔄 Consistent Builds: All images built in standardized GitHub environment
  3. 🛡️ Security: Production hardened images with non-root users
  4. 📈 Scalability: Multi-architecture support for different deployment targets
  5. 🔧 Developer Experience: Simplified setup for contributors and users
  6. 🎯 CI/CD Ready: Foundation for automated testing and deployment

Technical Details

Image Variants

  • Standard Image: ghcr.io/catchthetornado/text-extract-api:latest

    • Python 3.10 slim base
    • CPU-only processing
    • Multi-architecture (AMD64/ARM64)
  • GPU Image: ghcr.io/catchthetornado/text-extract-api-gpu:latest

    • NVIDIA CUDA 11.8 base
    • GPU-accelerated processing
    • AMD64 architecture only

Workflow Triggers

  • Push to main → Build and publish latest images
  • Push to develop → Build and publish develop images
  • Git tags (v*) → Build and publish versioned images
  • Pull requests → Build and test (no publish)

Security Features

  • Non-root user execution (appuser)
  • Minimal attack surface with slim base images
  • Health check endpoints for monitoring
  • Secure layer caching and optimization

Implementation Checklist

  • Create production Dockerfile
  • Create GPU-enabled Dockerfile.gpu
  • Implement GitHub Actions workflow (.github/workflows/docker-build.yml)
  • Add health check endpoint to FastAPI application
  • Create production Docker Compose configuration
  • Add comprehensive documentation
  • Update .dockerignore for optimized builds
  • Create environment template for production
  • Test workflow with sample builds

Success Criteria

Automated Builds: Images build automatically on code changes
Multi-Platform: CPU images work on both Intel/AMD and Apple Silicon
GPU Support: GPU images work with NVIDIA Docker runtime
Documentation: Clear setup and usage instructions
Testing: PR builds validate Docker configurations
Production Ready: Images suitable for production deployment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions