Install bun when required in Devcontainer #51604
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation / Background
Currently when you generate a Rails app with bun the devcontainer image does not contains the bun itself, so you need to manually install it. This commit installs bun when required.
Detail
I implemented this by adding bun installation directly to the
.devcontainer/Dockerfile
file, which made the Dockerfile not so clean like previously.The best way would be to install
bun
via a devcontainer feature, which would allow us to install bun in thedevcontainer.json
instead, like we do for activestorage, datbase clientes and github cli.But there is no official bun feature that is maintained by the official
Dev Container Spec Maintainers
from the official features repo. The available bun features are from the community:bun Shyim ghcr.io/shyim/devcontainers-features/bun:0 0.0.1
bun Michael Lohr ghcr.io/michidk/devcontainers-features/bun:1 1.0.1
Bun audacioustux ghcr.io/audacioustux/devcontainers/bun:1 1.0.0
Bun Pablo Ulloa ghcr.io/prulloac/devcontainer-features/bun:1 1.1.2
bun lumenpink ghcr.io/lumenpink/devcontainer-features/bun:0 0.0.1
and I don't know if it is feasible for Rails to use these bun feature instead an "official" one.
I tried to create a
feature
inside rails/devcontainer-features but it got rejected with the suggestion to try to create it directly inside the official repo, which was declined as well with the reason:the devcontainers/features repo only accepts improvements and bug fixes for the [current set of maintained Features](https://github.com/devcontainers/features/blob/main/src).
, so no bun official feature will be available.There is one solution if we want to stick with the features installation method instead of the Dockerfile one:
we can create a folder
.devcontainer/features/bun
and reference this folder inside thedevcontainer.json
:but I want to check your preferences before implementing this.
thoughts?
Thanks! 馃嵒
Additional information
How to test
bundle exec rails new ../testbundevcontainer -j bun --dev
.devcontainer/Dockerfile
should include bun installationcat .devcontainer/Dockerfile | grep bun
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]