Proposal: Kamal gets ruby version build arg from ruby itself

Problem: The ruby version currently is duplicated at least once in a new Rails app that uses Kamal. “.ruby-version” and “Dockerfile”.

Proposal: Have the “deploy.yml.tt” generator have the following:

builder:
  ...
  args:
    RUBY_VERSION: <%= "\<%= Gem.ruby_version %>" %>

How will this solve the problem? For the default use case, Kamal is a ruby script running with the Ruby version the app uses. This means, with the above change, the builder will pass the correct Ruby version to Docker, overriding the RUBY_VERSION in the Dockerfile.

1 Like

The way I understand it .ruby_version is a declaration what ruby version is required for this project,

Dockerfile has it’s own mechanism to set up the world, so this requirement is fulfilled.

So I’d rather look for a way for Dockerfile to get version from .ruby_version file, than telling bundler “the required version is whatever version currently available”.

That is what this does. Kamal can only be run from the app directory AFAIK, which means that Gem.ruby_version is the same as the version in the file. Gem.ruby_version also handles apps that are not using .ruby_version.