This project provides a containerized Ruby development environment that seamlessly integrates with your local machine while maintaining isolation and consistency. It's designed to make Ruby development easier by handling common development tasks in a containerized environment, preventing "works on my machine" issues.
- Complete Ruby 3.1 environment with essential development tools
- Automatic bundle management and gem caching
- Concurrent installation protection with lock files
- Seamless integration with local filesystem
- MacOS path compatibility built-in
- Automatic bundle installation and updates (every 24 hours)
- Intelligent configuration file detection (e.g., .rubocop.yml)
- Proper exit code and signal handling
- Environment variable preservation
- Ruby command execution
- Interactive Ruby console (IRB)
- Rails commands
- RSpec test runner
- Rubocop with automatic config detection
- Rake task execution
- Test Kitchen for Chef development
- Bundle management
- Gem handling
- Added shared lock volume (
ruby_dev_locks
) to prevent concurrent bundle installations - Improved lock file management across containers
- Better handling of environment variables
- Enhanced error handling and cleanup
- Consistent volume mounting across all commands
- Clone the repository:
git clone <repository-url>
cd <repository-name>
- Build the Docker image:
docker build --build-arg USER=$(whoami) -t ruby-dev .
- Create required Docker volumes:
docker volume create bundle_cache31
docker volume create ruby_dev_locks
- Install the function definitions:
echo "source \"$HOME/.ruby-functions.zsh\"" >> ~/.zshrc
source ~/.zshrc
# Run Ruby script
ruby script.rb
# Start interactive console
irb
# Execute gem commands
gem list
# Create new Rails application
rails new myapp
# Start Rails server
rails server
# Run Rails console
rails console
# Run RSpec tests
rspec
# Run Rubocop with automatic config detection
rubocop
# Run specific Rubocop checks
rubocop app/models
# Install dependencies
bundle install
# Update gems
bundle update
# Execute commands through bundle
bundle exec rake db:migrate
bundle_cache31
: Persists installed gemsruby_dev_locks
: Manages concurrent operations- Local filesystem mounting: Maps your home directory
The environment uses a sophisticated locking system to prevent concurrent bundle installations:
- Lock files are stored in a dedicated Docker volume
- Each project gets a unique lock based on its path
- Automatic cleanup ensures no orphaned locks
- Built-in timeout and retry mechanism
- Preserves local environment variables
- Maintains proper locale settings
- Handles path translations between host and container
- Lock files not clearing:
docker volume rm ruby_dev_locks
docker volume create ruby_dev_locks
- Bundle cache issues:
docker volume rm bundle_cache31
docker volume create bundle_cache31
- Permission problems:
docker build --build-arg USER=$(whoami) -t ruby-dev .
Contributions are welcome! Please feel free to submit pull requests with improvements or bug fixes.
This project is licensed under the MIT License - see the LICENSE file for details.
When modifying the entrypoint:
- Maintain the use of
exec
for proper signal handling - Consider bundle context requirements
- Preserve argument passing with
"${@:2}"
- Add appropriate error handling
- Document new commands and their usage