Skip to main content

Ruby on Miren

Miren auto-detects Ruby apps from a Gemfile, installs gems with Bundler, and configures the right web server — no Dockerfile required. Rails, Puma, and Rack apps all work out of the box.

Let your agent do this

Ask your AI coding agent to "set up this Rails app on Miren" after installing the Miren agent skills. It detects your framework, stages secrets like SECRET_KEY_BASE and RAILS_MASTER_KEY, proposes a start command, and deploys — using this page as its reference.

Do you need a Dockerfile?

No. Miren detects Ruby from your Gemfile and builds the image automatically. The default Ruby version is 3.2; override it in .miren/app.toml if you need another. Provide a Dockerfile.miren only for custom build steps — see Using Dockerfile.miren.

Set up the app

From your project root:

miren init
miren deploy

Preview what Miren detects — framework, entrypoint, staged env vars — without building:

miren deploy --analyze

Build process

Miren installs system dependencies (build tools, libpq-dev, nodejs, libyaml-dev, postgresql-client), then runs bundle install with BUNDLE_WITHOUT=development. If Bootsnap is present, it precompiles the cache; if a Rakefile defines assets:precompile, it runs that too.

These environment variables are set for you automatically:

  • BUNDLE_PATH=/usr/local/bundle
  • BUNDLE_WITHOUT=development
  • RACK_ENV=production
  • RAILS_ENV=production (for Rails apps)

Start command

Miren detects your web server. It must bind to 0.0.0.0 on $PORT — Miren injects PORT and routes traffic to it.

FrameworkDetected entrypoint
Railsbundle exec rails server -b 0.0.0.0 -p $PORT
Puma (with config)bundle exec puma -C config/puma.rb
Puma (no config)bundle exec puma -b tcp://0.0.0.0 -p $PORT
Rackbundle exec rackup -p $PORT

Override with a Procfile to add workers or change the command:

# Rails web server
web: bundle exec rails server -b 0.0.0.0 -p $PORT

# Sidekiq background worker
worker: bundle exec sidekiq

Use a single web: line. To run Puma with a config file instead of the Rails command:

web: bundle exec puma -C config/puma.rb

See Services for running Sidekiq or other workers alongside web.

Environment variables

miren init stages the secrets a Rails app needs on first deploy: it generates SECRET_KEY_BASE and reads RAILS_MASTER_KEY from config/master.key (or config/credentials/production.key) if present, pre-setting both on the app. See What miren init Does for You.

Set anything else with miren env set-e for plain values, -s for secrets (masked in output and logs):

miren env set -s DATABASE_URL
miren env set -s RAILS_MASTER_KEY=@config/master.key
miren env set -s SECRET_KEY_BASE

KEY=@file reads the value from a file; -s SECRET_KEY_BASE (no value) prompts with masked input. You can also declare variables in .miren/app.toml:

[[env]]
key = "DATABASE_URL"
value = ""
required = true
sensitive = true
description = "Postgres connection string"

See App Configuration — Environment Variables.

Agent quick reference

  • Detection: Gemfile in the project
  • Default version: Ruby 3.2 (override via [build] version in .miren/app.toml)
  • Install: bundle install with BUNDLE_WITHOUT=development
  • Auto env: RACK_ENV=production, RAILS_ENV=production, BUNDLE_PATH, BUNDLE_WITHOUT
  • Staged by miren init: generates SECRET_KEY_BASE, reads RAILS_MASTER_KEY from config/master.key
  • Start command: Rails/Puma/Rack auto-detected, bind 0.0.0.0:$PORT; or set a Procfile
  • Env vars: miren env set -e/-s, KEY=@file to read from disk, or [[env]] in app.toml
  • Dockerfile: not needed; add Dockerfile.miren only for custom builds

Next steps