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
Dockerfilethat builds on its own. - Forge:
reliant forgeinside Reliant, ornpx -y @reliantlabs/forge@latestanywhere 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 withSECRET_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)
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(orSECRET_KEY_BASE). Production refuses to boot without one. Deliver it as a secret, never commitconfig/master.key.force_ssl. TLS ends at the hosting ingress, which forwardsX-Forwarded-Proto: https. Keepconfig.force_ssl = trueandconfig.assume_ssl = true, so Rails trusts the header instead of redirecting in a loop.- Host authorization. If
config.hostsis set, add the URL hosting gives you, or every request isBlocked hosts. The TCP probe doesn’t send a host, so it is unaffected; an HTTP probe on/upshould be excluded withconfig.host_authorization = { exclude: ->(r) { r.path == "/up" } }. - Logs to stdout.
RAILS_LOG_TO_STDOUT=1(the default in Rails 7.1+ production) soreliant forge obs logssees them.
Postgres and migrations
Withpg 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
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
/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::InvalidMessageat boot: the master key doesn’t matchcredentials.yml.enc. Set the right one; per-environment credentials readconfig/credentials/production.key.- Sidekiq or Solid Queue workers are a second workload (
kind = "worker", same image, its owncommand). They need billing. - Active Storage on
:localwrites to scratch disk that each rollout discards. Use an S3-compatible service.