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
8 changes: 4 additions & 4 deletions src/docker-in-docker/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "docker-in-docker",
"version": "2.12.0",
"version": "2.12.1",
"name": "Docker (Docker-in-Docker)",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/docker-in-docker",
"description": "Create child containers *inside* a container, independent from the host's docker instance. Installs Docker extension in the container along with needed CLIs.",
Expand Down Expand Up @@ -29,11 +29,11 @@
"type": "string",
"enum": [
"none",
"latest",
"v1",
"v2"
],
"default": "latest",
"description": "Default version of Docker Compose (latest, v2 or none)"
"default": "v2",
"description": "Default version of Docker Compose (v1, v2 or none)"
},
"azureDnsAutoDetection": {
"type": "boolean",
Expand Down
33 changes: 16 additions & 17 deletions src/docker-in-docker/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
DOCKER_VERSION="${VERSION:-"latest"}" # The Docker/Moby Engine + CLI should match in version
USE_MOBY="${MOBY:-"true"}"
MOBY_BUILDX_VERSION="${MOBYBUILDXVERSION:-"latest"}"
DOCKER_DASH_COMPOSE_VERSION="${DOCKERDASHCOMPOSEVERSION:-"latest"}" #latest, v2 or none
DOCKER_DASH_COMPOSE_VERSION="${DOCKERDASHCOMPOSEVERSION:-"v2"}" #v1, v2 or none
AZURE_DNS_AUTO_DETECTION="${AZUREDNSAUTODETECTION:-"true"}"
DOCKER_DEFAULT_ADDRESS_POOL="${DOCKERDEFAULTADDRESSPOOL:-""}"
USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"
Expand Down Expand Up @@ -157,26 +157,28 @@ get_previous_version() {
local repo_url=$2
local variable_name=$3
prev_version=${!variable_name}

output=$(curl -s "$repo_url");
message=$(echo "$output" | jq -r '.message')

if [[ $message == "API rate limit exceeded"* ]]; then
echo -e "\nAn attempt to find latest version using GitHub Api Failed... \nReason: ${message}"
echo -e "\nAttempting to find latest version using GitHub tags."
find_prev_version_from_git_tags prev_version "$url" "tags/v"
declare -g ${variable_name}="${prev_version}"
else
if echo "$output" | jq -e 'type == "object"' > /dev/null; then
message=$(echo "$output" | jq -r '.message')

if [[ $message == "API rate limit exceeded"* ]]; then
echo -e "\nAn attempt to find latest version using GitHub Api Failed... \nReason: ${message}"
echo -e "\nAttempting to find latest version using GitHub tags."
find_prev_version_from_git_tags prev_version "$url" "tags/v"
declare -g ${variable_name}="${prev_version}"
fi
elif echo "$output" | jq -e 'type == "array"' > /dev/null; then
echo -e "\nAttempting to find latest version using GitHub Api."
version=$(echo "$output" | jq -r '.tag_name')
version=$(echo "$output" | jq -r '.[1].tag_name')
declare -g ${variable_name}="${version#v}"
fi
echo "${variable_name}=${!variable_name}"
}

get_github_api_repo_url() {
local url=$1
echo "${url/https:\/\/github.com/https:\/\/api.github.com\/repos}/releases/latest"
echo "${url/https:\/\/github.com/https:\/\/api.github.com\/repos}/releases"
}

###########################################
Expand Down Expand Up @@ -372,11 +374,8 @@ if [ "${DOCKER_DASH_COMPOSE_VERSION}" != "none" ]; then
find_version_from_git_tags compose_version "$docker_compose_url" "tags/v"
echo "(*) Installing docker-compose ${compose_version}..."
curl -fsSL "https://github.com/docker/compose/releases/download/v${compose_version}/docker-compose-linux-${target_compose_arch}" -o ${docker_compose_path} || {
if [[ $DOCKER_DASH_COMPOSE_VERSION == "latest" ]]; then
fallback_compose "$docker_compose_url"
else
echo -e "Error: Failed to install docker-compose v${compose_version}"
fi
echo -e "\n(!) Failed to fetch the latest artifacts for docker-compose v${compose_version}..."
fallback_compose "$docker_compose_url"
}

chmod +x ${docker_compose_path}
Expand Down
31 changes: 14 additions & 17 deletions test/docker-in-docker/docker_build_fallback_compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,31 +108,28 @@ get_previous_version() {
local mode=$4
prev_version=${!variable_name}

echo -e "\nAttempting to find latest version using Github Api."

output=$(curl -s "$repo_url");
message=$(echo "$output" | jq -r '.message')

if [[ $mode != "install_from_github_api_valid" ]]; then
message="API rate limit exceeded"
fi

if [[ $message == "API rate limit exceeded"* ]]; then
echo -e "\nAttempting to find latest version using Github Api Failed. Exceeded API Rate Limit."
echo -e "\nAttempting to find latest version using Github Tags."
find_prev_version_from_git_tags prev_version "$url" "tags/v"
declare -g ${variable_name}="${prev_version}"
else
echo -e "\nAttempting to find latest version using Github Api Succeeded."
version=$(echo "$output" | jq -r '.tag_name')
if echo "$output" | jq -e 'type == "object"' > /dev/null; then
message=$(echo "$output" | jq -r '.message')
if [[ $message == "API rate limit exceeded"* ]]; then
echo -e "\nAn attempt to find latest version using GitHub Api Failed... \nReason: ${message}"
echo -e "\nAttempting to find latest version using GitHub tags."
find_prev_version_from_git_tags prev_version "$url" "tags/v"
declare -g ${variable_name}="${prev_version}"
fi
elif echo "$output" | jq -e 'type == "array"' > /dev/null; then
echo -e "\nAttempting to find latest version using GitHub Api."
version=$(echo "$output" | jq -r '.[1].tag_name')
declare -g ${variable_name}="${version#v}"
fi
fi
echo "${variable_name}=${!variable_name}"
}

get_github_api_repo_url() {
local url=$1
echo "${url/https:\/\/github.com/https:\/\/api.github.com\/repos}/releases/latest"
echo "${url/https:\/\/github.com/https:\/\/api.github.com\/repos}/releases"
}

install_using_get_previous_version() {
Expand Down
Loading