All templates

Deploy Rails with Postgres on Rebasable

Rails 8 built from its own production Dockerfile; the entrypoint runs db:prepare before the server starts.

Runtime: docker Free instance with Postgres rubypostgresdocker

How it works

The service uses runtime: docker, so Rebasable builds the Dockerfile from rails new: gems, bootsnap and assets:precompile happen at build time. On start, bin/docker-entrypoint runs rails db:prepare (creates or migrates the database), then Puma listens on $PORT. SECRET_KEY_BASE is generated once; no master.key is needed. /up is the health check and is excluded from the HTTPS redirect.

Run it locally

bundle install
bin/rails db:prepare
bin/rails server   # needs a local Postgres or DATABASE_URL

Use it as your own repository

Copy the rails folder of the templates repository into a new repo (the files at the root, rebasable.yaml included) and push it. Then add a Deploy button to its README, or create it from Blueprints, New blueprint in the dashboard. From then on, every push deploys, and pull requests get preview environments.

Good to know

  • Open a console: start a shell on the service (Shell tab in the dashboard, or rebasable ssh) and run bin/rails console.
  • Background jobs with Solid Queue or Sidekiq: add a type: worker service from the same repo with dockerCommand: bin/jobs (or bundle exec sidekiq) and a Key Value store for Sidekiq.