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
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ I make no guarantee that features here won't break with updates etc, but I use [

If you want to create your own features, see <https://github.com/devcontainers/feature-template>

| Feature | Description |
| ------------------------------------------------------------ | ----------------------------------------------------------------- |
| [azure-cli-persistence](src/azure-cli-persistence/README.md) | Preserve `~/.azure` folder across instances (avoids extra logins) |
| [add-host](src/add-host/README.md) | Add a host name/ip to the dev container hosts file |
| [dev-tunnels](src/dev-tunnels/README.md) | Set up the `devtunnel` CLI for working with Dev Tunnels |
| [railway-cli](src/railway-cli/README.md) | Set up the `railway` CLI for working with [Railway](https://railway.com) projects |
| [shell-history](src/shell-history/README.md) | Preserve shell history across dev container instances/rebuilds |
| Feature | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
| [azure-cli-persistence](src/azure-cli-persistence/README.md) | Preserve `~/.azure` folder across instances (avoids extra logins) |
| [add-host](src/add-host/README.md) | Add a host name/ip to the dev container hosts file |
| [dev-tunnels](src/dev-tunnels/README.md) | Set up the `devtunnel` CLI for working with Dev Tunnels |
| [github-copilot-cli](src/github-copilot-cli/README.md) | Set up the `GitHub Copilot` CLI for working with [GitHub Copilot](https://github.com/features/copilot) and persist config |
| [railway-cli](src/railway-cli/README.md) | Set up the `railway` CLI for working with [Railway](https://railway.com) projects |
| [shell-history](src/shell-history/README.md) | Preserve shell history across dev container instances/rebuilds |

6 changes: 6 additions & 0 deletions src/github-copilot-cli/NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

## Changelog

| Version | Notes |
| ------- | ------------------------------------------------------------ |
| 0.0.1 | Initial version |
29 changes: 29 additions & 0 deletions src/github-copilot-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

# GitHub Copilot CLI (github-copilot-cli)

Set up the `GitHub Copilot` CLI for working with [GitHub Copilot](https://github.com/features/copilot) and persist configuration across container instances.

## Example Usage

```json
"features": {
"ghcr.io/stuartleeks/dev-container-features/github-copilot-cli:0": {}
}
```

## Options

| Options Id | Description | Type | Default Value |
|-----|-----|-----|-----|



## Changelog

| Version | Notes |
| ------- | ------------------------------------------------------------ |
| 0.0.1 | Initial version |

---

_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/stuartleeks/dev-container-features/blob/main/src/github-copilot-cli/devcontainer-feature.json). Add additional notes to a `NOTES.md`._
20 changes: 20 additions & 0 deletions src/github-copilot-cli/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "GitHub CLI (with persistence)",
"id": "github-copilot-cli",
"version": "0.0.1",
"description": "Install GitHub CLI and configure it to store configuration in a mounted volume to preserve across container builds",
"options": {},
"containerEnv": {
"COPILOT_HOME": "/dc/github-copilot-cli"
},
"mounts": [
{
"source": "${devcontainerId}-github-copilot-cli",
"target": "/dc/github-copilot-cli",
"type": "volume"
}
],
"onCreateCommand": {
"github-copilot-cli": "/usr/local/share/stuartleeks-devcontainer-features/github-copilot-cli/scripts/oncreate.sh"
}
}
27 changes: 27 additions & 0 deletions src/github-copilot-cli/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

FEATURE_DIR="/usr/local/share/stuartleeks-devcontainer-features/github-copilot-cli"
LIFECYCLE_SCRIPTS_DIR="$FEATURE_DIR/scripts"
LOG_FILE="$FEATURE_DIR/log.txt"

set -e

mkdir -p "${FEATURE_DIR}"

echo "" > "$LOG_FILE"
log() {
echo "$1"
echo "$1" >> "$LOG_FILE"
}

log "Activating feature 'github-copilot-cli'"
log "User: ${_REMOTE_USER} User home: ${_REMOTE_USER_HOME}"

log "Installing GitHub Copilot CLI..."
curl -fsSL https://gh.io/copilot-install | bash
log "GitHub Copilot CLI installed"

if [ -f oncreate.sh ]; then
mkdir -p "${LIFECYCLE_SCRIPTS_DIR}"
cp oncreate.sh "${LIFECYCLE_SCRIPTS_DIR}/oncreate.sh"
fi
48 changes: 48 additions & 0 deletions src/github-copilot-cli/oncreate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash

set -e

# NOTES
# `install.sh`
# - installs GitHub Copilot CLI via https://gh.io/copilot-install
#
# `oncreate.sh`
# - fixes permissions on the mounted volume so the user can write to it
# (COPILOT_HOME is set to /dc/github-copilot-cli via containerEnv in devcontainer-feature.json)

FEATURE_DIR="/usr/local/share/stuartleeks-devcontainer-features/github-copilot-cli"
LOG_FILE="$FEATURE_DIR/log.txt"

log() {
echo "$1"
echo "$1" >> "$LOG_FILE"
}

if command -v sudo > /dev/null; then
SUDO="sudo"
else
SUDO=""
fi

$SUDO chown -R "$(id -u):$(id -g)" "$LOG_FILE"

log "In OnCreate script"
if [ -f "$FEATURE_DIR/markers/oncreate" ]; then
log "Feature 'github-copilot-cli' oncreate actions already run, skipping"
exit 0
fi

if [ ! -w "/dc/github-copilot-cli" ]; then
log "Fixing permissions of '/dc/github-copilot-cli'..."
$SUDO chown -R "$(id -u):$(id -g)" "/dc/github-copilot-cli"
log "Done!"
else
log "Permissions of '/dc/github-copilot-cli' are OK!"
fi

log "Adding marker file to indicate oncreate actions have been run"
$SUDO mkdir -p "$FEATURE_DIR/markers"
$SUDO touch "$FEATURE_DIR/markers/oncreate"

log "Done"

2 changes: 2 additions & 0 deletions test-project/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@
"ghcr.io/azure/azure-dev/azd:0": {},
"./src/azd-cli-persistence": {},
// "./src/dev-tunnels" : {}
// "./src/railway-cli": {}
"./src/github-copilot-cli": {}
}
}
Loading