Originally published on gregale.dev. I build Gregale, so read this as a vendor's page. Competitor details come from each vendor's own docs, linked in the post. This post was written with AI assistance.
A Rails 8 app generated with rails new --database=postgresql deploys on Gregale from its own Dockerfile with a few changes: upload the vendor/ folder, start Puma directly, run db:migrate from a release script that switches to the migration credential, and drop Active Storage so the image fits. Rails used 257 MB of memory in our test, so it needs the Hobby plan's 512 MB; the Free plan's 256 MB is just too small, and Free has no managed PostgreSQL anyway. The working result is public at gregale-dev/rails-postgres.
Generate the app
rails new blog --database=postgresql --skip-solid --skip-kamal -
--skip-solidleaves out Solid Cache, Solid Queue and Solid Cable. With them, Rails 8 gives each its own production database next to the main one, and Gregale's attach gives the app a singleDATABASE_URL. -
--skip-kamalleaves out Kamal's deploy configuration, which Gregale does not use.
Rails still writes its production Dockerfile, and Gregale builds from it.
Change six things
1. Upload vendor/. Gregale leaves vendor folders out of every upload by default, but the Rails Dockerfile runs COPY vendor/* ./vendor/, and the build fails with lstat /vendor: no such file or directory. Add a .gregaleignore at the project root:
!vendor/ 2. Start Puma directly. The Dockerfile's default command starts Thruster, a proxy in front of Puma. Gregale already terminates HTTPS and proxies requests to the app, so run Puma on its own, and point the health check at Rails' built-in /up:
# gregale.yaml access: public hosting: start: ./bin/rails server health: /up release: command: ./bin/release Puma listens on the port in PORT, which Gregale sets. access: public lets visitors in without a Gregale API key. The release command runs before a new version takes traffic. If it fails, the previous version keeps serving.
3. Migrate with the migration credential. Gregale gives a database two kinds of credentials. DATABASE_URL reads and writes rows but cannot CREATE, ALTER or DROP anything, and serving instances get only that one. MIGRATION_DATABASE_URL can change the schema, and only the release command receives it, alongside DATABASE_URL.
Rails gives the DATABASE_URL environment variable precedence over the url in config/database.yml, so release: ./bin/rails db:migrate migrates with the serving credential, even with MIGRATION_DATABASE_URL named in database.yml. The release then fails with PG::InsufficientPrivilege: permission denied for schema public. Point DATABASE_URL at the migration credential before Rails starts, in bin/release:
#!/bin/bash -e # Gregale's release command. Rails prefers DATABASE_URL over database.yml, # so point it at the migration credential. if [ -n "$MIGRATION_DATABASE_URL" ]; then export DATABASE_URL="$MIGRATION_DATABASE_URL" fi exec ./bin/rails db:migrate Make it executable with chmod +x bin/release. So db:migrate runs with schema rights, and the running app never has them.
4. Keep migrations out of the entrypoint. Rails' default bin/docker-entrypoint runs ./bin/rails db:prepare before the server starts, which would migrate with the serving credential. Replace it with one that only starts the command:
#!/bin/bash -e exec "${@}" 5. Read one database URL in production. Replace the production: block in config/database.yml:
production: <<: *default url: <%= ENV["DATABASE_URL"] %> prepared_statements: false # True only in bin/release, where DATABASE_URL is the migration credential. advisory_locks: <%= ENV["MIGRATION_DATABASE_URL"].present? && ENV["DATABASE_URL"] == ENV["MIGRATION_DATABASE_URL"] %> The serving DATABASE_URL goes through a connection pooler in transaction mode, which cannot keep prepared statements or session-level advisory locks between transactions. The migration credential connects to PostgreSQL directly, so the release keeps the advisory lock Rails holds while it migrates.
6. Drop Active Storage and libvips. Gregale caps the layer an image adds on top of its runtime base at 512 MB on Hobby. Rails' default image installs libvips for Active Storage image variants, and in our test it came to 517 MB. Remove libvips from the apt-get install line in the Dockerfile, the image_processing gem from the Gemfile, and Active Storage itself: comment out require "active_storage/engine" in config/application.rb (or replace require "rails/all" with the frameworks you use), and delete config/storage.yml and the config.active_storage lines in config/environments/. That brought the image to 419 MB. Store uploads in object storage instead; Active Storage's disk service would lose them anyway (see below).
Create the database and deploy
gregale deploy --create-only --name blog gregale add postgres --app blog --region <region> gregale postgres attach blog-postgres blog --access migration --env MIGRATION_DATABASE_URL echo "RAILS_MASTER_KEY=$(cat config/master.key)" > ../blog.secrets gregale deploy --name blog --secrets-file ../blog.secrets gregale add postgres creates the database blog-postgres and attaches it as DATABASE_URL. The attach adds the migration credential. Rails reads its credentials with RAILS_MASTER_KEY, which the Dockerfile build leaves out on purpose, so pass it to the deploy as a secret. Keep the secrets file out of the repository.
The example repo declares both credentials in its gregale.yaml instead, so its first deploy creates the database, and reads SECRET_KEY_BASE from the environment, so a fresh clone needs no master.key.
What we measured
We deployed the example repo, a Rails 8.1.4.1 notes app on Ruby 4.0.10, on Gregale on 2026-11-29:
- Migrations: with
release: ./bin/rails db:migrateand thedatabase.ymlfrom an earlier version of this article, the release failed withpermission denied for schema public. Withbin/releaseit ran, and the app read and wrote notes through the serving credential. - Size: 517 MB with Rails' default image, 419 MB without
libvipsand Active Storage. - Build: about two minutes the first time, one minute with the dependency cache.
- Waking up: the snapshot restore took 82 to 92 ms and Puma was running about 135 ms after the request arrived. The first byte of
GET /notes.jsoncame at about 1 s, most of it opening the first database connection and Rails' first request. - Memory: 257 MB while serving, with Puma's default 3 threads, measured on a scaffolded
blogapp on 2026-11-27.
Things that work differently
- Uploaded files. Active Storage's default disk service, if you keep it, writes to
storage/on the instance. Gregale's filesystem is ephemeral, so those files do not survive a redeploy or reach other instances. Use an S3-compatible service; see What breaks when your app scales to zero. - Scheduled work. Without Solid Queue there is no recurring-job runner. A Gregale cron sends an HTTP
POSTto a path on your app on a schedule, and wakes the app for it. - Logs. Rails 8 logs to standard output in production, so
gregale logs blogshows every request.
How other platforms run Rails migrations
| Platform | Migration step | Credential |
|---|---|---|
| Gregale | release: command, before the new version takes traffic | A separate migration credential the app never receives |
| Heroku | release: in the Procfile, run in a one-off dyno for each new release | The app's own database credential |
| Render | Pre-deploy command bin/rails db:migrate; needs a paid plan, else the build script | The app's own database credential |
| Fly.io | release_command in fly.toml, in a temporary Machine with the new image | The app's own database credential |
Render's Free PostgreSQL databases expire 30 days after creation. A Gregale database on Hobby has no expiry and includes a 7-day restore window.
Sources, checked 2026-11-27: Heroku release phase, Render: deploy Rails 8, Render free instances, Fly.io app configuration.
Pricing
Hobby costs $10 a month and includes one managed PostgreSQL database, 512 MB per app and 200 GB-RAM-hours. Between requests the app pauses, and paused seconds are not billed. See Gregale pricing, Managed PostgreSQL and Container compatibility.

