Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use .tool-versions file from asdf for node (and other tool) version detection #22

Open
olbrich opened this issue Mar 7, 2023 · 2 comments

Comments

@olbrich
Copy link

olbrich commented Mar 7, 2023

https://github.com/rubys/dockerfile-rails/blob/718a4ad457d4a1330cc39788bdf55a07531adbbd/lib/generators/dockerfile_generator.rb#L712

.tool-versions may also contain information about ruby, yarn, and python, java, awscli, azure-cli, elixir, etc.. versions formatted like...

ruby 3.2.0
nodejs 19.6.0
yarn 1.22.19
python 3.10.7 2.7.18
@rubys
Copy link
Collaborator

rubys commented Mar 7, 2023

Looks like tool versions not only have multiple versions, but also comments. The following should grab only the first version:

IO.read('.tool-versions').scan(/^(\w+)\s+(\d+\.\d+\.\d+)/).to_h

Then there is the question of precedence. If there is a .ruby-version and a .tool-versions file present, which one should be used? My initial leanings are to take the more specific one first.

Finally, if there is a .tool-versions file, dockerfile-rails should NOT write out a redundant .node-versions file.

Sound about right?

@olbrich
Copy link
Author

olbrich commented Mar 12, 2023

Sounds about right... I also found this spec for the file format.

I would not write out the .node-versions file if a .tool-versions file exists.

It also looks like asdf will fall back to reading a .ruby-version file if configured to do so, or .nvmrc or .node-versions. See nodejs plugin.

For the ruby version, I'd probably use whatever version the Gemfile.lock specifies, for node, I'd probably raise an error if both a .tool-versions file and a .node-versions file existed and the versions didn't match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants