Skip to content

Commit

Permalink
Merge pull request #48 from patriciomacadden/bundler-cache-feature
Browse files Browse the repository at this point in the history
Add bundler cache feature
  • Loading branch information
andrewn617 authored Sep 30, 2024
2 parents 1a23e3d + ea4b949 commit 0e92227
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
19 changes: 19 additions & 0 deletions features/bundler-cache/README.md
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.
17 changes: 17 additions & 0 deletions features/bundler-cache/devcontainer-feature.json
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"
},
"mounts": [
{
"source": "bundler-data",
"target": "/bundle",
"type": "volume"
}
],
"postCreateCommand": "/usr/local/share/bundler-data-permissions.sh"
}
16 changes: 16 additions & 0 deletions features/bundler-cache/install.sh
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"

0 comments on commit 0e92227

Please sign in to comment.