Skip to content

Instantly share code, notes, and snippets.

@0xbharath
Created August 28, 2023 08:57
Show Gist options
  • Save 0xbharath/6ff865d22140a3ce1148d72bc379f3a1 to your computer and use it in GitHub Desktop.
Save 0xbharath/6ff865d22140a3ce1148d72bc379f3a1 to your computer and use it in GitHub Desktop.
docker-setup-macos.sh
#!/bin/bash
# Regular Colors
Black='\033[0;30m' # Black
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
Yellow='\033[0;33m' # Yellow
Blue='\033[0;34m' # Blue
Purple='\033[0;35m' # Purple
Cyan='\033[0;36m' # Cyan
White='\033[0;37m' # White
NC='\033[0m' # No Color
# Bold
BBlack='\033[1;30m' # Black
BRed='\033[1;31m' # Red
BGreen='\033[1;32m' # Green
BYellow='\033[1;33m' # Yellow
BBlue='\033[1;34m' # Blue
BPurple='\033[1;35m' # Purple
BCyan='\033[1;36m' # Cyan
BWhite='\033[1;37m' # White
# High Intensity
IBlack='\033[0;90m' # Black
IRed='\033[0;91m' # Red
IGreen='\033[0;92m' # Green
IYellow='\033[0;93m' # Yellow
IBlue='\033[0;94m' # Blue
IPurple='\033[0;95m' # Purple
ICyan='\033[0;96m' # Cyan
IWhite='\033[0;97m' # White
# Bold High Intensity
BIBlack='\033[1;90m' # Black
BIRed='\033[1;91m' # Red
BIGreen='\033[1;92m' # Green
BIYellow='\033[1;93m' # Yellow
BIBlue='\033[1;94m' # Blue
BIPurple='\033[1;95m' # Purple
BICyan='\033[1;96m' # Cyan
BIWhite='\033[1;97m' # White
echo -e -n "
${BIYellow}
MANDATORY PREREQUISITES
Please ensure your system meets them before proceeding.
1. Docker >= v19.0.0
- Check with 'docker --version'
2. Docker compose >= v2.0.0
- Check with 'docker-compose version'
3. Docker configured to work without sudo
4. sudo access on the machine (Not mandatory)
5. Port 80 & 443 available on host machine (for appsmith dashboard)
- If these ports can't be freed then modify the port mapping in docker-compose-mantis.yml
to any available ports
${NC}
"
echo -e -n "[?] ${BICyan}Does your system meet the above prerequisites? (y/n) ${NC}"
read is_installed_answer
if [ "$is_installed_answer" != "${is_installed_answer#[Yy]}" ] ;then
echo -e "[+] ${Green}Proceeding with mantis installation on docker${NC}"
else
echo -e "[+] ${Green}Please ensure that the prerequisites are met${NC}"
exit -1
fi
echo -e -n "[?] ${BICyan}Have you tried setting up Mantis using this script previously?
Selecting yes means, we will remove & recreate all the resources including MongoDB (y/n)?
${Red}(It is recommended to backup MongoDB before proceeding) ${NC}"
read remove_answer
if [ "$remove_answer" != "${remove_answer#[Yy]}" ] ;then
echo -e "[-] ${Red}Removing the existing containers${NC}"
docker-compose -p mantis-tool -f docker-compose-appsmith.yml down
docker-compose -p mantis-appsmith -f docker-compose-mantis.yml down
fi
## Setup aliases
COMMAND_NAME="mantis-activate"
COMMAND_PATH="/usr/local/bin/mantis-activate"
COMMAND_CONTENT="docker exec -it mantis bash"
# Check if the command already exists
echo -e "[*] ${BPurple}Sudo is only required to provide a seamless user experience by adding aliases on host system ${NC}"
echo -e -n "[?] ${BICyan} Do you have sudo access on the machine? (y/n)? ${NC}"
read sudo_answer
if [ "$sudo_answer" != "${sudo_answer#[Yy]}" ] ;then
sudo rm -f /usr/local/bin/mantis-activate
echo "$COMMAND_CONTENT" | sudo tee "$COMMAND_PATH"
cat "$COMMAND_PATH"
sudo chmod +x "$COMMAND_PATH"
echo "Command '$COMMAND_NAME' added to system."
fi
docker-compose -p mantis-tool -f docker-compose-mantis.yml up --remove-orphans --build -d
#curl -L https://bit.ly/docker-compose-CE -s -o $PWD/docker-compose-appsmith.yml
docker-compose -p mantis-appsmith -f docker-compose-appsmith.yml up -d --build
# rm docker-compose-appsmith.yml
docker network connect mantis-network appsmith
echo -e "${BPurple}Mantis container is at: docker exec -it mantis bash${NC}"
sudo sed -i '/mantis/d' /etc/hosts
sudo -- sh -c -e "echo '10.10.0.3 mantis.db' >> /etc/hosts";
sudo -- sh -c -e "echo '10.10.0.4 mantis.dashboard' >> /etc/hosts";
docker exec -it mantis bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment