diff --git a/features/bundler-cache/README.md b/features/bundler-cache/README.md new file mode 100644 index 0000000..378758f --- /dev/null +++ b/features/bundler-cache/README.md @@ -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. diff --git a/features/bundler-cache/devcontainer-feature.json b/features/bundler-cache/devcontainer-feature.json new file mode 100644 index 0000000..b1df7b3 --- /dev/null +++ b/features/bundler-cache/devcontainer-feature.json @@ -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" +} diff --git a/features/bundler-cache/install.sh b/features/bundler-cache/install.sh new file mode 100644 index 0000000..d53017f --- /dev/null +++ b/features/bundler-cache/install.sh @@ -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"