From a8cb375d460840bbf8c91599d16fc87d9ee8b996 Mon Sep 17 00:00:00 2001 From: eitsupi <50911393+eitsupi@users.noreply.github.com> Date: Tue, 11 Oct 2022 07:33:01 +0900 Subject: [PATCH] Ensure remove apt-update cache at the beginning and end of the scripts (#210) * remove apt lists * bump versions --- src/anaconda/devcontainer-feature.json | 2 +- src/anaconda/install.sh | 13 ++++++-- src/aws-cli/devcontainer-feature.json | 2 +- src/aws-cli/install.sh | 11 ++++++- src/azure-cli/devcontainer-feature.json | 2 +- src/azure-cli/install.sh | 13 ++++++-- src/common-utils/devcontainer-feature.json | 2 +- src/common-utils/install.sh | 12 ++++++-- src/conda/devcontainer-feature.json | 2 +- src/conda/install.sh | 16 ++++++---- src/desktop-lite/devcontainer-feature.json | 2 +- src/desktop-lite/install.sh | 18 +++++++---- .../devcontainer-feature.json | 2 +- src/docker-from-docker/install.sh | 30 +++++++++++-------- .../devcontainer-feature.json | 2 +- src/docker-in-docker/install.sh | 22 +++++++++----- src/dotnet/devcontainer-feature.json | 2 +- src/dotnet/install.sh | 14 +++++++-- src/git-lfs/devcontainer-feature.json | 2 +- src/git-lfs/install.sh | 17 +++++++---- src/git/devcontainer-feature.json | 2 +- src/git/install.sh | 19 +++++++++--- src/github-cli/devcontainer-feature.json | 2 +- src/github-cli/install.sh | 15 +++++++--- src/go/devcontainer-feature.json | 2 +- src/go/install.sh | 15 +++++++--- src/hugo/devcontainer-feature.json | 2 +- src/hugo/install.sh | 12 ++++++-- src/java/devcontainer-feature.json | 2 +- src/java/install.sh | 12 ++++++-- .../devcontainer-feature.json | 2 +- src/kubectl-helm-minikube/install.sh | 17 +++++++---- src/node/devcontainer-feature.json | 2 +- src/node/install.sh | 14 +++++++-- src/nvidia-cuda/devcontainer-feature.json | 2 +- src/nvidia-cuda/install.sh | 26 ++++++++++++++-- src/oryx/devcontainer-feature.json | 2 +- src/oryx/install.sh | 20 ++++++++----- src/php/devcontainer-feature.json | 2 +- src/php/install.sh | 11 ++++++- src/powershell/devcontainer-feature.json | 2 +- src/powershell/install.sh | 17 +++++++---- src/python/devcontainer-feature.json | 2 +- src/python/install.sh | 15 +++++++--- src/ruby/devcontainer-feature.json | 4 +-- src/ruby/install.sh | 15 +++++++--- src/rust/devcontainer-feature.json | 2 +- src/rust/install.sh | 23 +++++++++++--- src/sshd/devcontainer-feature.json | 2 +- src/sshd/install.sh | 15 ++++++++-- src/terraform/devcontainer-feature.json | 2 +- src/terraform/install.sh | 16 +++++++--- 52 files changed, 352 insertions(+), 130 deletions(-) diff --git a/src/anaconda/devcontainer-feature.json b/src/anaconda/devcontainer-feature.json index e4b753d..d0bc70d 100644 --- a/src/anaconda/devcontainer-feature.json +++ b/src/anaconda/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "anaconda", - "version": "1.0.7", + "version": "1.0.8", "name": "Anaconda", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/anaconda", "options": { diff --git a/src/anaconda/install.sh b/src/anaconda/install.sh index 468fd01..47f3462 100755 --- a/src/anaconda/install.sh +++ b/src/anaconda/install.sh @@ -16,6 +16,9 @@ CONDA_DIR=${CONDA_DIR:-"/usr/local/conda"} set -eux export DEBIAN_FRONTEND=noninteractive +# Clean up +rm -rf /var/lib/apt/lists/* + if [ "$(id -u)" -ne 0 ]; then echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 @@ -64,7 +67,10 @@ updaterc() { # Checks if packages are installed and installs them if not check_packages() { if ! dpkg -s "$@" > /dev/null 2>&1; then - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi apt-get -y install --no-install-recommends "$@" fi } @@ -128,4 +134,7 @@ if [ -f "/etc/bash.bashrc" ]; then echo "${notice_script}" | tee -a /etc/bash.bashrc fi -echo "Done!" \ No newline at end of file +# Clean up +rm -rf /var/lib/apt/lists/* + +echo "Done!" diff --git a/src/aws-cli/devcontainer-feature.json b/src/aws-cli/devcontainer-feature.json index 11b0bda..5302cf1 100644 --- a/src/aws-cli/devcontainer-feature.json +++ b/src/aws-cli/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "aws-cli", - "version": "1.0.3", + "version": "1.0.4", "name": "AWS CLI", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/aws-cli", "description": "Installs the AWS CLI along with needed dependencies. Useful for base Dockerfiles that often are missing required install dependencies like gpg.", diff --git a/src/aws-cli/install.sh b/src/aws-cli/install.sh index 4ab2234..a8b414e 100755 --- a/src/aws-cli/install.sh +++ b/src/aws-cli/install.sh @@ -9,6 +9,9 @@ set -e +# Clean up +rm -rf /var/lib/apt/lists/* + VERSION=${VERSION:-"latest"} AWSCLI_GPG_KEY=FB5DB77FD5C118B80511ADA8A6310ACC4672475C @@ -71,7 +74,10 @@ apt_get_update() # Checks if packages are installed and installs them if not check_packages() { if ! dpkg -s "$@" > /dev/null 2>&1; then - apt_get_update + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi apt-get -y install --no-install-recommends "$@" fi } @@ -133,4 +139,7 @@ echo "(*) Installing AWS CLI..." install +# Clean up +rm -rf /var/lib/apt/lists/* + echo "Done!" diff --git a/src/azure-cli/devcontainer-feature.json b/src/azure-cli/devcontainer-feature.json index b3e6288..85fa055 100644 --- a/src/azure-cli/devcontainer-feature.json +++ b/src/azure-cli/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "azure-cli", - "version": "1.0.3", + "version": "1.0.4", "name": "Azure CLI", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/azure-cli", "description": "Installs the Azure CLI along with needed dependencies. Useful for base Dockerfiles that often are missing required install dependencies like gpg.", diff --git a/src/azure-cli/install.sh b/src/azure-cli/install.sh index 6518f6c..de5d65d 100755 --- a/src/azure-cli/install.sh +++ b/src/azure-cli/install.sh @@ -9,6 +9,9 @@ set -e +# Clean up +rm -rf /var/lib/apt/lists/* + AZ_VERSION=${VERSION:-"latest"} MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc" @@ -44,7 +47,10 @@ apt_get_update() # Checks if packages are installed and installs them if not check_packages() { if ! dpkg -s "$@" > /dev/null 2>&1; then - apt_get_update + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi apt-get -y install --no-install-recommends "$@" fi } @@ -179,4 +185,7 @@ if [ "${use_pip}" = "true" ]; then fi fi -echo "Done!" \ No newline at end of file +# Clean up +rm -rf /var/lib/apt/lists/* + +echo "Done!" diff --git a/src/common-utils/devcontainer-feature.json b/src/common-utils/devcontainer-feature.json index e916135..c5f8621 100644 --- a/src/common-utils/devcontainer-feature.json +++ b/src/common-utils/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "common-utils", - "version": "1.1.2", + "version": "1.1.3", "name": "Common Debian Utilities", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/common-utils", "description": "Installs a set of common command line utilities, Oh My Zsh!, and sets up a non-root user.", diff --git a/src/common-utils/install.sh b/src/common-utils/install.sh index 1170200..2d51a0b 100755 --- a/src/common-utils/install.sh +++ b/src/common-utils/install.sh @@ -9,6 +9,9 @@ set -e +# Clean up +rm -rf /var/lib/apt/lists/* + INSTALL_ZSH=${INSTALLZSH:-"true"} INSTALL_OH_MY_ZSH=${INSTALLOHMYZSH:-"true"} UPGRADE_PACKAGES=${UPGRADEPACKAGES:-"true"} @@ -60,8 +63,10 @@ export DEBIAN_FRONTEND=noninteractive apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Run install apt-utils to avoid debconf warning then verify presence of other common developer tools and dependencies @@ -447,4 +452,7 @@ echo -e "\ RC_SNIPPET_ALREADY_ADDED=${RC_SNIPPET_ALREADY_ADDED}\n\ ZSH_ALREADY_INSTALLED=${ZSH_ALREADY_INSTALLED}" > "${MARKER_FILE}" +# Clean up +rm -rf /var/lib/apt/lists/* + echo "Done!" diff --git a/src/conda/devcontainer-feature.json b/src/conda/devcontainer-feature.json index 1aa69a2..2c9c769 100644 --- a/src/conda/devcontainer-feature.json +++ b/src/conda/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "conda", - "version": "1.0.3", + "version": "1.0.4", "name": "Conda", "description": "A cross-platform, language-agnostic binary package manager", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/conda", diff --git a/src/conda/install.sh b/src/conda/install.sh index 89d2fcb..9b51bbd 100644 --- a/src/conda/install.sh +++ b/src/conda/install.sh @@ -14,6 +14,9 @@ CONDA_DIR="/opt/conda" set -eux export DEBIAN_FRONTEND=noninteractive +# Clean up +rm -rf /var/lib/apt/lists/* + if [ "$(id -u)" -ne 0 ]; then echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 @@ -50,12 +53,11 @@ fi # Checks if packages are installed and installs them if not check_packages() { if ! dpkg -s "$@" > /dev/null 2>&1; then - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi apt-get -y install --no-install-recommends "$@" - - # Clean up - apt-get clean -y - rm -rf /var/lib/apt/lists/* fi } @@ -73,6 +75,7 @@ if ! conda --version &> /dev/null ; then curl -sS https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor > /usr/share/keyrings/conda-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/conda-archive-keyring.gpg] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" > /etc/apt/sources.list.d/conda.list + apt-get update -y CONDA_PKG="conda=${VERSION}-0" if [ "${VERSION}" = "latest" ]; then @@ -123,4 +126,7 @@ if [ -f "/etc/bash.bashrc" ]; then echo "${notice_script}" | tee -a /etc/bash.bashrc fi +# Clean up +rm -rf /var/lib/apt/lists/* + echo "Done!" diff --git a/src/desktop-lite/devcontainer-feature.json b/src/desktop-lite/devcontainer-feature.json index a6382a0..7b2a5c2 100644 --- a/src/desktop-lite/devcontainer-feature.json +++ b/src/desktop-lite/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "desktop-lite", - "version": "1.0.3", + "version": "1.0.4", "name": "Light-weight Desktop", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/desktop-lite", "description": "Adds a lightweight Fluxbox based desktop to the container that can be accessed using a VNC viewer or the web. GUI-based commands executed from the built-in VS code terminal will open on the desktop automatically.", diff --git a/src/desktop-lite/install.sh b/src/desktop-lite/install.sh index b05896c..dc8ee39 100755 --- a/src/desktop-lite/install.sh +++ b/src/desktop-lite/install.sh @@ -63,6 +63,9 @@ package_list_additional=" set -e +# Clean up +rm -rf /var/lib/apt/lists/* + if [ "$(id -u)" -ne 0 ]; then echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 @@ -151,8 +154,10 @@ copy_fluxbox_config() { apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Checks if packages are installed and installs them if not @@ -176,7 +181,7 @@ apt_get_update if [[ -z $(apt-cache --names-only search ^tilix$) ]]; then . /etc/os-release if [ "${ID}" = "ubuntu" ]; then - apt-get install -y --no-install-recommends apt-transport-https software-properties-common + check_packages apt-transport-https software-properties-common add-apt-repository -y ppa:webupd8team/terminix elif [ "${VERSION_CODENAME}" = "stretch" ]; then echo "deb http://deb.debian.org/debian stretch-backports main" > /etc/apt/sources.list.d/stretch-backports.list @@ -232,9 +237,7 @@ if [ "${INSTALL_NOVNC}" = "true" ] && [ ! -d "/usr/local/novnc" ]; then rm -f /tmp/websockify-install.zip /tmp/novnc-install.zip # Install noVNC dependencies and use them. - if ! dpkg -s python3-minimal python3-numpy > /dev/null 2>&1; then - apt-get -y install --no-install-recommends python3-minimal python3-numpy - fi + check_packages python3-minimal python3-numpy sed -i -E 's/^python /python3 /' /usr/local/novnc/websockify-${WEBSOCKETIFY_VERSION}/run fi @@ -387,6 +390,9 @@ if [ "${USERNAME}" != "root" ]; then chown -R ${USERNAME} /home/${USERNAME}/.Xmodmap /home/${USERNAME}/.fluxbox fi +# Clean up +rm -rf /var/lib/apt/lists/* + cat << EOF diff --git a/src/docker-from-docker/devcontainer-feature.json b/src/docker-from-docker/devcontainer-feature.json index 119ef3a..866f176 100644 --- a/src/docker-from-docker/devcontainer-feature.json +++ b/src/docker-from-docker/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "docker-from-docker", - "version": "1.0.4", + "version": "1.0.5", "name": "Docker (Docker-from-Docker)", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/docker-from-docker", "descripton": "Re-use the host docker socket, adding the Docker CLI to a container. Feature invokes a script to enable using a forwarded Docker socket within a container to run Docker commands.", diff --git a/src/docker-from-docker/install.sh b/src/docker-from-docker/install.sh index 312e283..d128ab9 100755 --- a/src/docker-from-docker/install.sh +++ b/src/docker-from-docker/install.sh @@ -22,6 +22,9 @@ DOCKER_LICENSED_ARCHIVE_VERSION_CODENAMES="buster bullseye bionic focal hirsute set -e +# Clean up +rm -rf /var/lib/apt/lists/* + if [ "$(id -u)" -ne 0 ]; then echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 @@ -61,8 +64,10 @@ get_common_setting() { apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Checks if packages are installed and installs them if not @@ -113,8 +118,7 @@ export DEBIAN_FRONTEND=noninteractive # Install dependencies check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr if ! type git > /dev/null 2>&1; then - apt_get_update - apt-get -y install git + check_packages git fi # Source /etc/os-release to get OS info @@ -206,10 +210,7 @@ else fi if [ "${TARGET_COMPOSE_ARCH}" != "x86_64" ]; then # Use pip to get a version that runns on this architecture - if ! dpkg -s python3-minimal python3-pip libffi-dev python3-venv > /dev/null 2>&1; then - apt_get_update - apt-get -y install python3-minimal python3-pip libffi-dev python3-venv - fi + check_packages python3-minimal python3-pip libffi-dev python3-venv export PIPX_HOME=/usr/local/pipx mkdir -p ${PIPX_HOME} export PIPX_BIN_DIR=/usr/local/bin @@ -255,6 +256,8 @@ fi # If init file already exists, exit if [ -f "/usr/local/share/docker-init.sh" ]; then + # Clean up + rm -rf /var/lib/apt/lists/* exit 0 fi echo "docker-init doesnt exist, adding..." @@ -269,6 +272,8 @@ fi if [ "${ENABLE_NONROOT_DOCKER}" = "false" ] || [ "${USERNAME}" = "root" ]; then echo -e '#!/usr/bin/env bash\nexec "$@"' > /usr/local/share/docker-init.sh chmod +x /usr/local/share/docker-init.sh + # Clean up + rm -rf /var/lib/apt/lists/* exit 0 fi @@ -281,10 +286,7 @@ DOCKER_GID="$(grep -oP '^docker:x:\K[^:]+' /etc/group)" # If enabling non-root access and specified user is found, setup socat and add script chown -h "${USERNAME}":root "${TARGET_SOCKET}" -if ! dpkg -s socat > /dev/null 2>&1; then - apt_get_update - apt-get -y install socat -fi +check_packages socat tee /usr/local/share/docker-init.sh > /dev/null \ << EOF #!/usr/bin/env bash @@ -346,4 +348,8 @@ exec "\$@" EOF chmod +x /usr/local/share/docker-init.sh chown ${USERNAME}:root /usr/local/share/docker-init.sh + +# Clean up +rm -rf /var/lib/apt/lists/* + echo "Done!" diff --git a/src/docker-in-docker/devcontainer-feature.json b/src/docker-in-docker/devcontainer-feature.json index 8538b46..5ed236c 100644 --- a/src/docker-in-docker/devcontainer-feature.json +++ b/src/docker-in-docker/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "docker-in-docker", - "version": "1.0.5", + "version": "1.0.6", "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.", diff --git a/src/docker-in-docker/install.sh b/src/docker-in-docker/install.sh index afcdc1a..edcc221 100755 --- a/src/docker-in-docker/install.sh +++ b/src/docker-in-docker/install.sh @@ -23,6 +23,9 @@ DOCKER_LICENSED_ARCHIVE_VERSION_CODENAMES="buster bullseye bionic focal hirsute # Default: Exit on any failure. set -e +# Clean up +rm -rf /var/lib/apt/lists/* + # Setup STDERR. err() { echo "(!) $*" >&2 @@ -72,8 +75,10 @@ get_common_setting() { apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Checks if packages are installed and installs them if not @@ -154,8 +159,7 @@ fi # Install dependencies check_packages apt-transport-https curl ca-certificates pigz iptables gnupg2 dirmngr if ! type git > /dev/null 2>&1; then - apt_get_update - apt-get -y install git + check_packages git fi # Swap to legacy iptables for compatibility @@ -249,10 +253,7 @@ else fi if [ "${target_compose_arch}" != "x86_64" ]; then # Use pip to get a version that runs on this architecture - if ! dpkg -s python3-minimal python3-pip libffi-dev python3-venv > /dev/null 2>&1; then - apt_get_update - apt-get -y install python3-minimal python3-pip libffi-dev python3-venv - fi + check_packages python3-minimal python3-pip libffi-dev python3-venv export PIPX_HOME=/usr/local/pipx mkdir -p ${PIPX_HOME} export PIPX_BIN_DIR=/usr/local/bin @@ -299,6 +300,8 @@ fi # If init file already exists, exit if [ -f "/usr/local/share/docker-init.sh" ]; then echo "/usr/local/share/docker-init.sh already exists, so exiting." + # Clean up + rm -rf /var/lib/apt/lists/* exit 0 fi echo "docker-init doesnt exist, adding..." @@ -398,4 +401,7 @@ EOF chmod +x /usr/local/share/docker-init.sh chown ${USERNAME}:root /usr/local/share/docker-init.sh +# Clean up +rm -rf /var/lib/apt/lists/* + echo 'docker-in-docker-debian script has completed!' diff --git a/src/dotnet/devcontainer-feature.json b/src/dotnet/devcontainer-feature.json index 5d9b0f3..2d261eb 100644 --- a/src/dotnet/devcontainer-feature.json +++ b/src/dotnet/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "dotnet", - "version": "1.0.6", + "version": "1.0.7", "name": "Dotnet CLI", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/dotnet", "description": "Installs the .NET CLI. Provides option of installing sdk or runtime, and option of versions to install. Uses latest version of .NET sdk as defaults to install.", diff --git a/src/dotnet/install.sh b/src/dotnet/install.sh index d9399ca..fe4f58d 100755 --- a/src/dotnet/install.sh +++ b/src/dotnet/install.sh @@ -30,6 +30,11 @@ DOTNET_VERSION_CODENAMES_REQUIRE_OLDER_LIBSSL_1="buster bullseye bionic focal hi # alongside DOTNET_VERSION, but not set as default. ADDITIONAL_VERSIONS=${ADDITIONALVERSIONS:-""} +set -e + +# Clean up +rm -rf /var/lib/apt/lists/* + # Setup STDERR. err() { echo "(!) $*" >&2 @@ -109,8 +114,10 @@ updaterc() { apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Check if packages are installed and installs them if not. @@ -463,4 +470,7 @@ if [ "${CHANGE_OWNERSHIP}" = "true" ]; then find "${TARGET_DOTNET_ROOT}" -type d -print0 | xargs -n 1 -0 chmod g+s fi +# Clean up +rm -rf /var/lib/apt/lists/* + echo "Done!" diff --git a/src/git-lfs/devcontainer-feature.json b/src/git-lfs/devcontainer-feature.json index 0f075ca..f67376e 100644 --- a/src/git-lfs/devcontainer-feature.json +++ b/src/git-lfs/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "git-lfs", - "version": "1.0.2", + "version": "1.0.3", "name": "Git Large File Support (LFS)", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/git-lfs", "description": "Installs Git Large File Support (Git LFS) along with needed dependencies. Useful for base Dockerfiles that often are missing required install dependencies like git and curl.", diff --git a/src/git-lfs/install.sh b/src/git-lfs/install.sh index d88a379..f24ed92 100755 --- a/src/git-lfs/install.sh +++ b/src/git-lfs/install.sh @@ -19,6 +19,9 @@ keyserver hkp://keyserver.pgp.com" set -e +# Clean up +rm -rf /var/lib/apt/lists/* + if [ "$(id -u)" -ne 0 ]; then echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 @@ -107,8 +110,10 @@ receive_gpg_keys() { apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Checks if packages are installed and installs them if not @@ -178,8 +183,7 @@ export DEBIAN_FRONTEND=noninteractive . /etc/os-release check_packages curl ca-certificates gnupg2 dirmngr apt-transport-https if ! type git > /dev/null 2>&1; then - apt_get_update - apt-get -y install --no-install-recommends git + check_packages git fi if [ "${ID}" = "debian" ]; then check_packages debian-archive-keyring @@ -199,4 +203,7 @@ if [ "${use_github}" = "true" ]; then install_using_github fi -echo "Done!" \ No newline at end of file +# Clean up +rm -rf /var/lib/apt/lists/* + +echo "Done!" diff --git a/src/git/devcontainer-feature.json b/src/git/devcontainer-feature.json index 6f0e717..c39ffbd 100644 --- a/src/git/devcontainer-feature.json +++ b/src/git/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "git", - "version": "1.0.3", + "version": "1.0.4", "name": "Git (from source)", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/git", "description": "Install an up-to-date version of Git, built from source as needed. Useful for when you want the latest and greatest features. Auto-detects latest stable version and installs needed dependencies.", diff --git a/src/git/install.sh b/src/git/install.sh index 507599e..153b4e1 100755 --- a/src/git/install.sh +++ b/src/git/install.sh @@ -17,6 +17,9 @@ keyserver hkp://keyserver.pgp.com" set -e +# Clean up +rm -rf /var/lib/apt/lists/* + if [ "$(id -u)" -ne 0 ]; then echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 @@ -76,8 +79,10 @@ receive_gpg_keys() { apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Checks if packages are installed and installs them if not @@ -96,12 +101,16 @@ export DEBIAN_FRONTEND=noninteractive # If the os provided version is "good enough", just install that. if [ ${GIT_VERSION} = "os-provided" ] || [ ${GIT_VERSION} = "system" ]; then if type git > /dev/null 2>&1; then - echo "Detected existing system install: $(git version)" - exit 0 + echo "Detected existing system install: $(git version)" + # Clean up + rm -rf /var/lib/apt/lists/* + exit 0 fi echo "Installing git from OS apt repository" check_packages git + # Clean up + rm -rf /var/lib/apt/lists/* exit 0 fi @@ -114,6 +123,7 @@ if ([ "${GIT_VERSION}" = "latest" ] || [ "${GIT_VERSION}" = "lts" ] || [ "${GIT_ apt-get update apt-get -y install --no-install-recommends git rm -rf "/tmp/tmp-gnupg" + rm -rf /var/lib/apt/lists/* exit 0 fi @@ -143,4 +153,5 @@ echo "Building..." cd /tmp/git-${GIT_VERSION} make -s prefix=/usr/local all && make -s prefix=/usr/local install 2>&1 rm -rf /tmp/git-${GIT_VERSION} +rm -rf /var/lib/apt/lists/* echo "Done!" diff --git a/src/github-cli/devcontainer-feature.json b/src/github-cli/devcontainer-feature.json index 597291d..3108a69 100644 --- a/src/github-cli/devcontainer-feature.json +++ b/src/github-cli/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "github-cli", - "version": "1.0.4", + "version": "1.0.5", "name": "GitHub CLI", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/github-cli", "description": "Installs the GitHub CLI. Auto-detects latest version and installs needed dependencies.", diff --git a/src/github-cli/install.sh b/src/github-cli/install.sh index 22ed040..5f59d01 100755 --- a/src/github-cli/install.sh +++ b/src/github-cli/install.sh @@ -17,6 +17,9 @@ keyserver hkp://keyserver.pgp.com" set -e +# Clean up +rm -rf /var/lib/apt/lists/* + if [ "$(id -u)" -ne 0 ]; then echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 @@ -141,8 +144,10 @@ receive_gpg_keys() { apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Checks if packages are installed and installs them if not @@ -209,8 +214,7 @@ export DEBIAN_FRONTEND=noninteractive # Install curl, apt-transport-https, curl, gpg, or dirmngr, git if missing check_packages curl ca-certificates apt-transport-https dirmngr gnupg2 if ! type git > /dev/null 2>&1; then - apt_get_update - apt-get -y install --no-install-recommends git + check_packages git fi # Soft version matching @@ -236,3 +240,6 @@ else rm -rf "/tmp/gh/gnupg" echo "Done!" fi + +# Clean up +rm -rf /var/lib/apt/lists/* diff --git a/src/go/devcontainer-feature.json b/src/go/devcontainer-feature.json index 3c532bb..76e5bf1 100644 --- a/src/go/devcontainer-feature.json +++ b/src/go/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "go", - "version": "1.0.7", + "version": "1.0.8", "name": "Go", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/go", "description": "Installs Go and common Go utilities. Auto-detects latest version and installs needed dependencies.", diff --git a/src/go/install.sh b/src/go/install.sh index 86bdbc6..9bb8047 100755 --- a/src/go/install.sh +++ b/src/go/install.sh @@ -19,6 +19,9 @@ GO_GPG_KEY_URI="https://dl.google.com/linux/linux_signing_key.pub" set -e +# Clean up +rm -rf /var/lib/apt/lists/* + if [ "$(id -u)" -ne 0 ]; then echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 @@ -97,8 +100,10 @@ get_common_setting() { apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Checks if packages are installed and installs them if not @@ -114,8 +119,7 @@ export DEBIAN_FRONTEND=noninteractive # Install curl, tar, git, other dependencies if missing check_packages curl ca-certificates gnupg2 tar g++ gcc libc6-dev make pkg-config if ! type git > /dev/null 2>&1; then - apt_get_update - apt-get -y install --no-install-recommends git + check_packages git fi # Get closest match for version number specified @@ -225,4 +229,7 @@ chmod -R g+r+w "${TARGET_GOROOT}" "${TARGET_GOPATH}" find "${TARGET_GOROOT}" -type d -print0 | xargs -n 1 -0 chmod g+s find "${TARGET_GOPATH}" -type d -print0 | xargs -n 1 -0 chmod g+s +# Clean up +rm -rf /var/lib/apt/lists/* + echo "Done!" diff --git a/src/hugo/devcontainer-feature.json b/src/hugo/devcontainer-feature.json index 2303397..b08a51c 100644 --- a/src/hugo/devcontainer-feature.json +++ b/src/hugo/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "hugo", - "version": "1.0.4", + "version": "1.0.5", "name": "Hugo", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/hugo", "options": { diff --git a/src/hugo/install.sh b/src/hugo/install.sh index 62c0724..778b552 100755 --- a/src/hugo/install.sh +++ b/src/hugo/install.sh @@ -16,6 +16,9 @@ HUGO_DIR=${HUGO_DIR:-"/usr/local/hugo"} set -e +# Clean up +rm -rf /var/lib/apt/lists/* + if [ "$(id -u)" -ne 0 ]; then echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 @@ -63,8 +66,10 @@ updaterc() { apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Checks if packages are installed and installs them if not @@ -114,4 +119,7 @@ if ! hugo version &> /dev/null ; then find "${HUGO_DIR}" -type d -print0 | xargs -n 1 -0 chmod g+s fi +# Clean up +rm -rf /var/lib/apt/lists/* + echo "Done!" diff --git a/src/java/devcontainer-feature.json b/src/java/devcontainer-feature.json index 3d8b8d8..7188929 100644 --- a/src/java/devcontainer-feature.json +++ b/src/java/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "java", - "version": "1.0.9", + "version": "1.0.10", "name": "Java (via SDKMAN!)", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/java", "description": "Installs Java, SDKMAN! (if not installed), and needed dependencies.", diff --git a/src/java/install.sh b/src/java/install.sh index 838f782..d2f735d 100755 --- a/src/java/install.sh +++ b/src/java/install.sh @@ -24,6 +24,9 @@ ADDITIONAL_VERSIONS=${ADDITIONALVERSIONS:-""} set -e +# Clean up +rm -rf /var/lib/apt/lists/* + if [ "$(id -u)" -ne 0 ]; then echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 @@ -65,8 +68,10 @@ updaterc() { apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Checks if packages are installed and installs them if not @@ -176,4 +181,7 @@ if [[ "${INSTALL_MAVEN}" = "true" ]] && ! mvn --version > /dev/null; then sdk_install maven latest fi +# Clean up +rm -rf /var/lib/apt/lists/* + echo "Done!" diff --git a/src/kubectl-helm-minikube/devcontainer-feature.json b/src/kubectl-helm-minikube/devcontainer-feature.json index 0aead19..19a665a 100644 --- a/src/kubectl-helm-minikube/devcontainer-feature.json +++ b/src/kubectl-helm-minikube/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "kubectl-helm-minikube", - "version": "1.0.3", + "version": "1.0.4", "name": "Kubectl, Helm, and Minkube", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/kubectl-helm-minikube", "description": "Installs latest version of kubectl, Helm, and optionally minikube. Auto-detects latest versions and installs needed dependencies.", diff --git a/src/kubectl-helm-minikube/install.sh b/src/kubectl-helm-minikube/install.sh index e9993a1..c961e56 100755 --- a/src/kubectl-helm-minikube/install.sh +++ b/src/kubectl-helm-minikube/install.sh @@ -9,6 +9,9 @@ set -e +# Clean up +rm -rf /var/lib/apt/lists/* + KUBECTL_VERSION="${VERSION:-"latest"}" HELM_VERSION="${HELM:-"latest"}" MINIKUBE_VERSION="${MINIKUBE:-"none"}" # latest is also valid @@ -102,8 +105,10 @@ find_version_from_git_tags() { apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Checks if packages are installed and installs them if not @@ -120,8 +125,7 @@ export DEBIAN_FRONTEND=noninteractive # Install dependencies check_packages curl ca-certificates coreutils gnupg2 dirmngr bash-completion if ! type git > /dev/null 2>&1; then - apt_get_update - apt-get -y install --no-install-recommends git + check_packages git fi architecture="$(uname -m)" @@ -240,4 +244,7 @@ if ! type docker > /dev/null 2>&1; then echo -e '\n(*) Warning: The docker command was not found.\n\nYou can use one of the following scripts to install it:\n\nhttps://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/docker-in-docker.md\n\nor\n\nhttps://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/docker.md' fi -echo -e "\nDone!" \ No newline at end of file +# Clean up +rm -rf /var/lib/apt/lists/* + +echo -e "\nDone!" diff --git a/src/node/devcontainer-feature.json b/src/node/devcontainer-feature.json index 8f92365..09097e5 100644 --- a/src/node/devcontainer-feature.json +++ b/src/node/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "node", - "version": "1.0.6", + "version": "1.0.7", "name": "Node.js (via nvm) and yarn", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/node", "description": "Installs Node.js, nvm, yarn, and needed dependencies.", diff --git a/src/node/install.sh b/src/node/install.sh index 6a237d6..2bdd21a 100755 --- a/src/node/install.sh +++ b/src/node/install.sh @@ -22,6 +22,9 @@ export NVM_VERSION="0.38.0" set -e +# Clean up +rm -rf /var/lib/apt/lists/* + if [ "$(id -u)" -ne 0 ]; then echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 @@ -62,8 +65,10 @@ updaterc() { } apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Checks if packages are installed and installs them if not @@ -109,6 +114,8 @@ if [ -d "${NVM_DIR}" ]; then if [ "${NODE_VERSION}" != "" ]; then su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache" fi + # Clean up + rm -rf /var/lib/apt/lists/* exit 0 fi @@ -187,4 +194,7 @@ fi find "${NVM_DIR}" -type d -print0 | xargs -n 1 -0 chmod g+s +# Clean up +rm -rf /var/lib/apt/lists/* + echo "Done!" diff --git a/src/nvidia-cuda/devcontainer-feature.json b/src/nvidia-cuda/devcontainer-feature.json index 7ede271..6fa9aae 100644 --- a/src/nvidia-cuda/devcontainer-feature.json +++ b/src/nvidia-cuda/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "nvidia-cuda", - "version": "1.0.2", + "version": "1.0.3", "name": "NVIDIA CUDA", "description": "Installs shared libraries for NVIDIA CUDA.", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/nvidia-cuda", diff --git a/src/nvidia-cuda/install.sh b/src/nvidia-cuda/install.sh index f017ecb..9b41713 100644 --- a/src/nvidia-cuda/install.sh +++ b/src/nvidia-cuda/install.sh @@ -2,6 +2,9 @@ set -e +# Clean up +rm -rf /var/lib/apt/lists/* + INSTALL_CUDNN=${INSTALLCUDNN} INSTALL_NVTX=${INSTALLNVTX} CUDA_VERSION=${CUDAVERSION} @@ -12,9 +15,23 @@ if [ "$(id -u)" -ne 0 ]; then exit 1 fi -# Install dependencies -apt-get update -yq -apt-get install -yq wget ca-certificates +apt_get_update() +{ + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi +} + +# Checks if packages are installed and installs them if not +check_packages() { + if ! dpkg -s "$@" > /dev/null 2>&1; then + apt_get_update + apt-get -y install --no-install-recommends "$@" + fi +} + +check_packages wget ca-certificates # Add NVIDIA's package repository to apt so that we can download packages # Always use the ubuntu2004 repo because the other repos (e.g., debian11) are missing packages @@ -55,4 +72,7 @@ if [ "$INSTALL_NVTX" = "true" ]; then apt-get install -yq "$nvtx_pkg" fi +# Clean up +rm -rf /var/lib/apt/lists/* + echo "Done!" diff --git a/src/oryx/devcontainer-feature.json b/src/oryx/devcontainer-feature.json index 2e40e88..2abf1f2 100644 --- a/src/oryx/devcontainer-feature.json +++ b/src/oryx/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "oryx", - "version": "1.0.6", + "version": "1.0.7", "name": "Oryx", "description": "Installs the oryx CLI", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/oryx", diff --git a/src/oryx/install.sh b/src/oryx/install.sh index 826d916..f84cf22 100755 --- a/src/oryx/install.sh +++ b/src/oryx/install.sh @@ -12,6 +12,9 @@ MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc" set -eu +# Clean up +rm -rf /var/lib/apt/lists/* + if [ "$(id -u)" -ne 0 ]; then echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 @@ -53,19 +56,17 @@ function updaterc() { apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Checks if packages are installed and installs them if not check_packages() { if ! dpkg -s "$@" > /dev/null 2>&1; then apt_get_update - DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends "$@" - - # Clean up - apt-get clean -y - rm -rf /var/lib/apt/lists/* + apt-get -y install --no-install-recommends "$@" fi } @@ -105,6 +106,8 @@ fi # If we don't already have Oryx installed, install it now. if oryx --version > /dev/null ; then echo "oryx is already installed. Skipping installation." + # Clean up + rm -rf /var/lib/apt/lists/* exit 0 fi @@ -182,4 +185,7 @@ if [[ "${DOTNET_INSTALLATION_PACKAGE}" != "" ]]; then apt purge -yq $DOTNET_INSTALLATION_PACKAGE fi +# Clean up +rm -rf /var/lib/apt/lists/* + echo "Done!" diff --git a/src/php/devcontainer-feature.json b/src/php/devcontainer-feature.json index 418162f..294c687 100644 --- a/src/php/devcontainer-feature.json +++ b/src/php/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "php", - "version": "1.0.6", + "version": "1.0.7", "name": "PHP", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/php", "options": { diff --git a/src/php/install.sh b/src/php/install.sh index fdc374a..70b63da 100755 --- a/src/php/install.sh +++ b/src/php/install.sh @@ -8,6 +8,9 @@ set -eux +# Clean up +rm -rf /var/lib/apt/lists/* + VERSION=${VERSION:-"latest"} INSTALL_COMPOSER=${INSTALLCOMPOSER:-"true"} OVERRIDE_DEFAULT_VERSION=${OVERRIDEDEFAULTVERSION:-"true"} @@ -73,7 +76,10 @@ updaterc() { # Checks if packages are installed and installs them if not check_packages() { if ! dpkg -s "$@" > /dev/null 2>&1; then - apt-get update + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi apt-get -y install --no-install-recommends "$@" fi } @@ -222,4 +228,7 @@ chown -R "${USERNAME}:php" "${PHP_DIR}" chmod -R g+r+w "${PHP_DIR}" find "${PHP_DIR}" -type d -print0 | xargs -n 1 -0 chmod g+s +# Clean up +rm -rf /var/lib/apt/lists/* + echo "Done!" diff --git a/src/powershell/devcontainer-feature.json b/src/powershell/devcontainer-feature.json index 150cf26..41475c6 100644 --- a/src/powershell/devcontainer-feature.json +++ b/src/powershell/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "powershell", - "version": "1.0.2", + "version": "1.0.3", "name": "PowerShell", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/powershell", "description": "Installs PowerShell along with needed dependencies. Useful for base Dockerfiles that often are missing required install dependencies like gpg.", diff --git a/src/powershell/install.sh b/src/powershell/install.sh index 328ae93..ea3b6e8 100755 --- a/src/powershell/install.sh +++ b/src/powershell/install.sh @@ -9,6 +9,9 @@ set -e +# Clean up +rm -rf /var/lib/apt/lists/* + POWERSHELL_VERSION=${VERSION:-"latest"} MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc" @@ -74,8 +77,10 @@ get_common_setting() { apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Checks if packages are installed and installs them if not @@ -118,8 +123,7 @@ install_using_github() { # Fall back on direct download if no apt package exists in microsoft pool check_packages curl ca-certificates gnupg2 dirmngr libc6 libgcc1 libgssapi-krb5-2 libstdc++6 libunwind8 libuuid1 zlib1g libicu[0-9][0-9] if ! type git > /dev/null 2>&1; then - apt_get_update - apt-get install -y --no-install-recommends git + check_packages git fi if [ "${architecture}" = "amd64" ]; then architecture="x64" @@ -161,4 +165,7 @@ if [ "${use_github}" = "true" ]; then install_using_github fi -echo "Done!" \ No newline at end of file +# Clean up +rm -rf /var/lib/apt/lists/* + +echo "Done!" diff --git a/src/python/devcontainer-feature.json b/src/python/devcontainer-feature.json index 0c90e0b..de65a8c 100644 --- a/src/python/devcontainer-feature.json +++ b/src/python/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "python", - "version": "1.0.8", + "version": "1.0.9", "name": "Python", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/python", "description": "Installs the provided version of Python, as well as PIPX, and other common Python utilities. JupyterLab is conditionally installed with the python feature. Note: May require source code compilation.", diff --git a/src/python/install.sh b/src/python/install.sh index 3cf3a88..ac5eec6 100755 --- a/src/python/install.sh +++ b/src/python/install.sh @@ -34,6 +34,9 @@ keyserver hkp://keyserver.pgp.com" set -e +# Clean up +rm -rf /var/lib/apt/lists/* + if [ "$(id -u)" -ne 0 ]; then echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 @@ -199,8 +202,10 @@ oryx_install() { apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Checks if packages are installed and installs them if not @@ -232,8 +237,7 @@ install_from_source() { libbz2-dev libreadline-dev libxml2-dev xz-utils libgdbm-dev tk-dev dirmngr \ libxmlsec1-dev libsqlite3-dev libffi-dev liblzma-dev uuid-dev if ! type git > /dev/null 2>&1; then - apt_get_update - apt-get -y install --no-install-recommends git + check_packages git fi # Find version using soft match @@ -454,4 +458,7 @@ if [ "${INSTALL_JUPYTERLAB}" = "true" ]; then fi fi +# Clean up +rm -rf /var/lib/apt/lists/* + echo "Done!" diff --git a/src/ruby/devcontainer-feature.json b/src/ruby/devcontainer-feature.json index 9e617d0..e2d909f 100644 --- a/src/ruby/devcontainer-feature.json +++ b/src/ruby/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "ruby", - "version": "1.0.4", + "version": "1.0.5", "name": "Ruby (via rvm)", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/ruby", "description": "Installs Ruby, rvm, rbenv, common Ruby utilities, and needed dependencies.", @@ -31,4 +31,4 @@ "MY_RUBY_HOME": "/usr/local/rvm/rubies/default", "PATH": "/usr/local/rvm/gems/default/bin:/usr/local/rvm/gems/default@global/bin:/usr/local/rvm/rubies/default/bin:/usr/local/share/rbenv/bin:${PATH}" } -} \ No newline at end of file +} diff --git a/src/ruby/install.sh b/src/ruby/install.sh index 6ff3b2f..2228522 100755 --- a/src/ruby/install.sh +++ b/src/ruby/install.sh @@ -28,6 +28,9 @@ keyserver hkp://keyserver.pgp.com" set -e +# Clean up +rm -rf /var/lib/apt/lists/* + if [ "$(id -u)" -ne 0 ]; then echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 @@ -154,8 +157,10 @@ find_version_from_git_tags() { apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Checks if packages are installed and installs them if not @@ -180,8 +185,7 @@ check_packages curl ca-certificates software-properties-common build-essential g procps dirmngr gawk autoconf automake bison libffi-dev libgdbm-dev libncurses5-dev \ libsqlite3-dev libtool libyaml-dev pkg-config sqlite3 zlib1g-dev libgmp-dev libssl-dev if ! type git > /dev/null 2>&1; then - apt_get_update - apt-get -y install --no-install-recommends git + check_packages git fi @@ -301,4 +305,7 @@ find "/usr/local/rvm/" -type d | xargs -n 1 chmod g+s rvm cleanup all ${ROOT_GEM} cleanup +# Clean up +rm -rf /var/lib/apt/lists/* + echo "Done!" diff --git a/src/rust/devcontainer-feature.json b/src/rust/devcontainer-feature.json index e843f22..5fb1049 100644 --- a/src/rust/devcontainer-feature.json +++ b/src/rust/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "rust", - "version": "1.0.6", + "version": "1.0.7", "name": "Rust", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/rust", "description": "Installs Rust, common Rust utilities, and their required dependencies", diff --git a/src/rust/install.sh b/src/rust/install.sh index d8d3b74..e7cfb71 100755 --- a/src/rust/install.sh +++ b/src/rust/install.sh @@ -18,6 +18,9 @@ UPDATE_RUST=${UPDATE_RUST:-"false"} set -e +# Clean up +rm -rf /var/lib/apt/lists/* + if [ "$(id -u)" -ne 0 ]; then echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 @@ -127,8 +130,18 @@ updaterc() { apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi +} + +# Checks if packages are installed and installs them if not +check_packages() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + apt_get_update + apt-get -y install --no-install-recommends "$@" + fi } export DEBIAN_FRONTEND=noninteractive @@ -170,8 +183,7 @@ else if [ "${RUST_VERSION}" != "latest" ] && [ "${RUST_VERSION}" != "lts" ] && [ "${RUST_VERSION}" != "stable" ]; then # Find version using soft match if ! type git > /dev/null 2>&1; then - apt_get_update - apt-get -y install --no-install-recommends git + check_packages git fi is_nightly=0 @@ -215,5 +227,8 @@ EOF # Make files writable for rustlang group chmod -R g+r+w "${RUSTUP_HOME}" "${CARGO_HOME}" +# Clean up +rm -rf /var/lib/apt/lists/* + echo "Done!" diff --git a/src/sshd/devcontainer-feature.json b/src/sshd/devcontainer-feature.json index 518c35b..24c4ba6 100644 --- a/src/sshd/devcontainer-feature.json +++ b/src/sshd/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "sshd", - "version": "1.0.3", + "version": "1.0.4", "name": "SSH server", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/sshd", "description": "Adds a SSH server into a container so that you can use an external terminal, sftp, or SSHFS to interact with it.", diff --git a/src/sshd/install.sh b/src/sshd/install.sh index 25b8859..a93b927 100755 --- a/src/sshd/install.sh +++ b/src/sshd/install.sh @@ -17,6 +17,9 @@ FIX_ENVIRONMENT=${FIX_ENVIRONMENT:-"true"} set -e +# Clean up +rm -rf /var/lib/apt/lists/* + if [ "$(id -u)" -ne 0 ]; then echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 @@ -41,8 +44,10 @@ fi apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Checks if packages are installed and installs them if not @@ -166,4 +171,8 @@ echo -e "Done!\n\n- Port: ${SSHD_PORT}\n- User: ${USERNAME}" if [ "${EMIT_PASSWORD}" = "true" ]; then echo "- Password: ${NEW_PASSWORD}" fi -echo -e "\nForward port ${SSHD_PORT} to your local machine and run:\n\n ssh -p ${SSHD_PORT} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o GlobalKnownHostsFile=/dev/null ${USERNAME}@localhost\n" \ No newline at end of file + +# Clean up +rm -rf /var/lib/apt/lists/* + +echo -e "\nForward port ${SSHD_PORT} to your local machine and run:\n\n ssh -p ${SSHD_PORT} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o GlobalKnownHostsFile=/dev/null ${USERNAME}@localhost\n" diff --git a/src/terraform/devcontainer-feature.json b/src/terraform/devcontainer-feature.json index 4ace245..cafa3db 100644 --- a/src/terraform/devcontainer-feature.json +++ b/src/terraform/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "terraform", - "version": "1.0.5", + "version": "1.0.6", "name": "Terraform, tflint, and TFGrunt", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/terraform", "description": "Installs the Terraform CLI and optionally TFLint and Terragrunt. Auto-detects latest version and installs needed dependencies.", diff --git a/src/terraform/install.sh b/src/terraform/install.sh index 358b8b2..fc523b8 100755 --- a/src/terraform/install.sh +++ b/src/terraform/install.sh @@ -9,6 +9,9 @@ set -e +# Clean up +rm -rf /var/lib/apt/lists/* + TERRAFORM_VERSION="${VERSION:-"latest"}" TFLINT_VERSION="${TFLINT:-"latest"}" TERRAGRUNT_VERSION="${TERRAGRUNT:-"latest"}" @@ -124,8 +127,10 @@ find_version_from_git_tags() { apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Checks if packages are installed and installs them if not @@ -142,8 +147,7 @@ export DEBIAN_FRONTEND=noninteractive # Install dependencies if missing check_packages curl ca-certificates gnupg2 dirmngr coreutils unzip if ! type git > /dev/null 2>&1; then - apt_get_update - apt-get -y install --no-install-recommends git + check_packages git fi # Verify requested version is available, convert latest @@ -209,4 +213,8 @@ if [ "${TERRAGRUNT_VERSION}" != "none" ]; then fi rm -rf /tmp/tf-downloads ${GNUPGHOME} + +# Clean up +rm -rf /var/lib/apt/lists/* + echo "Done!"