From ea4b94973ffeda9e53fbf63c68415272276ea4e0 Mon Sep 17 00:00:00 2001 From: Patricio Mac Adden Date: Wed, 4 Sep 2024 16:21:58 -0300 Subject: [PATCH] Add bundler cache feature --- features/bundler-cache/README.md | 19 +++++++++++++++++++ .../bundler-cache/devcontainer-feature.json | 17 +++++++++++++++++ features/bundler-cache/install.sh | 16 ++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 features/bundler-cache/README.md create mode 100644 features/bundler-cache/devcontainer-feature.json create mode 100644 features/bundler-cache/install.sh 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"