#!/bin/bash -e ################################################################################ ## File: install-docker.sh ## Desc: Install docker onto the image ## Supply chain security: amazon-ecr-credential-helper - dynamic checksum validation ################################################################################ # Source the helpers for use with the script source $HELPER_SCRIPTS/install.sh REPO_URL="https://download.docker.com/linux/ubuntu" GPG_KEY="/usr/share/keyrings/docker.gpg" REPO_PATH="/etc/apt/sources.list.d/docker.list" os_codename=$(lsb_release -cs) curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o $GPG_KEY echo "deb [arch=amd64 signed-by=$GPG_KEY] $REPO_URL ${os_codename} stable" > $REPO_PATH apt-get update # Install docker components which available via apt-get # Using toolsets keep installation order to install dependencies before the package in order to control versions components=$(get_toolset_value '.docker.components[] .package') for package in $components; do version=$(get_toolset_value ".docker.components[] | select(.package == \"$package\") | .version") if [[ $version == "latest" ]]; then apt-get install --no-install-recommends "$package" else version_string=$(apt-cache madison "$package" | awk '{ print $3 }' | grep "$version" | grep "$os_codename" | head -1) apt-get install --no-install-recommends "${package}=${version_string}" fi done # Install plugins that are best installed from the GitHub repository # Be aware that `url` built from github repo name and plugin name because of current repo naming for those plugins plugins=$(get_toolset_value '.docker.plugins[] .plugin') for plugin in $plugins; do version=$(get_toolset_value ".docker.plugins[] | select(.plugin == \"$plugin\") | .version") filter=$(get_toolset_value ".docker.plugins[] | select(.plugin == \"$plugin\") | .asset") url=$(resolve_github_release_asset_url "docker/$plugin" "endswith(\"$filter\")" "$version") binary_path=$(download_with_retry "$url" "/tmp/docker-$plugin") mkdir -pv "/usr/libexec/docker/cli-plugins" install "$binary_path" "/usr/libexec/docker/cli-plugins/docker-$plugin" done # docker from official repo introduced different GID generation: https://github.com/actions/runner-images/issues/8157 gid=$(cut -d ":" -f 3 /etc/group | grep "^1..$" | sort -n | tail -n 1 | awk '{ print $1+1 }') groupmod -g "$gid" docker # Create systemd-tmpfiles configuration for Docker cat <