From c12a205ab8e195541acfe0cb654b4888e16ea05c Mon Sep 17 00:00:00 2001 From: Josh Spicer Date: Fri, 3 Jun 2022 10:46:25 -0400 Subject: Pass options via environment variables (#39) * up to docker-in-docker converted * first pass at the rest of the features (and bash linting and updated CLI * move shell linter to own file * rename feature.json -> devcontainer-feature.json * continue on error * continue on error in right spot * formatting * fix AZ_VERSION * update python * restore variable name * update linter actions, fix dind/dfd/desktop scripts, add test-scenaerios * add tree because I like tree * glob for shell linter * fix test-scenarios * shell linter * more shell helper --- src/docker-from-docker/devcontainer-feature.json | 48 ++++++++++++++++++++++++ src/docker-from-docker/feature.json | 41 -------------------- src/docker-from-docker/install.sh | 22 +++++------ 3 files changed, 59 insertions(+), 52 deletions(-) create mode 100644 src/docker-from-docker/devcontainer-feature.json delete mode 100644 src/docker-from-docker/feature.json (limited to 'src/docker-from-docker') diff --git a/src/docker-from-docker/devcontainer-feature.json b/src/docker-from-docker/devcontainer-feature.json new file mode 100644 index 0000000..f9c5d28 --- /dev/null +++ b/src/docker-from-docker/devcontainer-feature.json @@ -0,0 +1,48 @@ +{ + "id": "docker-from-docker", + "name": "Docker (Moby) support, reuse host Docker Engine (Docker-from-Docker)", + "options": { + "version": { + "type": "string", + "proposals": [ + "latest", + "none", + "20.10" + ], + "default": "latest", + "description": "Select or enter a Docker/Moby CLI version. (Availability can vary by OS version.)" + }, + "moby": { + "type": "boolean", + "default": true, + "description": "Install OSS Moby build instead of Docker CE" + }, + "docker_dash_compose_version": { + "type": "string", + "enum": [ + "v1", + "v2" + ], + "default": "v1", + "description": "Compose version to use for docker-compose (v1 or v2)" + } + }, + "entrypoint": "/usr/local/share/docker-init.sh", + "containerEnv": { + "DOCKER_BUILDKIT": "1" + }, + "extensions": [ + "ms-azuretools.vscode-docker" + ], + "mounts": [ + { + "source": "/var/run/docker.sock", + "target": "/var/run/docker-host.sock", + "type": "bind" + } + ], + "install": { + "app": "", + "file": "install.sh" + } +} \ No newline at end of file diff --git a/src/docker-from-docker/feature.json b/src/docker-from-docker/feature.json deleted file mode 100644 index ce955a7..0000000 --- a/src/docker-from-docker/feature.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "id": "docker-from-docker", - "name": "Docker (Moby) support, reuse host Docker Engine (Docker-from-Docker)", - "options": { - "version": { - "type": "string", - "proposals": ["latest", "none", "20.10"], - "default": "latest", - "description": "Select or enter a Docker/Moby CLI version. (Availability can vary by OS version.)" - }, - "moby": { - "type": "boolean", - "default": true, - "description": "Install OSS Moby build instead of Docker CE" - }, - "dockerDashComposeVersion": { - "type": "string", - "enum": ["v1", "v2" ], - "default": "v1", - "description": "Compose version to use for docker-compose (v1 or v2)" - } - }, - "entrypoint": "/usr/local/share/docker-init.sh", - "containerEnv": { - "DOCKER_BUILDKIT": "1" - }, - "extensions": [ - "ms-azuretools.vscode-docker" - ], - "mounts": [ - { - "source":"/var/run/docker.sock", - "target":"/var/run/docker-host.sock", - "type":"bind" - } - ], - "install": { - "app": "", - "file": "install.sh" - } -} \ No newline at end of file diff --git a/src/docker-from-docker/install.sh b/src/docker-from-docker/install.sh index 1102ae9..88ad52f 100644 --- a/src/docker-from-docker/install.sh +++ b/src/docker-from-docker/install.sh @@ -6,16 +6,16 @@ # # Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/docker.md # Maintainer: The VS Code and Codespaces Teams -# -# Syntax: ./docker-debian.sh [enable non-root docker socket access flag] [source socket] [target socket] [non-root user] [use moby] [CLI version] [Major version for docker-compose] - -ENABLE_NONROOT_DOCKER=${1:-"true"} -SOURCE_SOCKET=${2:-"/var/run/docker-host.sock"} -TARGET_SOCKET=${3:-"/var/run/docker.sock"} -USERNAME=${4:-"automatic"} -USE_MOBY=${5:-"true"} -DOCKER_VERSION=${6:-"latest"} -DOCKER_DASH_COMPOSE_VERSION=${7:-"v1"} # v1 or v2 + +DOCKER_VERSION=${VERSION:-"latest"} +USE_MOBY=${MOBY:-"true"} +DOCKER_DASH_COMPOSE_VERSION=${DOCKER_DASH_COMPOSE_VERSION:-"v1"} # v1 or v2 + +ENABLE_NONROOT_DOCKER=${ENABLE_NONROOT_DOCKER:-"true"} +SOURCE_SOCKET=${SOURCE_SOCKET:-"/var/run/docker-host.sock"} +TARGET_SOCKET=${TARGET_SOCKET:-"/var/run/docker.sock"} +USERNAME=${USERNAME:-"automatic"} + MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc" DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES="buster bullseye bionic focal jammy" DOCKER_LICENSED_ARCHIVE_VERSION_CODENAMES="buster bullseye bionic focal hirsute impish jammy" @@ -31,7 +31,7 @@ fi if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then USERNAME="" POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)") - for CURRENT_USER in ${POSSIBLE_USERS[@]}; do + for CURRENT_USER in "${POSSIBLE_USERS[@]}"; do if id -u ${CURRENT_USER} > /dev/null 2>&1; then USERNAME=${CURRENT_USER} break -- cgit v1.2.3