diff --git a/deploy/install.sh b/deploy/install.sh index 0843961fcc..31ec23eaca 100755 --- a/deploy/install.sh +++ b/deploy/install.sh @@ -5,6 +5,17 @@ is_command_present() { type "$1" >/dev/null 2>&1 } +# This function checks if the relevant ports required by appsmith are available or not +# The script should error out incase they aren't available +check_ports_occupied() { + ports_occupied=0 + if [[ "$OSTYPE" == "darwin"* ]]; then + ports_occupied=`sudo netstat -anp tcp | grep -e "*.80" -e "*.443" | grep LISTEN | wc -l | cut -d " " -f 8` + else + ports_occupied=`sudo netstat -tupln tcp | grep -e "*.80" -e "*.443" | grep LISTEN | wc -l | cut -d " " -f 8` + fi +} + install_docker() { if [[ $package_manager -eq apt-get ]];then echo "++++++++++++++++++++++++" @@ -51,7 +62,7 @@ check_os() { os_name=`cat /etc/*-release | egrep "^NAME="` os_name="${os_name#*=}" - echo $os_name + case "${os_name}" in \"Ubuntu*\") desired_os=1 @@ -110,6 +121,17 @@ if [[ $desired_os -eq 0 ]];then exit fi +check_ports_occupied + +if [[ $ports_occupied -ne 0 ]]; then + echo "+++++++++++ ERROR ++++++++++++++++++++++" + echo "Appsmith requires ports 80 & 443 to be open. Please shut down any other service(s) that may be running on these ports." + echo "++++++++++++++++++++++++++++++++++++++++" + echo "" + echo -e "Exiting for now. Bye! \U1F44B" + exit +fi + read -p 'Installation Directory [appsmith]: ' install_dir install_dir=${install_dir:-appsmith} mkdir -p $PWD/$install_dir @@ -181,6 +203,9 @@ fi echo "" read -p 'Do you have a custom domain that you would like to link? (Only for cloud installations) [N/y]: ' setup_domain setup_domain=${setup_domain:-N} +# Setting default value for the setup_ssl variable. Without this, the script errors out in the if condition later +setup_ssl='N' + if [ $setup_domain == "Y" -o $setup_domain == "y" -o $setup_domain == "yes" -o $setup_domain == "Yes" ];then echo "" echo "+++++++++++ IMPORTANT PLEASE READ ++++++++++++++++++++++" @@ -194,7 +219,7 @@ if [ $setup_domain == "Y" -o $setup_domain == "y" -o $setup_domain == "yes" -o $ setup_ssl=${setup_ssl:-Y} fi -if [ $setup_ssl == "Y" -o $setup_ssl == "y" -o $setup_ssl == "yes" -o $setup_ssl == "Yes" ];then +if [ $setup_ssl == "Y" -o $setup_ssl == "y" -o $setup_ssl == "yes" -o $setup_ssl == "Yes" ]; then read -p 'Enter the domain or subdomain on which you want to host appsmith (example.com / app.example.com): ' custom_domain fi @@ -265,18 +290,23 @@ if [[ ! -z $custom_domain ]]; then echo "Running init-letsencrypt.sh...." sudo ./init-letsencrypt.sh else - echo "No domain found. Skipping generation of LetsEncrypt certificate." + echo "No domain found. Skipping generation of SSL certificate." fi -echo "Updating the container images" +echo "Pulling the latest container images" sudo docker-compose pull echo "Starting the Appsmith containers" sudo docker-compose -f docker-compose.yml up -d --remove-orphans echo "" -echo "Your installation is complete. Please run the following command to ensure that all the containers are running without errors" -echo " cd $install_dir && sudo docker-compose ps -a" -echo -e "Peace out \U1F596" +echo "+++++++++++ SUCCESS ++++++++++++++++++++++" +echo "Your installation is complete. Please run the following command to ensure that all the containers are running without errors:" +echo "" +echo "cd $install_dir && sudo docker-compose ps -a" +echo "+++++++++++++++++++++++++++++++++++++++++++++++++" echo "" echo "Your application is running on http://localhost" +echo "" echo "Need help troubleshooting?" echo "Join our discord server https://discord.com/invite/rBTTVJp" +echo "" +echo -e "Peace out \U1F596" diff --git a/deploy/template/docker-compose.yml.sh b/deploy/template/docker-compose.yml.sh index 9f00c285d1..f701eaaef6 100644 --- a/deploy/template/docker-compose.yml.sh +++ b/deploy/template/docker-compose.yml.sh @@ -38,8 +38,8 @@ services: env_file: - ./docker.env - ./encryption.env - ports: - - "8080:8080" + expose: + - "8080" links: - mongo depends_on: @@ -49,8 +49,8 @@ services: mongo: image: mongo - ports: - - "27017:27017" + expose: + - "27017" environment: - MONGO_INITDB_DATABASE=appsmith - MONGO_INITDB_ROOT_USERNAME=$mongo_root_user @@ -63,8 +63,8 @@ services: redis: image: redis - ports: - - "6379:6379" + expose: + - "6379" networks: - appsmith