Skip to content

Instantly share code, notes, and snippets.

@coffeegoddd
Last active February 14, 2023 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coffeegoddd/f6cacad2a6da423ca27cd0bebc67fd80 to your computer and use it in GitHub Desktop.
Save coffeegoddd/f6cacad2a6da423ca27cd0bebc67fd80 to your computer and use it in GitHub Desktop.
Easily install DoltLab dependencies on Ubuntu 18.04/20.04
#!/bin/bash
set -e
set -o pipefail
with_sudo=""
version=""
if [ "$#" -eq 2 ]; then
if [ "$1" == "with-sudo" ]; then
with_sudo="sudo"
version="$2"
else
echo "unrecognized argument $1"
echo ""
echo ""
echo "Usage: ./ubuntu-bootstrap.sh <DoltLab version>"
echo "Or: ./ubuntu-bootstrap.sh with-sudo <DoltLab version>"
echo "to prefix appropriate commands with 'sudo'"
echo ""
echo ""
exit 1
fi
else
version="$1"
fi
export DEBIAN_FRONTEND=noninteractive
# create docker group if it doesnt exist
group=docker
eval "$with_sudo getent group $group" || eval "$with_sudo groupadd $group"
# do this here to avoid 'newgrp' command
# which doesnt work well in scripts
if [ $(id -gn) != $group ]; then
exec "$with_sudo" sg $group "$0 $*"
fi
echo "Preparing to download DoltLab $version"
# install tools make and unzip
eval "$with_sudo apt update -y"
eval "$with_sudo apt install -y make unzip"
# install docker and docker-compose
eval "$with_sudo apt-get update -y"
eval "$with_sudo apt-get install -y ca-certificates curl gnupg lsb-release"
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | eval "$with_sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg"
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | eval "$with_sudo tee /etc/apt/sources.list.d/docker.list" > /dev/null
eval "$with_sudo apt-get update -y"
eval "$with_sudo apt-get install -y docker-ce docker-ce-cli containerd.io"
# sanity check
docker --version
eval "$with_sudo curl -L 'https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)' -o /usr/local/bin/docker-compose"
eval "$with_sudo chmod +x /usr/local/bin/docker-compose"
# sanity check
docker-compose --version
eval "$with_sudo usermod -aG docker $USER"
# sanity check
docker ps
# install creds-helper and create config
git clone https://github.com/awslabs/amazon-ecr-credential-helper.git
cd amazon-ecr-credential-helper && make docker
eval "$with_sudo mv ./bin/local/docker-credential-ecr-login /usr/local/bin/"
docker-credential-ecr-login -v
cd .. && mkdir -p ~/.docker
echo '{"credHelpers":{"public.ecr.aws":"ecr-login"}}' > ~/.docker/config.json
# download and unzip DoltLab
curl -LO https://doltlab-releases.s3.amazonaws.com/linux/amd64/doltlab-"$version".zip
unzip doltlab-"$version".zip -d doltlab
cd doltlab
echo "All dependencies installed successfully, ready to start DoltLab"
echo "Please run 'sudo newgrp docker' to use docker without 'sudo'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment