Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
matrix:
features:
- circleci-cli
- deno-cache
- exercism-cli
baseImage:
- debian:latest
Expand Down
6 changes: 6 additions & 0 deletions src/deno-cache/NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Deno Cache

Setup the [deno cache](https://jsr.io/@deno/cache-dir) as a volume.

Intended for usage with the `denoland/deno:debian` docker image. Otherwise,
will create a `deno` group with read-write permissions on the cache directory.
25 changes: 25 additions & 0 deletions src/deno-cache/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"id": "deno-cache",
"name": "Deno cache setup",
"version": "0.1.0",
"containerEnv": {
"DENO_DIR": "/deno-dir"
},
"options": {
"username": {
"description": "Add the 'deno' group to the given non-root user. Defaults to the value of `remoteUser`.",
"default": "automatic",
"type": "string"
}
},
"mounts": [
{
"source": "deno-cache-${devcontainerId}",
"target": "/deno-dir",
"type": "volume"
}
],
"installsAfter": [
"ghcr.io/devcontainers/features/common-utils"
]
}
24 changes: 24 additions & 0 deletions src/deno-cache/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

set -e

GROUP=deno

echo "Creating cache directory: $DENO_DIR"
mkdir --parents "$DENO_DIR"

echo "Creating user group: $GROUP"
groupadd --force --key GID_MIN=1993 "$GROUP"

echo "Assigning group to cache directory..."
chgrp --changes --recursive "$GROUP" "$DENO_DIR"

echo "Assigning permissions with sticky group..."
chmod --changes --recursive 2775 "$DENO_DIR"

echo "Appending group ${GROUP@Q} to user..."
if [[ "$USERNAME" == "automatic" ]]; then
usermod --append --groups "$GROUP" "$_REMOTE_USER"
elif [[ -n "$USERNAME" && "$USERNAME" != "root" ]]; then
usermod --append --groups "$GROUP" "$USERNAME"
fi
14 changes: 14 additions & 0 deletions test/deno-cache/denoland_deno__debian__custom_user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -e

source dev-container-features-test-lib

check "Group exists" getent group deno
check "Directory /deno-dir exists" test -d "$DENO_DIR"
check "Group is set" test "$(stat --printf="%G" "$DENO_DIR")" == "deno"
check "Permissions are set" test "$(stat --printf="%a" "$DENO_DIR")" -eq 2775
check "Remote user is in the deno group" bash -c "getent group deno | grep jsr"
check "Run deno info" deno info "jsr:@deno/cache-dir"

reportResults
12 changes: 12 additions & 0 deletions test/deno-cache/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"denoland_deno__debian__custom_user": {
"image": "denoland/deno:debian",
"remoteUser": "jsr",
"features": {
"deno-cache": {},
"ghcr.io/devcontainers/features/common-utils:2": {
"username": "jsr"
}
}
}
}
12 changes: 12 additions & 0 deletions test/deno-cache/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -e

source dev-container-features-test-lib

check "Group exists" getent group deno
check "Directory /deno-dir exists" test -d "$DENO_DIR"
check "Group is set" test "$(stat --printf="%G" "$DENO_DIR")" == "deno"
check "Permissions are set" test "$(stat --printf="%a" "$DENO_DIR")" -eq 2775

reportResults