-
Notifications
You must be signed in to change notification settings - Fork 26
Add bundler cache feature #48
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Bundler cache | ||
|
||
Creates a volume for persisting the installed gems across different containers. | ||
|
||
## Example Usage | ||
|
||
```json | ||
"features": { | ||
"ghcr.io/rails/devcontainer/features/bundler-cache:1": {} | ||
} | ||
``` | ||
|
||
## Options | ||
|
||
## Customizations | ||
|
||
## OS Support | ||
|
||
`bash` is required to execute the `install.sh` script. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,17 @@ | ||||||||||||
{ | ||||||||||||
"id": "bundler-cache", | ||||||||||||
"version": "1.0.0", | ||||||||||||
"name": "Bundler cache", | ||||||||||||
"description": "Creates a volume for persisting the installed gems across different containers", | ||||||||||||
"containerEnv": { | ||||||||||||
"BUNDLE_PATH": "/bundle/vendor" | ||||||||||||
}, | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps also add this?
Suggested change
I'm not sure if it makes sense though There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's necessary. The ruby feature should not install any gems. |
||||||||||||
"mounts": [ | ||||||||||||
{ | ||||||||||||
"source": "bundler-data", | ||||||||||||
"target": "/bundle", | ||||||||||||
"type": "volume" | ||||||||||||
} | ||||||||||||
], | ||||||||||||
"postCreateCommand": "/usr/local/share/bundler-data-permissions.sh" | ||||||||||||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}" | ||
|
||
POST_CREATE_COMMAND_SCRIPT_PATH="/usr/local/share/bundler-data-permissions.sh" | ||
|
||
tee "$POST_CREATE_COMMAND_SCRIPT_PATH" > /dev/null \ | ||
<< EOF | ||
#!/bin/sh | ||
set -e | ||
sudo chown -R ${USERNAME} /bundle | ||
EOF | ||
|
||
chmod 755 "$POST_CREATE_COMMAND_SCRIPT_PATH" |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that once you're in the container, if you run
rails c
(or any other executable in your Gemfile) you'll get a "command not found" error.to solve this, we can add these env vars:
BUNDLE_BIN
tells bundler to install the bins in the specified dir, and then we'll prepend this dir in thePATH
.By default, the
BUNDLE_BIN
would be something like/bundle/vendor/ruby/COMPATIBILITY_VERSION/bin
. And compatibility version is not always the same ruby version you're running (for example i'm testing with 3.3.4 and the compat version is 3.3.0 - This is not trivial to get, so changing theBUNDLE_BIN
makes sense..There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should add the bundle bin to the path like that. Instead people should do
bundle exec rails c
orbin/rails c
. I expect global gems to be in the path but not bundled gems.