-
-
Notifications
You must be signed in to change notification settings - Fork 72
[feat] Add webi feature #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
|
|
||
| # webi packages (webi-packages) | ||
|
|
||
| Install webi and use it to install specified packages | ||
|
|
||
| ## Example Usage | ||
|
|
||
| ```json | ||
| "features": { | ||
| "ghcr.io/devcontainers-extra/features/webi-packages:1": {} | ||
| } | ||
| ``` | ||
|
|
||
| ## Options | ||
|
|
||
| | Options Id | Description | Type | Default Value | | ||
| |-----|-----|-----|-----| | ||
| | packages | List of packages to install, comma-separated (e.g., 'node@lts', 'deno'). | string | - | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "id": "webi-packages", | ||
| "version": "1.0.0", | ||
| "name": "webi packages", | ||
| "documentationURL": "http://github.com/devcontainers-extra/features/tree/main/src/webi-packages", | ||
| "description": "Install webi and use it to install specified packages", | ||
| "options": { | ||
| "packages": { | ||
| "type": "string", | ||
| "description": "List of packages to install, comma-separated (e.g., 'node@lts', 'deno')", | ||
| "default": "" | ||
| } | ||
| }, | ||
| "installsAfter": [ | ||
| "ghcr.io/devcontainers/features/common-utils" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e | ||
|
|
||
| USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}" | ||
| PACKAGES="${PACKAGES:-""}" | ||
|
|
||
| if [ "$(id -u)" -ne 0 ]; then | ||
| echo "Script must be run as root. Use sudo, su, or add \"USER root\" to your Dockerfile before running this script." | ||
| exit 1 | ||
| fi | ||
|
|
||
| . ./utils.sh | ||
|
|
||
| install_webi "$(determine_user "$USERNAME")" "$PACKAGES" | ||
|
|
||
| clean | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| install_webi() { | ||
| local USERNAME="$1" | ||
| local PACKAGES="$2" | ||
|
|
||
| check_command curl | ||
|
|
||
| su - "${USERNAME}" <<EOF | ||
| if ! command -v webi &>/dev/null; then | ||
| echo "Installing webinstall.dev for user ${USERNAME}..." | ||
| curl -sS https://webi.sh/webi | sh | ||
| source ~/.config/envman/PATH.env | ||
| echo "Webinstall.dev installation completed for user ${USERNAME}" | ||
| fi | ||
|
|
||
| if [ -n "$PACKAGES" ]; then | ||
| echo "Installing specified packages: ${PACKAGES}" | ||
| webi $(echo "$PACKAGES" | tr ',' ' ') | ||
| fi | ||
| EOF | ||
| } | ||
|
|
||
| determine_user() { | ||
| local USERNAME="${1:-"auto"}" | ||
| if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then | ||
| USERNAME="" | ||
| check_command awk >/dev/null 2>&1 | ||
| USERNAME_UID_1000="$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)" | ||
| POSSIBLE_USERS=("vscode" "node" "codespace" "${USERNAME_UID_1000}") | ||
| for CURRENT_USER in "${POSSIBLE_USERS[@]}"; do | ||
| if id -u "${CURRENT_USER}" >/dev/null 2>&1; then | ||
| USERNAME=${CURRENT_USER} | ||
| break | ||
| fi | ||
| done | ||
| if [ "${USERNAME}" = "" ]; then | ||
| USERNAME=root | ||
| fi | ||
| elif [ "${USERNAME}" = "none" ] || ! id -u "${USERNAME}" >/dev/null 2>&1; then | ||
| USERNAME=root | ||
| fi | ||
|
|
||
| echo "${USERNAME}" | ||
| } | ||
|
|
||
| check_command() { | ||
| local cmd=$1 | ||
|
|
||
| if command -v "$cmd" &>/dev/null; then | ||
| echo "$cmd is already installed" | ||
| return 0 | ||
| fi | ||
|
|
||
| echo "$cmd not found, attempting to install..." | ||
|
|
||
| if command -v apt &>/dev/null; then | ||
| echo "Installing using apt..." | ||
| apt update | ||
| apt -y install --no-install-recommends "$cmd" | ||
| return $? | ||
| fi | ||
|
|
||
| if command -v apk &>/dev/null; then | ||
| echo "Installing using apk..." | ||
| apk update | ||
| apk add --no-cache "$cmd" | ||
| return $? | ||
| fi | ||
|
|
||
| echo "Error: No supported package manager found (apt/apk)" | ||
| return 1 | ||
| } | ||
|
|
||
| clean() { | ||
| if command -v apt &>/dev/null; then | ||
| apt clean | ||
| rm -rf /var/lib/apt/lists/* | ||
| fi | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "test": { | ||
| "image": "mcr.microsoft.com/devcontainers/base:debian", | ||
| "features": { | ||
| "webi-packages": { | ||
| "packages": "node@18,deno" | ||
| } | ||
| } | ||
| }, | ||
| "test_alpine": { | ||
| "image": "mcr.microsoft.com/devcontainers/base:alpine", | ||
| "features": { | ||
| "webi-packages": { | ||
| "packages": "node@18" | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e | ||
|
|
||
| source dev-container-features-test-lib | ||
|
|
||
| check "node version is equal to 18.*.*" sh -c "node --version | grep '18.*.*'" | ||
|
|
||
| check "deno --version" deno --version | ||
|
|
||
| reportResults |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e | ||
|
|
||
| source dev-container-features-test-lib | ||
|
|
||
| source ~/.config/envman/PATH.env | ||
|
koralowiec marked this conversation as resolved.
|
||
|
|
||
| check "node version is equal to 18.*.*" sh -c "node --version | grep '18.*.*'" | ||
|
|
||
| reportResults | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.