Miget detects Ruby on Rails from your Gemfile and runs your app with no configuration. You push your code, Miget builds it, and your Rails server goes live.

Prerequisites

Before you start, make sure you have:
  • A Miget account
  • Git installed locally
  • A Rails app with a Gemfile committed to a Git repository

Bind to the right port

Every app on Miget must listen on 0.0.0.0:5000. Miget sets an immutable PORT=5000, and public traffic only reaches port 5000. Puma respects the PORT environment variable, so rails server binds to 5000 automatically. No changes needed for the default setup.
If you want to control the start command explicitly, add a Procfile to your project root:
Procfile
web: bundle exec rails server -b 0.0.0.0 -p 5000
Learn more about ports and buildpacks.

Set environment variables

Add these variables to your app before deploying. Set them under your app’s settings - see using secrets.
VariableValuePurpose
RAILS_ENVproductionRun in production mode
SECRET_KEY_BASEyour secretRequired by Rails to sign sessions and cookies
RAILS_SERVE_STATIC_FILEStrueServe precompiled assets from the app
Generate a SECRET_KEY_BASE locally with bundle exec rails secret and paste the value into Miget.

Deploy your app

1

Create the application

Go to app.miget.com, click New then Application. Give your app a name, pick a resource, and click Next.
2

Choose auto detection

Select Auto detection (Miget Buildpacks) and choose a size, then click Next. Miget will detect Ruby from your Gemfile, detect Rails, and run the Rails server.
3

Pick git push

Choose git push as the deployment method, click Create, and copy the token shown.
4

Push your code

Add the Miget remote and push:
git remote add miget https://git.<region>.miget.io/<your-miget-name>/<app-name>
git push miget
Miget builds your app and starts the Rails server. See git push to builder for the full reference.
This guide uses git push, but it’s one of several ways to deploy. You can also connect a GitHub repository for auto-deploys and pull request previews, deploy from a public Git repository, or push a prebuilt container image. See all deployment methods.

Precompile assets and run migrations

Precompile your assets during the build or as a post-deploy step:
bundle exec rails assets:precompile
Run database migrations as a post-deploy step so they execute after each new release:
bundle exec rails db:migrate

Connect a database

Rails reads DATABASE_URL automatically, so connecting a database takes no code changes.
1

Add a PostgreSQL addon

Add a PostgreSQL addon to your app. Miget provisions the database and auto-injects a DATABASE_URL (postgres://...) into your app’s environment.
2

Run your migrations

Rails picks up DATABASE_URL on boot. Run bundle exec rails db:migrate as a post-deploy step to set up your schema.
You do not need to edit database.yml beyond honoring DATABASE_URL, which recent Rails versions do out of the box.

Next steps

Add a custom domain

Point your own domain at your Rails app.

Manage secrets

Store SECRET_KEY_BASE and other config securely.

PostgreSQL databases

Learn how Miget provisions and injects your database.

Fair Scheduler

Understand how Miget allocates compute across your apps.