Skip to content

Commit 06bdd7c

Browse files
committed
Initial commit
1 parent 7a0f10e commit 06bdd7c

File tree

9 files changed

+257
-0
lines changed

9 files changed

+257
-0
lines changed

.devcontainer/devcontainer.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"image": "mcr.microsoft.com/devcontainers/javascript-node:1-20-bookworm",
3+
"customizations": {
4+
"vscode": {
5+
"settings": {
6+
"json.schemas": [
7+
{
8+
"fileMatch": [
9+
"*/devcontainer-feature.json"
10+
],
11+
"url": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainerFeature.schema.json"
12+
}
13+
]
14+
},
15+
"extensions": [
16+
"mads-hartmann.bash-ide-vscode"
17+
]
18+
}
19+
},
20+
"features": {
21+
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
22+
},
23+
"remoteUser": "node",
24+
"updateContentCommand": "npm install -g @devcontainers/cli"
25+
}

.github/workflows/release.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: "Release dev container features & Generate Documentation"
2+
on:
3+
workflow_dispatch:
4+
5+
jobs:
6+
deploy:
7+
if: ${{ github.ref == 'refs/heads/main' }}
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
packages: write
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: "Publish Features"
17+
uses: devcontainers/action@v1
18+
with:
19+
publish-features: "true"
20+
base-path-to-features: "./src"
21+
generate-docs: "true"
22+
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Create PR for Documentation
27+
id: push_image_info
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
run: |
31+
set -e
32+
echo "Start."
33+
# Configure git and Push updates
34+
git config --global user.email github-actions[bot]@users.noreply.github.com
35+
git config --global user.name github-actions[bot]
36+
git config pull.rebase false
37+
branch=automated-documentation-update-$GITHUB_RUN_ID
38+
git checkout -b $branch
39+
message='Automated documentation update'
40+
# Add / update and commit
41+
git add */**/README.md
42+
git commit -m 'Automated documentation update [skip ci]' || export NO_UPDATES=true
43+
# Push
44+
if [ "$NO_UPDATES" != "true" ] ; then
45+
git push origin "$branch"
46+
gh pr create --title "$message" --body "$message"
47+
fi

.github/workflows/test.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: "Release dev container features & Generate Documentation"
2+
on:
3+
workflow_dispatch:
4+
5+
jobs:
6+
deploy:
7+
if: ${{ github.ref == 'refs/heads/main' }}
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
packages: write
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: "Publish Features"
17+
uses: devcontainers/action@v1
18+
with:
19+
publish-features: "true"
20+
base-path-to-features: "./src"
21+
generate-docs: "true"
22+
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Create PR for Documentation
27+
id: push_image_info
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
run: |
31+
set -e
32+
echo "Start."
33+
# Configure git and Push updates
34+
git config --global user.email github-actions[bot]@users.noreply.github.com
35+
git config --global user.name github-actions[bot]
36+
git config pull.rebase false
37+
branch=automated-documentation-update-$GITHUB_RUN_ID
38+
git checkout -b $branch
39+
message='Automated documentation update'
40+
# Add / update and commit
41+
git add */**/README.md
42+
git commit -m 'Automated documentation update [skip ci]' || export NO_UPDATES=true
43+
# Push
44+
if [ "$NO_UPDATES" != "true" ] ; then
45+
git push origin "$branch"
46+
gh pr create --title "$message" --body "$message"
47+
fi

.github/workflows/validate.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: "Validate devcontainer-feature.json files"
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
6+
jobs:
7+
validate:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- name: "Validate devcontainer-feature.json files"
13+
uses: devcontainers/action@v1
14+
with:
15+
validate-only: "true"
16+
base-path-to-features: "./src"

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Dev Container Features
2+
3+
> This repository contains custom dev container features that enhance my development workflow. The features are located in the `src` directory and include tools and configurations that I frequently use.

src/ngrok/devcontainer-feature.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "ngrok",
3+
"id": "ngrok",
4+
"version": "1.0.0",
5+
"description": "Globally distributed reverse proxy that secures, protects and accelerates your applications and network services, no matter where you run them.",
6+
"options": {
7+
"authtoken": {
8+
"type": "string",
9+
"proposals": [],
10+
"default": "",
11+
"description": "Connect ngrok to your account by providing your `authtoken`"
12+
}
13+
},
14+
"installsAfter": ["ghcr.io/devcontainers/features/common-utils"]
15+
}

src/ngrok/install.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/sh
2+
set -e
3+
4+
check_dependencies() {
5+
for dep in "$@"; do
6+
if ! command -v "$dep" >/dev/null 2>&1; then
7+
echo "error: $dep is not installed, attempting to install..."
8+
if command -v apt-get >/dev/null 2>&1; then
9+
apt-get update && apt-get install --no-install-recommends -y "$dep"
10+
else
11+
echo "error: cannot install $dep, please install it manually" >&2
12+
exit 1
13+
fi
14+
fi
15+
done
16+
}
17+
18+
get_architecture() {
19+
ARCH=$(uname -m)
20+
case "$ARCH" in
21+
armhf) echo 'arm' ;;
22+
armv7) echo 'arm' ;;
23+
aarch64) echo 'arm64' ;;
24+
x86_64) echo 'amd64' ;;
25+
x86) echo '386' ;;
26+
*) echo >&2 "error: unsupported architecture: $ARCH"; exit 1 ;;
27+
esac
28+
}
29+
30+
install_ngrok() {
31+
if command -v ngrok >/dev/null 2>&1; then
32+
echo "ngrok is already installed"
33+
return
34+
fi
35+
36+
ARCH=$(get_architecture)
37+
38+
curl -L https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-${ARCH}.tgz --progress-bar -o ngrok-v3-stable-linux-${ARCH}.tgz \
39+
&& tar -xvf ngrok-v3-stable-linux-${ARCH}.tgz \
40+
&& mv ngrok /usr/local/bin/ \
41+
&& rm -f ngrok-v3-stable-linux-${ARCH}.tgz
42+
}
43+
44+
configure_ngrok() {
45+
if [ -n "$NG_TOKEN" ]; then
46+
ngrok config add-authtoken "$NG_TOKEN"
47+
fi
48+
}
49+
50+
check_dependencies curl ca-certificates
51+
install_ngrok
52+
configure_ngrok

test/ngrok/scenarios.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"test": {
3+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
4+
"features": {
5+
"ngrok": {}
6+
}
7+
}
8+
}

test/ngrok/test.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
# This test file will be executed against an auto-generated devcontainer.json that
4+
# includes the 'ngrok' Feature with no options.
5+
#
6+
# For more information, see: https://github.com/devcontainers/cli/blob/main/docs/features/test.md
7+
#
8+
# Eg:
9+
# {
10+
# "image": "<..some-base-image...>",
11+
# "features": {
12+
# "ngrok": {}
13+
# },
14+
# "remoteUser": "root"
15+
# }
16+
#
17+
# These scripts are run as 'root' by default. Although that can be changed
18+
# with the '--remote-user' flag.
19+
#
20+
# This test can be run with the following command:
21+
#
22+
# devcontainer features test \
23+
# --features ngrok \
24+
# --remote-user root \
25+
# --skip-scenarios \
26+
# --base-image mcr.microsoft.com/devcontainers/base:ubuntu \
27+
# /path/to/this/repo
28+
29+
set -e
30+
31+
# Optional: Import test library bundled with the devcontainer CLI
32+
# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib
33+
# Provides the 'check' and 'reportResults' commands.
34+
source dev-container-features-test-lib
35+
36+
# Feature-specific tests
37+
# The 'check' command comes from the dev-container-features-test-lib. Syntax is...
38+
# check <LABEL> <cmd> [args...]
39+
check "ngrok installation" command -v ngrok
40+
check "ngrok version" ngrok --version
41+
42+
# Report results
43+
# If any of the checks above exited with a non-zero exit code, the test will fail.
44+
reportResults

0 commit comments

Comments
 (0)