Skip to main content
You will deploy an existing Rails app, using the Dockerfile Rails 7.1+ generates, to Reliant hosting with a managed Postgres. Forge reads the Dockerfile, the Gemfile and db/migrate and writes its declarations beside them; no Ruby changes. The detector output here is from Forge v1.10.1-0.20261123064811-54313eead62f.

Before you begin

  • Docker, and the app in a git repository with a root Dockerfile that builds on its own.
  • Forge: reliant forge inside Reliant, or npx -y @reliantlabs/forge@latest anywhere else.
  • For a deploy that lasts, a Reliant account with app hosting billing.

What the Dockerfile must do

The generated Rails Dockerfile is close to right: it builds in stages, precompiles assets with SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile, and runs as the non-root rails user. Check two things. Rails 8’s default CMD starts Thruster on port 80, which a non-root user can’t always bind and which hosting’s TLS already covers; serve Puma directly on a high port, on all interfaces:
Dockerfile (end)
The detector reads the port from EXPOSE (or a -p/-b in the command, the compose port, or ENV PORT) and sets PORT. Remove the ENTRYPOINT ["/rails/bin/docker-entrypoint"] line’s db:prepare call, or leave it knowing that every replica start runs it: the migration job below already migrated.

Production settings

  • RAILS_MASTER_KEY (or SECRET_KEY_BASE). Production refuses to boot without one. Deliver it as a secret, never commit config/master.key.
  • force_ssl. TLS ends at the hosting ingress, which forwards X-Forwarded-Proto: https. Keep config.force_ssl = true and config.assume_ssl = true, so Rails trusts the header instead of redirecting in a loop.
  • Host authorization. If config.hosts is set, add the URL hosting gives you, or every request is Blocked hosts. The TCP probe doesn’t send a host, so it is unaffected; an HTTP probe on /up should be excluded with config.host_authorization = { exclude: ->(r) { r.path == "/up" } }.
  • Logs to stdout. RAILS_LOG_TO_STDOUT=1 (the default in Rails 7.1+ production) so reliant forge obs logs sees them.

Postgres and migrations

With pg in the Gemfile, the detector adds a managed Postgres on staging and prod and passes its URL as DATABASE_URL, which Rails reads with no database.yml change. With db/migrate, it adds a migrate job, bin/rails db:migrate, run from the app’s image before every rollout. Rails 8’s solid_queue/solid_cache second databases need their own DATABASE_URL-style variables; an anonymous deploy allows only one database.
1

Preview and adopt

terminal
Output (trimmed)
terminal
2

Deliver the master key

With no compose file, the detector can’t see RAILS_MASTER_KEY, so add it to both workloads in deploy/kcl/prod/main.k (the migration job boots Rails too):
deploy/kcl/prod/main.k (excerpt)
terminal
3

Build, render, lint, deploy

terminal
Without app hosting billing the deploy is queued and exits 7 with the billing link. The default size is 250m CPU and 1 GiB per workload; set WEB_CONCURRENCY and RAILS_MAX_THREADS to fit it.With no account, npx -y @reliantlabs/forge@latest env deploy prod --claimable publishes a 72-hour preview (adopt with --kind app --claimable, then check with --plan-only). It is one service at 125m CPU and 128 MiB, which a typical Rails app exceeds at boot, and it gets no secret values, so Rails production can’t find its master key. For Rails, sign in and deploy to your organization. See Deploy without an account.
4

Verify

terminal
Rails’ /up returns 200 once the app booted. Then hit a page that reads the database. obs check exits 0 proven good, 1 regressed, 2 not proven, 8 the wait ran out; without an OpenTelemetry SDK (opentelemetry-instrumentation-all) it is 2, no_request_telemetry, which means not proven good. Once /up is reliable, switch the probe in workloads.k to tiers.Probes {readinessPath = "/up"}.

Rails gotchas

  • ActiveSupport::MessageEncryptor::InvalidMessage at boot: the master key doesn’t match credentials.yml.enc. Set the right one; per-environment credentials read config/credentials/production.key.
  • Sidekiq or Solid Queue workers are a second workload (kind = "worker", same image, its own command). They need billing.
  • Active Storage on :local writes to scratch disk that each rollout discards. Use an S3-compatible service.
See also: Bring an existing app, Managed Postgres, Secrets, Hosting limits.