aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/release-v1.yaml40
-rw-r--r--collection/java/wrapper.sh52
-rw-r--r--collection/python/install.sh (renamed from collection/python/python-debian.sh)0
-rw-r--r--v1/README.md2
-rwxr-xr-xv1/combine-feature-fragments.py32
-rw-r--r--v1/feature-scripts.env23
-rwxr-xr-xv1/install.sh60
7 files changed, 209 insertions, 0 deletions
diff --git a/.github/workflows/release-v1.yaml b/.github/workflows/release-v1.yaml
new file mode 100644
index 0000000..fbae8cc
--- /dev/null
+++ b/.github/workflows/release-v1.yaml
@@ -0,0 +1,40 @@
+name: "Package dev container features (v1)"
+on:
+ # Will create a release ON THE CURRENT TAG
+ workflow_dispatch:
+
+jobs:
+ deploy: # make sure the action works on a clean machine without building
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Combine Feature Fragments
+ run: ./v1/combine-feature-fragments.py > ./collection/devcontainer-features.json
+
+ - name: Copy scripts to src folder
+ id: copy_scripts
+ run: cp -r ./v1/install.sh ./v1/feature-scripts.env ./collection
+
+ - name: Debug Output
+ run: sudo apt install tree -y && tree
+
+ - name: Generate tgz
+ uses: microsoft/publish-dev-container-features-action@main # devcontainers/action
+ with:
+ publish-features: "true"
+ path-to-features: "./collection"
+ publish-definitions: "false"
+
+ - uses: actions/upload-artifact@v3
+ with:
+ name: devcontainer-features.tgz
+ path: devcontainer-features.tgz
+
+ # - name: Get or Create Release at current tag
+ # uses: ncipollo/release-action@v1
+ # with:
+ # allowUpdates: true # Lets us upload our own artifact from previous step
+ # artifactErrorsFailBuild: true
+ # artifacts: "./devcontainer-*"
+ # token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/collection/java/wrapper.sh b/collection/java/wrapper.sh
new file mode 100644
index 0000000..c48e7d9
--- /dev/null
+++ b/collection/java/wrapper.sh
@@ -0,0 +1,52 @@
+#!/usr/bin/env bash
+# Wrapper function that also installs JDK 11 if JDK 8 is selected since this is required for the Java extension
+
+set -e
+
+JAVA_VERSION=${1:-"default"}
+SDKMAN_DIR=${2:-"/usr/local/sdkman"}
+USERNAME=${3:-"automatic"}
+UPDATE_RC=${4:-"true"}
+ADDITIONAL_JAVA_VERSION=11
+
+cd "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+chmod +x java-debian.sh
+
+is_jdk_8="false"
+if echo "${JAVA_VERSION}" | grep -E '^8([\s\.]|$)' > /dev/null 2>&1; then
+ is_jdk_8="true"
+fi
+
+# If the user selected JDK 8, install the JDK 11 as well since this is needed by the Java extension
+if [ "${is_jdk_8}" = "true" ]; then
+ echo "(*) Installing JDK ${ADDITIONAL_JAVA_VERSION} as Java VS Code extension requires a recent JDK..."
+ ./java-debian.sh "${ADDITIONAL_JAVA_VERSION}" "${SDKMAN_DIR}" "${USERNAME}" "${UPDATE_RC}"
+ jdk_11_folder="$(ls --format=single-column ${SDKMAN_DIR}/candidates/java | grep -oE -m 1 '11\..+')"
+ ln -s "${SDKMAN_DIR}/candidates/java/${jdk_11_folder}" /extension-java-home
+
+ # Determine the appropriate non-root user
+ username=""
+ possible_users=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)")
+ 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
+else
+ ln -s ${SDKMAN_DIR}/candidates/java/current /extension-java-home
+fi
+
+echo "(*) Installing JDK ${JAVA_VERSION}..."
+./java-debian.sh "${JAVA_VERSION}" "${SDKMAN_DIR}" "${USERNAME}" "${UPDATE_RC}"
+if [ "${is_jdk_8}" = "true" ]; then
+ # Set current and default version to last SDK installed
+ jdk_full_version="$(ls --format=single-column "${SDKMAN_DIR}/candidates/java" | sort -rV | grep -oE -m 1 "${JAVA_VERSION}\\..+" )"
+ echo "(*) Setting default JDK to ${jdk_full_version}..."
+ . ${SDKMAN_DIR}/bin/sdkman-init.sh
+ sdk use java "${jdk_full_version}"
+ sdk default java "${jdk_full_version}"
+fi \ No newline at end of file
diff --git a/collection/python/python-debian.sh b/collection/python/install.sh
index 3a2d429..3a2d429 100644
--- a/collection/python/python-debian.sh
+++ b/collection/python/install.sh
diff --git a/v1/README.md b/v1/README.md
new file mode 100644
index 0000000..316d69f
--- /dev/null
+++ b/v1/README.md
@@ -0,0 +1,2 @@
+Files in this folder are designed for back-compat with 'v1'
+while waiting 'v2' implementation: https://github.com/devcontainers/cli/pull/6
diff --git a/v1/combine-feature-fragments.py b/v1/combine-feature-fragments.py
new file mode 100755
index 0000000..bbc9913
--- /dev/null
+++ b/v1/combine-feature-fragments.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python3
+
+# Run from repo root.
+
+import os
+
+featureDirs = os.listdir('./collection')
+
+beginning = """
+{
+ "features": [
+"""
+
+middle = ""
+
+end = """
+ ]
+}
+"""
+
+count = len(featureDirs)
+
+for fDir in featureDirs:
+ count -= 1
+ config = f'./collection/{fDir}/feature.json'
+ data = open(config, "r").read()
+ middle += f'{data}'
+ if count != 0:
+ middle += ','
+ middle += '\n'
+
+print(f'{beginning}{middle}{end}')
diff --git a/v1/feature-scripts.env b/v1/feature-scripts.env
new file mode 100644
index 0000000..848302b
--- /dev/null
+++ b/v1/feature-scripts.env
@@ -0,0 +1,23 @@
+_BUILD_ARG_COMMON="./common/install.sh ${_BUILD_ARG_COMMON_INSTALLZSH} ${_BUILD_ARG_COMMON_USERNAME} ${_BUILD_ARG_COMMON_UID} ${_BUILD_ARG_COMMON_GID} ${_BUILD_ARG_COMMON_UPGRADEPACKAGES} ${_BUILD_ARG_COMMON_INSTALLOHMYZSH} ${_BUILD_ARG_COMMON_NONFREEPACKAGES}"
+_BUILD_ARG_GIT="./git/install.sh ${_BUILD_ARG_GIT_VERSION:-latest} ${_BUILD_ARG_GIT_PPA:-true}"
+_BUILD_ARG_GIT_LFS="./git-lfs/install.sh ${_BUILD_ARG_GIT_LFS_VERSION:-latest}"
+_BUILD_ARG_DOCKER_IN_DOCKER="./docker-in-docker/install.sh true automatic ${_BUILD_ARG_DOCKER_IN_DOCKER_MOBY:-true} ${_BUILD_ARG_DOCKER_IN_DOCKER_VERSION:-latest} ${_BUILD_ARG_DOCKER_IN_DOCKER_DOCKERDASHCOMPOSEVERSION:-v1}"
+_BUILD_ARG_DOCKER_FROM_DOCKER="./docker-from-docker/install.sh true /var/run/docker-host.sock /var/run/docker.sock automatic ${_BUILD_ARG_DOCKER_FROM_DOCKER_MOBY:-true} ${_BUILD_ARG_DOCKER_FROM_DOCKER_VERSION:-latest} ${_BUILD_ARG_DOCKER_FROM_DOCKER_DOCKERDASHCOMPOSEVERSION:-v1}"
+_BUILD_ARG_KUBECTL_HELM_MINIKUBE="./kubectl-helm-debian/install.sh ${_BUILD_ARG_KUBECTL_HELM_MINIKUBE_VERSION:-latest} ${_BUILD_ARG_KUBECTL_HELM_MINIKUBE_HELM:-latest} ${_BUILD_ARG_KUBECTL_HELM_MINIKUBE_MINIKUBE:-latest}"
+_BUILD_ARG_TERRAFORM="./terraform/install.sh ${_BUILD_ARG_TERRAFORM_VERSION:-latest} ${_BUILD_ARG_TERRAFORM_TFLINT:-latest} ${_BUILD_ARG_TERRAFORM_TERRAGRUNT:-latest}"
+_BUILD_ARG_GITHUB_CLI="./github-cli/install.sh ${_BUILD_ARG_GITHUB_CLI_VERSION:-latest}"
+_BUILD_ARG_AWS_CLI="./aws-cli/install.sh ${_BUILD_ARG_AWS_CLI_VERSION:-latest}"
+_BUILD_ARG_AZURE_CLI="./az-cli/install.sh ${_BUILD_ARG_AZURE_CLI_VERSION:-latest}"
+_BUILD_ARG_SSH="./sshd/install.sh"
+_BUILD_ARG_NODE="./node/install.sh /usr/local/share/nvm ${_BUILD_ARG_NODE_VERSION:-lts/*} automatic true ${_BUILD_ARG_NODE_NODEGYPDEPENDENCIES:-true}"
+_BUILD_ARG_PYTHON="./python/install.sh ${_BUILD_ARG_PYTHON_VERSION:-latest} /usr/local/python /usr/local/py-utils automatic true ${_BUILD_ARG_PYTHON_INSTALLTOOLS:-true} true ${_BUILD_ARG_PYTHON_OPTIMIZE:-false}"
+_BUILD_ARG_GOLANG="./go/install.sh ${_BUILD_ARG_GOLANG_VERSION:-latest}"
+_BUILD_ARG_JAVA="./java/wrapper.sh ${_BUILD_ARG_JAVA_VERSION:-latest}"
+_BUILD_ARG_GRADLE="./gradle/install.sh ${_BUILD_ARG_GRADLE_VERSION:-latest}"
+_BUILD_ARG_MAVEN="./maven/install.sh ${_BUILD_ARG_MAVEN_VERSION:-latest}"
+_BUILD_ARG_RUBY="./ruby/install.sh ${_BUILD_ARG_RUBY_VERSION:-latest}"
+_BUILD_ARG_RUST="./rust/install.sh /usr/local/cargo /usr/local/rustup automatic true false ${_BUILD_ARG_RUST_VERSION:-latest} ${_BUILD_ARG_RUST_PROFILE:-minimal}"
+_BUILD_ARG_POWERSHELL="./powershell/install.sh ${_BUILD_ARG_POWERSHELL_VERSION:-latest}"
+_BUILD_ARG_DESKTOP_LITE="./desktop-lite/install.sh automatic ${_BUILD_ARG_DESKTOP_LITE_PASSWORD:-vscode} true ${_BUILD_ARG_DESKTOP_LITE_VNCPORT:-5901} ${_BUILD_ARG_DESKTOP_LITE_WEBPORT:-6080}"
+_BUILD_ARG_DOTNET="./dotnet/install.sh ${_BUILD_ARG_DOTNET_VERSION:-latest} ${_BUILD_ARG_DOTNET_RUNTIMEONLY:-false} automatic true /usr/local/dotnet dotnet"
+_BUILD_ARG_JUPYTERLAB="./jupyterlab/install.sh ${_BUILD_ARG_JUPYTERLAB_VERSION:-latest}"
diff --git a/v1/install.sh b/v1/install.sh
new file mode 100755
index 0000000..758b4cd
--- /dev/null
+++ b/v1/install.sh
@@ -0,0 +1,60 @@
+#!/usr/bin/env bash
+
+# Support 'v1' dev container feature installation
+# that require a root 'install.sh' script.
+
+set -e
+cd "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+# Verify we're on a supported OS
+. /etc/os-release
+if [ "${ID}" != "debian" ] && [ "${ID_LIKE}" != "debian" ]; then
+cat << EOF
+
+*********** Unsupported operating system "${ID}" detected ***********
+
+Features support currently requires a Debian/Ubuntu-based image. Update your
+image or Dockerfile FROM statement to start with a supported OS. For example:
+mcr.microsoft.com/vscode/devcontainers/base:ubuntu
+
+Aborting build...
+
+EOF
+ exit 2
+fi
+
+set -a
+. ./devcontainer-features.env
+set +a
+
+chmod +x *.sh
+
+# Execute option scripts if correct environment variable is set to "true"
+feature_marker_path="/usr/local/etc/vscode-dev-containers/features"
+mkdir -p "${feature_marker_path}"
+while IFS= read -r feature_line; do
+ # Extract the env var part of the line
+ feature_var_name="${feature_line%%=*}"
+ if [ ! -z "${!feature_var_name}" ]; then
+ # If a value is set for the env var, execute the script
+ feature_script_and_args="${feature_line##*=}"
+ feature_script_and_args="${feature_script_and_args%\"}"
+ script_command="$(eval echo "${feature_script_and_args#\"}")"
+ echo "(*) Script: ${script_command}"
+
+ # Check if script with same args has already been run
+ feature_marker="${feature_marker_path}/${feature_var_name}";
+ if [ -e "${feature_marker}" ] && [ "${script_command}" = "$(cat ${feature_marker})" ]; then
+ echo "(*) Skipping. Script already run with same arguments."
+ else
+ # Execute script and create a marker with the script args
+ ./${script_command}
+ echo "${script_command}" > "${feature_marker}"
+ fi
+ fi
+done < ./feature-scripts.env
+
+# Clean up
+apt-get autoremove -y
+apt-get clean -y
+rm -rf /var/lib/apt/lists/*