---
title: "Ruby"
description: "Deploy Ruby and Rails applications on Miget with native gem support and asset precompilation."
---
Miget Buildpacks automatically detect and build your Ruby applications when you select **Auto detection (Miget Buildpacks)** as the build method. Rails applications are fully supported with asset precompilation and native gem handling. For the full reference, visit the [migetpacks Ruby documentation](https://migetpacks.com/languages/ruby).
## Detection
Your application is detected as Ruby when one of these files is present in the root directory:
- `Gemfile`
- `Rakefile`
- `config.ru`
## Version Detection
The Ruby version is determined from the following sources, in order of priority:
1. `.ruby-version`
2. `ruby` directive in `Gemfile`
If no version is specified, a recent stable Ruby version is used.
## Build Process
During the build, the following steps are performed:
1. **Bundler version detection** - The Bundler version is auto-detected from the `BUNDLED WITH` section in `Gemfile.lock`.
2. **Dependency installation** - Gems are installed via Bundler.
3. **Native gem support** - Native gems such as `pg`, `mysql2`, `sqlite3`, and `nokogiri` are auto-detected, and the required system libraries are installed automatically.
4. **Rails support** - If Rails is detected:
- Asset precompilation runs automatically.
- Runtime cleanup removes unnecessary build artifacts.
## Run Command
The run command is resolved in the following order:
1. `web` process in a `Procfile`
2. Rails server (if Rails is detected)
3. `rackup` (if `config.ru` is present)
You can also override the run command directly in the Miget dashboard when creating your app or changing the deployment source.
## Configuration
You can customize the build and runtime behavior through the Miget dashboard and repository configuration files:
- **Environment variables** - Set under **Settings -> Variables** in the Miget dashboard
- **Procfile** - Define the start command at the root of your repository
- **app.json** - Application manifest for additional configuration
- **Project Path** - For monorepo setups, specify the subdirectory containing your application code in the **Advanced** tab
- **Pre-Deploy Command** - Run a command before deployment (e.g., database migrations) in the **Advanced** tab
- **Post-Deploy Command** - Run a command after successful deployment (e.g., seeding data, cache warming) in the **Advanced** tab
## Docker Hardened Images
You can enable Docker Hardened Images (DHI) in the **Advanced** tab when creating your app or changing the deployment source. When enabled, your application is built using distroless runtime images with a minimal attack surface, no shell, and no package manager.
Native gem libraries are automatically copied into the hardened image.
For the complete reference, see the [migetpacks Ruby documentation](https://migetpacks.com/languages/ruby).