a79c561e8d
- /home/.chezmoiscripts/_universal/run_onchange_before_11-install-docker.tmpl - /home/.chezmoiscripts/_universal/run_onchange_before_05-install-homebrew.tmpl - /home/.chezmoiscripts/_universal/run_onchange_before_10-remove-bloatware.tmpl - /home/.chezmoiscripts/_universal/run_onchange_before_08-install-zx.tmpl - /home/.chezmoiscripts/_universal/run_onchange_before_09-ensure-node-version.tmpl - /home/.chezmoiscripts/universal/run_before_01-decrypt-age-key.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_11-install-docker.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_05-install-homebrew.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_10-remove-bloatware.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_08-install-zx.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_09-ensure-node-version.tmpl - /home/.chezmoiscripts/centos/run_onchange_before_10-install-centos-dependencies.tmpl - /home/.chezmoiscripts/centos/run_onchange_before_05-upgrade.tmpl - /home/.chezmoiscripts/fedora/run_onchange_before_10-install-fedora-dependencies.tmpl - /home/.chezmoitemplates/universal/common-dependencies - /home/.chezmoitemplates/universal/profile-inline - /home/.chezmoitemplates/ubuntu/common-dependencies - /home/.chezmoitemplates/opensuse/common-dependencies - /home/.chezmoitemplates/freebsd/common-dependencies - /home/.chezmoitemplates/fedora/common-dependencies - /home/.chezmoitemplates/debian/common-dependencies - /home/.chezmoitemplates/archlinux/common-dependencies
117 lines
4.5 KiB
Cheetah
117 lines
4.5 KiB
Cheetah
{{- if ne .host.distro.family "windows" -}}
|
|
#!/usr/bin/env bash
|
|
|
|
{{ includeTemplate "universal/profile-before" }}
|
|
{{ includeTemplate "universal/logg-before" }}
|
|
|
|
### Install Docker
|
|
if [ -d /Applications ] && [ -d /System ]; then
|
|
# macOS
|
|
if [ ! -d /Applications/Docker.app ]; then
|
|
logg info 'Installing Docker on macOS via Homebrew cask'
|
|
brew install --cask docker
|
|
else
|
|
logg info 'Docker appears to be installed already'
|
|
fi
|
|
logg info 'Opening the Docker for Desktop app so that the Docker engine starts running'
|
|
open --background -a Docker
|
|
elif command -v apt-get > /dev/null; then
|
|
. /etc/os-release
|
|
if [ "$ID" == 'ubuntu' ]; then
|
|
logg info 'Installing Docker on Ubuntu'
|
|
else
|
|
logg info 'Installing Docker on Debian'
|
|
fi
|
|
sudo apt-get update
|
|
sudo apt-get install -y ca-certificates curl gnupg lsb-release
|
|
sudo mkdir -p /etc/apt/keyrings
|
|
curl -fsSL "https://download.docker.com/linux/$ID/gpg" | sudo gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg
|
|
sudo chmod a+r /etc/apt/keyrings/docker.gpg
|
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/$ID $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
sudo apt-get update
|
|
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
|
elif command -v dnf > /dev/null; then
|
|
. /etc/os-release
|
|
if [ "$ID" == 'centos' ]; then
|
|
logg info 'Installing Docker on CentOS'
|
|
elif [ "$ID" == 'fedora' ]; then
|
|
logg info 'Installing Docker on Fedora'
|
|
else
|
|
logg error 'Unknown OS - cannot install Docker' && exit 1
|
|
fi
|
|
sudo dnf -y install dnf-plugins-core
|
|
sudo dnf config-manager --add-repo "https://download.docker.com/linux/$ID/docker-ce.repo"
|
|
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
|
elif command -v yum > /dev/null; then
|
|
# CentOS
|
|
logg info 'Installing Docker on CentOS'
|
|
sudo yum install -y yum-utils
|
|
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
|
|
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
|
elif command -v apk > /dev/null; then
|
|
# Alpine
|
|
logg info 'Installing Docker on Alpine'
|
|
sudo apk add --update docker
|
|
elif command -v pacman > /dev/null; then
|
|
# Archlinux
|
|
logg info 'Installing Docker on Archlinux'
|
|
sudo pacman -Syu
|
|
sudo pacman -S docker
|
|
elif command -v zypper > /dev/null; then
|
|
# OpenSUSE
|
|
logg info 'Installing Docker on OpenSUSE'
|
|
sudo zypper addrepo https://download.docker.com/linux/sles/docker-ce.repo
|
|
sudo zypper install docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
|
fi
|
|
|
|
### Add Docker group on Linux
|
|
if command -v groupadd > /dev/null; then
|
|
# Linux
|
|
if ! cat /etc/group | grep docker > /dev/null; then
|
|
logg info 'Creating Docker group'
|
|
sudo groupadd docker
|
|
fi
|
|
logg info 'Adding user to Docker group'
|
|
sudo usermod -aG docker "$USER"
|
|
fi
|
|
|
|
### Boot Docker on start with systemd on Linux machines
|
|
if command -v systemctl > /dev/null; then
|
|
# Systemd Linux
|
|
sudo systemctl start docker.service
|
|
sudo systemctl enable docker.service
|
|
sudo systemctl enable containerd.service
|
|
fi
|
|
|
|
### Add gVisor
|
|
if [ ! -d /Applications ] || [ ! -d /System ]; then
|
|
# Linux
|
|
if ! command -v runsc > /dev/null; then
|
|
# Install gVisor
|
|
logg info 'Building gVisor from source'
|
|
if [ -d /usr/local/src/gvisor ]; then
|
|
logg info 'Removing stale directory /usr/local/src/gvisor'
|
|
sudo rm -rf /usr/local/src/gvisor
|
|
fi
|
|
sudo git clone https://github.com/google/gvisor.git /usr/local/src/gvisor
|
|
cd /usr/local/src/gvisor
|
|
sudo mkdir -p bin
|
|
sudo make copy TARGETS=runsc DESTINATION=bin/
|
|
sudo cp ./bin/runsc /usr/local/bin
|
|
fi
|
|
|
|
if [ ! -f /etc/docker/daemon.json ]; then
|
|
# Configure Docker to use gVisor
|
|
# Create /etc/docker/daemon.json
|
|
logg info 'Creating /etc/docker'
|
|
sudo mkdir -p /etc/docker
|
|
if [ -f /usr/local/src/install.doctor/home/dot_config/docker/daemon.json ]; then
|
|
logg info 'Creating /etc/docker/daemon.json'
|
|
sudo cp "/usr/local/src/install.doctor/home/dot_config/docker/daemon.json" /etc/docker/daemon.json
|
|
else
|
|
logg warn '/usr/local/src/install.doctor/home/dot_config/docker/daemon.json is not available so the /etc/docker/daemon.json file cannot be populated'
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
{{ end -}}
|