A modern Rails 7.1 application ready to deploy on Convox Cloud Machines or your own Convox Rack.
This example demonstrates a production-ready Rails application with PostgreSQL database, Redis caching, health checks, and a real-time dashboard. It showcases Rails best practices while being optimized for Convox deployment.
- Rails 7.1 with modern best practices
- PostgreSQL database with migrations and seeds
- User Management CRUD interface
- API Endpoints with JSON responses
- Health Monitoring with dedicated endpoints
- Dashboard showing real-time stats
- Docker Optimized for fast builds and small images
- Cloud Machine Ready with proper CPU/memory settings
-
Create a Cloud Machine at console.convox.com
-
Create the app:
convox cloud apps create rails-app -i your-machine-name- Set the secret key:
convox cloud env set SECRET_KEY_BASE=$(openssl rand -hex 64) -a rails-app -i your-machine-name- Deploy the app:
convox cloud deploy -a rails-app -i your-machine-name- Run database setup:
# Run migrations
convox cloud run web "bundle exec rails db:migrate" -a rails-app -i your-machine-name
# Seed the database (optional)
convox cloud run web "bundle exec rails db:seed" -a rails-app -i your-machine-name- View your app:
convox cloud services -a rails-app -i your-machine-nameVisit the URL to see your application running!
- Create the app:
convox apps create rails-app- Set the secret key:
convox env set SECRET_KEY_BASE=$(openssl rand -hex 64) -a rails-app- Deploy the app:
convox deploy -a rails-app- Run database setup:
# Run migrations
convox run web "bundle exec rails db:migrate" -a rails-app
# Seed the database (optional)
convox run web "bundle exec rails db:seed" -a rails-app- View your app:
convox services -a rails-appGET /- Dashboard with real-time statisticsGET /health- Health check endpointGET /api/status- System status JSONGET /users- User management interfaceGET /api/users- Users API endpointGET /api/stats- Application statistics
# Check health
curl https://your-app-url/health
# Get system status
curl https://your-app-url/api/status
# Get users list
curl https://your-app-url/api/users- Clone the repository:
git clone https://github.com/convox-examples/rails
cd rails- Start with Convox (no local Ruby/bundler needed!):
convox startThe app will be available at http://localhost:3000
Note: This example follows containerized best practices - all dependencies are installed inside Docker containers. You don't need Ruby, Node, or any dependencies installed locally.
# Scale horizontally
convox cloud scale web --count 3 -a rails-app -i your-machine-name
# Scale vertically
convox cloud scale web --cpu 500 --memory 1024 -a rails-app -i your-machine-name# Scale horizontally
convox scale web --count 3 -a rails-app
# Scale vertically
convox scale web --cpu 500 --memory 1024 -a rails-app# Cloud
convox cloud logs -a rails-app -i your-machine-name
# Rack
convox logs -a rails-app# Cloud
convox cloud run web "bundle exec rails console" -a rails-app -i your-machine-name
# Rack
convox run web "bundle exec rails console" -a rails-app# Cloud
convox cloud run web "bundle exec rails dbconsole" -a rails-app -i your-machine-name
# Rack
convox run web "bundle exec rails dbconsole" -a rails-app| Variable | Description | Required |
|---|---|---|
SECRET_KEY_BASE |
Rails secret key | Yes |
DATABASE_URL |
PostgreSQL connection (auto-set by Convox) | Auto |
RAILS_ENV |
Rails environment | Set to production |
RAILS_MAX_THREADS |
Max threads per worker | Optional (default: 5) |
Convox handles SSL termination at the load balancer level. The application receives plain HTTP traffic on port 3000. This is standard practice for containerized applications:
- Load Balancer: Handles HTTPS (port 443) with Let's Encrypt certificates
- Application: Receives HTTP (port 3000) from the load balancer
- Configuration:
config.force_ssl = falsewithconfig.assume_ssl = true
For simplicity, this example sets ALLOW_ALL_HOSTS=true to handle:
- Health checks from internal Kubernetes IPs
- Requests forwarded through the Convox load balancer
- Various Convox subdomain patterns
For production applications, you should restrict this to your specific domains.
If you see "Invalid HTTP format" or SSL-related errors, ensure:
- The app is configured to receive HTTP (not HTTPS) on port 3000
config.force_ssl = falsein production.rb- SSL is handled by the Convox load balancer, not the Rails app
If you see "Blocked hosts" errors:
- This example uses
ALLOW_ALL_HOSTS=truefor simplicity - For production, configure specific allowed hosts in production.rb
The app is configured with RAILS_SERVE_STATIC_FILES=true for simplicity. For production, consider using a CDN.
# Increase memory allocation
convox scale web --memory 1024 -a rails-app- Modern Rails 7.1 setup
- PostgreSQL database with sample data
- User management system
- RESTful API endpoints
- Health monitoring
- Optimized Docker build
- Production-ready configuration
- Cloud Machine compatible settings (CPU: 250)