sanataro icon indicating copy to clipboard operation
sanataro copied to clipboard

Add Docker Compose support for development with separate containers

Open Copilot opened this issue 6 months ago • 1 comments

This PR implements comprehensive Docker Compose support for development, providing separate containers for each functionality as requested in the issue.

🐳 Services Implemented

  • webapp-mysql: Rails application with MySQL database (accessible at http://localhost:3000)
  • webapp-postgresql: Rails application with PostgreSQL database (accessible at http://localhost:3001)
  • db-mysql: MySQL 8.0 database server
  • db-postgresql: PostgreSQL 13 database server
  • redis: Redis cache server for production-like development

📁 Files Added

  • Dockerfile: Optimized Rails container with all necessary dependencies
  • docker-compose.yml: Complete service orchestration with health checks
  • entrypoint.sh: Smart database initialization and wait logic
  • config/database.yml.docker: Environment-based database configuration
  • docker-dev.sh: Developer-friendly command interface
  • test-docker-setup.sh: Comprehensive validation suite
  • demo-docker-setup.sh: Setup demonstration script
  • .dockerignore: Optimized build context
  • .env.example: Configuration template with all available options

🚀 Usage

Quick Start

# Start with MySQL
./docker-dev.sh up-mysql

# Start with PostgreSQL
./docker-dev.sh up-postgres

Development Commands

./docker-dev.sh shell-mysql      # Open development shell
./docker-dev.sh console-postgres # Rails console with PostgreSQL
./docker-dev.sh test-mysql       # Run tests with MySQL
./docker-dev.sh logs             # View all service logs
./docker-dev.sh down             # Stop all services
./docker-dev.sh clean            # Remove containers and volumes

Manual Docker Compose

docker compose up db-mysql redis webapp-mysql
docker compose exec webapp-mysql bundle exec rails console

🔧 Key Features

  • Separate containers for each database backend (MySQL/PostgreSQL)
  • Health checks ensure databases are ready before app startup
  • Volume mounting for live code reloading during development
  • Environment-based configuration using ERB templates
  • Comprehensive validation with automated tests
  • Preserved compatibility with existing development workflow

📚 Documentation

Updated README.rdoc with comprehensive Docker setup instructions while maintaining all existing installation methods. The original development workflow remains unchanged.

✅ Validation

All Docker Compose configurations have been validated:

  • Service definitions are correct and functional
  • Database configurations render properly for both MySQL and PostgreSQL
  • No conflicts with existing development setup
  • All validation tests pass

Fixes #105.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot avatar Aug 07 '25 05:08 Copilot