aboutsummaryrefslogtreecommitdiff
path: root/src/docker-from-docker/install.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/docker-from-docker/install.sh')
-rwxr-xr-xsrc/docker-from-docker/install.sh30
1 files changed, 18 insertions, 12 deletions
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!"