Detection
migetpacks detects Ruby when any of these files are present in your project root:GemfileRakefileconfig.ru
Version Detection
Ruby version is resolved in this order:
The
ruby- prefix is automatically stripped (e.g., ruby-3.2.0 becomes 3.2.0).
Build Process
migetpacks generates a multi-stage Dockerfile with bundler layer caching:Dependency Detection
migetpacks inspects yourGemfile and Gemfile.lock to install the correct system libraries:
Additionally,
tzdata and ca-certificates are always installed in the runtime image.
Bundler Version
The bundler version is automatically detected fromGemfile.lock (the BUNDLED WITH section) and installed in the builder stage.
Local Gems
If yourGemfile references local gems with path: options, those directories are automatically copied before bundle install to ensure they are available during gem resolution.
Rails Asset Precompilation
If your project has aRakefile and either app/assets/ or app/javascript/ directories, migetpacks automatically:
- Sets
RAILS_ENV=production,SECRET_KEY_BASE_DUMMY=1, and a dummyDATABASE_URL - Runs
bundle exec rake assets:precompile - Runs
bundle exec rake assets:clean
Runtime Cleanup
The following are removed from the final image:.git/,.github/test/,tests/,spec/,features/.rspec,.rubocop*vendor/bundle/ruby/*/cache/
Run Command
The default run command is determined in this order:Runtime Environment
The following environment variables are set in the runtime container:Caching
Docker Layer Caching
Gems are installed in a separate layer before source code is copied.bundle install is only re-run when Gemfile or Gemfile.lock changes.
BuildKit Cache Mounts
WhenBUILD_CACHE_DIR is configured, BuildKit cache mounts are used:
Registry Cache
UseCACHE_IMAGE to push/pull BuildKit inline cache layers to a registry for cross-build caching.
DHI Support
Ruby is fully supported with Docker Hardened Images.
DHI-Specific Behavior
The DHI runtime is distroless (no shell, no apt-get), which requires special handling: Native gem libraries are copied from the builder stage:./bin/rails serverbecomesruby bin/rails serverbundle execcommands work because bundler is installed as a gem
/usr/bin/env).
Multi-Buildpack
Ruby applications commonly use Node.js for asset compilation. Whenpackage.json is detected alongside a Ruby project, Node.js is automatically added as a secondary buildpack: