Heroku Deployment
This guide covers deploying Vulcan to Heroku, a platform-as-a-service (PaaS) that enables developers to build and run applications entirely in the cloud.
Prerequisites
- Heroku account (free tier available)
- Heroku CLI installed locally
- Git repository with Vulcan code
- PostgreSQL add-on (Heroku Postgres)
Quick Deploy
Deploy with Heroku Button
Manual Deployment
- Create a new Heroku app:
bash
heroku create your-vulcan-app
- Add PostgreSQL database:
bash
heroku addons:create heroku-postgresql:mini
- Set required environment variables:
bash
# Ruby buildpack configuration
heroku config:set RAILS_ENV=production
heroku config:set RAILS_SERVE_STATIC_FILES=true
heroku config:set RAILS_LOG_TO_STDOUT=true
# Application configuration
heroku config:set SECRET_KEY_BASE=$(rails secret)
heroku config:set VULCAN_CONTACT_EMAIL=admin@example.com
heroku config:set VULCAN_APP_URL=https://your-vulcan-app.herokuapp.com
- Deploy the application:
bash
git push heroku main
- Run database migrations:
bash
heroku run rails db:migrate
- Create admin user (optional):
bash
heroku run rails c
# In Rails console:
User.create!(
email: 'admin@example.com',
password: 'secure_password_here',
admin: true,
confirmed_at: Time.now
)
Configuration
Essential Environment Variables
bash
# Database (automatically set by Heroku Postgres)
DATABASE_URL=postgres://...
# Rails configuration
SECRET_KEY_BASE=your-secret-key
RAILS_ENV=production
RAILS_SERVE_STATIC_FILES=true
RAILS_LOG_TO_STDOUT=true
# Vulcan configuration
VULCAN_CONTACT_EMAIL=admin@example.com
VULCAN_APP_URL=https://your-app.herokuapp.com
VULCAN_WELCOME_TEXT="Welcome to Vulcan"
# Email configuration (if using SendGrid)
VULCAN_ENABLE_SMTP=true
VULCAN_SMTP_ADDRESS=smtp.sendgrid.net
VULCAN_SMTP_PORT=587
VULCAN_SMTP_AUTHENTICATION=plain
VULCAN_SMTP_SERVER_USERNAME=apikey
VULCAN_SMTP_SERVER_PASSWORD=your-sendgrid-api-key
VULCAN_SMTP_DOMAIN=heroku.com
VULCAN_SMTP_ENABLE_STARTTLS_AUTO=true
Authentication Providers
For OAuth/OIDC authentication, add:
bash
# GitHub OAuth
VULCAN_GITHUB_APP_ID=your-github-app-id
VULCAN_GITHUB_APP_SECRET=your-github-app-secret
# OIDC
VULCAN_ENABLE_OIDC=true
VULCAN_OIDC_ISSUER_URL=https://your-provider.com
VULCAN_OIDC_CLIENT_ID=your-client-id
VULCAN_OIDC_CLIENT_SECRET=your-client-secret
Add-ons
Recommended Add-ons
Heroku Postgres (Required)
bashheroku addons:create heroku-postgresql:mini
SendGrid (Email service)
bashheroku addons:create sendgrid:starter
Papertrail (Logging)
bashheroku addons:create papertrail:choklad
New Relic (Application monitoring)
bashheroku addons:create newrelic:wayne
Heroku Scheduler (Background jobs)
bashheroku addons:create scheduler:standard
Scaling
Dyno Configuration
bash
# Scale web dynos
heroku ps:scale web=1
# For production workloads
heroku ps:scale web=2:standard-2x
# Add worker dynos if needed
heroku ps:scale worker=1:standard-1x
Database Scaling
bash
# Upgrade database plan
heroku addons:upgrade heroku-postgresql:standard-0
Maintenance
Updates and Migrations
bash
# Enable maintenance mode
heroku maintenance:on
# Deploy updates
git push heroku main
# Run migrations
heroku run rails db:migrate
# Disable maintenance mode
heroku maintenance:off
Backup and Restore
bash
# Create backup
heroku pg:backups:capture
# List backups
heroku pg:backups
# Download backup
heroku pg:backups:download
# Restore from backup
heroku pg:backups:restore b001 DATABASE_URL
Logs
bash
# View recent logs
heroku logs --tail
# View specific process logs
heroku logs --source app --tail
# Export logs to file
heroku logs -n 1500 > production.log
Review Apps
Enable Review Apps for pull request previews:
- Create
app.json
in repository root:
json
{
"name": "Vulcan",
"scripts": {
"postdeploy": "bundle exec rails db:schema:load"
},
"env": {
"RAILS_ENV": {
"value": "production"
},
"SECRET_KEY_BASE": {
"generator": "secret"
}
},
"formation": {
"web": {
"quantity": 1,
"size": "standard-1x"
}
},
"addons": [
"heroku-postgresql:mini"
],
"buildpacks": [
{
"url": "heroku/nodejs"
},
{
"url": "heroku/ruby"
}
]
}
- Enable Review Apps in Heroku Pipeline settings
Troubleshooting
Common Issues
Assets not loading
bashheroku config:set RAILS_SERVE_STATIC_FILES=true heroku run rails assets:precompile
Database connection errors
bash# Check database URL heroku config:get DATABASE_URL # Restart database heroku pg:restart
Memory issues
bash# Check memory usage heroku ps # Scale to larger dyno heroku ps:resize web=standard-2x
Deployment failures
bash# Check build log heroku builds:info # Clear build cache heroku builds:cache:purge
Security Considerations
Use strong SECRET_KEY_BASE
bashheroku config:set SECRET_KEY_BASE=$(openssl rand -hex 64)
Enable HTTPS only
- Heroku provides SSL certificates automatically
- Force SSL in Rails configuration
Restrict database access
- Use Heroku Private Spaces for sensitive data
- Enable database encryption at rest
Regular updates
bash# Update Ruby buildpack heroku buildpacks:set heroku/ruby # Update dependencies bundle update --conservative
Cost Optimization
- Use Eco dynos for development/staging ($5/month)
- Schedule dyno sleeping for non-production apps
- Use Heroku Postgres Mini for small projects ($5/month)
- Monitor usage with
heroku ps:type