Skip to content

Commit

Permalink
feature: check if brew exists, if not fallback to docker desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
NonsoAmadi10 committed Mar 30, 2023
1 parent 4b8ec00 commit 5ef38fb
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
set -u
set -o pipefail

BLUE='\033[40;38;5;82m'
GREEN='\033[40;38;5;82m'

function remove_images() {
repo=vulpemventures
Expand Down Expand Up @@ -52,17 +52,38 @@ function docker_install_linux(){
stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
echo " ${BLUE} docker has been installed!"
echo " ${GREEN} docker has been installed!"
}

function docker_install_mac(){

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# Check if Homebrew is installed
if command -v brew >/dev/null 2>&1; then
echo "Homebrew found, installing Docker using Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

brew cask install docker
brew cask install docker
echo "${GREEN} docker has been installed!"
else
echo "Homebrew not found, downloading Docker Desktop..."

# # Homebrew is not installed, check for Apple Silicon or Intel processor

if [[ "$(uname -m)" == "arm64" ]]; then
curl -o Docker.dmg https://desktop.docker.com/mac/main/arm64/Docker.dmg
else
curl -o Docker.dmg https://desktop.docker.com/mac/main/amd64/Docker.dmg
fi

# Mount the docker dmg file
hdiutil mount Docker.dmg
cp -r /Volumes/Docker/Docker.app /Applications/
hdiutil unmount /Volumes/Docker
rm Docker.dmg
fi

if [ -x "$(command -v docker)" ]; then
echo "${BLUE} docker has been installed!"
echo "${GREEN} docker has been installed!"
fi
}

Expand Down Expand Up @@ -157,6 +178,8 @@ if [ "$(command -v docker)" == "" ]; then
echo "Installing docker engine..."
docker_install_linux
fi
else
echo -e "${GREEN} docker has been installed!"
fi

echo ""
Expand Down

0 comments on commit 5ef38fb

Please sign in to comment.