Skip to content
Rails deploy guide

Deploy Ruby on Rails in Europe

Rails on EU infrastructure with the production settings already set: assets precompiled at build, RAILS_ENV=production, logs to stdout, db:migrate before traffic switches.

Rails ships its own idea of a production container, and HostStack’s Rails preset follows it: the gems installed without development and test groups, assets precompiled with a dummy secret, logs on stdout, tmp/ moved to a writable tmpfs, and rails server on the port the platform routes to. Link a managed Postgres and DATABASE_URL is there — Rails reads it without a database.yml change.

What HostStack detects and builds

  • Rails is recognised from a Gemfile plus config/application.rb.
  • The Ruby version comes from the Gemfile’s ruby line (including ruby file: ".ruby-version"), .ruby-version, .tool-versions or Gemfile.lock; with none, the newest release.
  • The image is the official slim Ruby image plus build-essential, git, libyaml-dev and pkg-config, so gems with native extensions compile.
  • assets:precompile runs with SECRET_KEY_BASE_DUMMY=1 on that one step, so it needs no master key; the running app never sees the dummy.
  • RAILS_ENV=production, BUNDLE_WITHOUT=development:test, RAILS_LOG_TO_STDOUT=1 and RAILS_SERVE_STATIC_FILES=1 are set, and tmp/ is linked to /tmp because the root filesystem is read-only.
StepDefault when you leave it empty
Installbundle install
Buildbundle exec rails assets:precompile
Startbundle exec rails server -b 0.0.0.0 -p $PORT
EnvironmentRAILS_ENV=production BUNDLE_WITHOUT=development:test

rails server boots Puma when your Gemfile has it, as a new Rails app does. The environment variables are applied whatever your commands are; your own values for the same names win.

hoststack.yaml for Rails

Optional. Commit it next to your code and every deploy applies it; leave a key out and the service keeps its dashboard value. It configures a service that already exists — it never creates one. The full schema and hoststack validate are in the docs.

hoststack.yaml
services:
  web:
    install:
      command: bundle install
    build:
      command: bundle exec rails assets:precompile
    start:
      command: bundle exec rails server -b 0.0.0.0 -p $PORT
    healthCheck:
      path: /up

These are the preset’s own commands. Writing them down means a command pre-filled when the service was created cannot shadow them. /up is the health route Rails 7.1 and later generate.

Database and environment variables

Link a managed Postgres or MySQL and DATABASE_URL is injected; Active Record merges it over database.yml’s production entry. Link a Redis too and REDIS_URL is there for Action Cable, Sidekiq or the cache store.

bash
hoststack db create --project prj_... --name app-db --engine postgres --plan micro
hoststack db link db_... --service svc_...
hoststack env set svc_... RAILS_MASTER_KEY=... --secret
hoststack services update svc_... --pre-deploy-command "bundle exec rails db:migrate"

Secrets belong on the service, not in the file — see environment variables and databases.

Deploy Rails step by step

  1. 1Create a web service from your repository, in the dashboard or with hoststack services create --name web --type web_service --project prj_... --repo acme/app.
  2. 2Commit the hoststack.yaml above.
  3. 3Create a managed Postgres and link it, which injects DATABASE_URL on the next deploy.
  4. 4Set RAILS_MASTER_KEY — the contents of config/master.key — as a secret.
  5. 5Set bundle exec rails db:migrate as the pre-deploy command.
  6. 6Push to deploy, then add your domain.

Hosted in Europe, by a European company

A Rails monolith usually holds everything: users, payments, the admin, Active Storage files. Hosting it on an EU-incorporated platform in an EU region keeps all of it under GDPR with no US parent company in the chain.

Every service, database and backup runs in Helsinki, Finland, on Hetzner, and HostStack is operated by MICCI, a Danish company — so the US CLOUD Act has no hold on it, the GDPR data processing agreement is signed at signup on every plan, and the invoice is in EUR. Why that differs from a US platform's EU region is on EU data residency.

Things that catch people out

No database client headers in the build image.

The image has a compiler but not libpq or libmysqlclient headers. A pg or mysql2 version that must compile against them fails; use a release with a precompiled Linux platform gem in Gemfile.lock, or build from your own Dockerfile.

Active Storage’s disk service is not durable.

Files written to storage/ are lost on the next deploy, and the root filesystem is read-only anyway. Use an S3-compatible service — HostStack object storage works — or a persistent disk.

The dashboard can pre-fill a plain-Ruby start command.

Its repo check sees the Gemfile and suggests bundle exec ruby app.rb, which then shadows the Rails preset. The hoststack.yaml above overrides it; so does clearing the start command in Settings → General.

Frequently asked questions

How do I deploy a Rails app in Europe?

Connect the repo to HostStack. It detects Rails from the Gemfile and config/application.rb, installs gems, precompiles assets and runs rails server in Helsinki, Finland. Link a managed Postgres for DATABASE_URL, set RAILS_MASTER_KEY as a secret, and set db:migrate as the pre-deploy command.

Can I run Sidekiq or Solid Queue workers?

Yes. Create a Worker service from the same repo with bundle exec sidekiq or bin/jobs as its start command. Link the same Postgres, and a managed Redis for Sidekiq, to both services.

Do I need Kamal or a Dockerfile?

No. HostStack builds Rails from the Gemfile with its own preset, so there is no Dockerfile to maintain and no server to provision. If you prefer your own Dockerfile, point the service at it with --dockerfile-path; the container has to listen on the port in PORT and live with a read-only root filesystem.

What does it cost to host Rails on HostStack?

Small (1 GB, €10/month) is a comfortable start for a Rails app, and managed Postgres starts at €4/month. The free tier — one Nano service and one Starter Postgres — is enough to try it, with no card.

Other stacks

All guides are on the deploy guides index. Moving an existing Rails app? The Heroku, Render and Fly.io guides have the cutover order.

Deploy your Rails app

Free tier, no card: one service and one Postgres, in the EU.

Essential cookies only — for login sessions. No tracking. Details