Modifying the docker-compose templates to only expose required ports (#207)
* Modifying the docker-compose templates to only expose required ports from Nginx * Also, adding function to check if the required ports are open & available for use by Appsmith
This commit is contained in:
parent
a29dccbaf0
commit
4a62da9b36
|
|
@ -5,6 +5,17 @@ is_command_present() {
|
||||||
type "$1" >/dev/null 2>&1
|
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() {
|
install_docker() {
|
||||||
if [[ $package_manager -eq apt-get ]];then
|
if [[ $package_manager -eq apt-get ]];then
|
||||||
echo "++++++++++++++++++++++++"
|
echo "++++++++++++++++++++++++"
|
||||||
|
|
@ -51,7 +62,7 @@ check_os() {
|
||||||
|
|
||||||
os_name=`cat /etc/*-release | egrep "^NAME="`
|
os_name=`cat /etc/*-release | egrep "^NAME="`
|
||||||
os_name="${os_name#*=}"
|
os_name="${os_name#*=}"
|
||||||
echo $os_name
|
|
||||||
case "${os_name}" in
|
case "${os_name}" in
|
||||||
\"Ubuntu*\")
|
\"Ubuntu*\")
|
||||||
desired_os=1
|
desired_os=1
|
||||||
|
|
@ -110,6 +121,17 @@ if [[ $desired_os -eq 0 ]];then
|
||||||
exit
|
exit
|
||||||
fi
|
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
|
read -p 'Installation Directory [appsmith]: ' install_dir
|
||||||
install_dir=${install_dir:-appsmith}
|
install_dir=${install_dir:-appsmith}
|
||||||
mkdir -p $PWD/$install_dir
|
mkdir -p $PWD/$install_dir
|
||||||
|
|
@ -181,6 +203,9 @@ fi
|
||||||
echo ""
|
echo ""
|
||||||
read -p 'Do you have a custom domain that you would like to link? (Only for cloud installations) [N/y]: ' setup_domain
|
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}
|
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
|
if [ $setup_domain == "Y" -o $setup_domain == "y" -o $setup_domain == "yes" -o $setup_domain == "Yes" ];then
|
||||||
echo ""
|
echo ""
|
||||||
echo "+++++++++++ IMPORTANT PLEASE READ ++++++++++++++++++++++"
|
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}
|
setup_ssl=${setup_ssl:-Y}
|
||||||
fi
|
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
|
read -p 'Enter the domain or subdomain on which you want to host appsmith (example.com / app.example.com): ' custom_domain
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -265,18 +290,23 @@ if [[ ! -z $custom_domain ]]; then
|
||||||
echo "Running init-letsencrypt.sh...."
|
echo "Running init-letsencrypt.sh...."
|
||||||
sudo ./init-letsencrypt.sh
|
sudo ./init-letsencrypt.sh
|
||||||
else
|
else
|
||||||
echo "No domain found. Skipping generation of LetsEncrypt certificate."
|
echo "No domain found. Skipping generation of SSL certificate."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Updating the container images"
|
echo "Pulling the latest container images"
|
||||||
sudo docker-compose pull
|
sudo docker-compose pull
|
||||||
echo "Starting the Appsmith containers"
|
echo "Starting the Appsmith containers"
|
||||||
sudo docker-compose -f docker-compose.yml up -d --remove-orphans
|
sudo docker-compose -f docker-compose.yml up -d --remove-orphans
|
||||||
echo ""
|
echo ""
|
||||||
echo "Your installation is complete. Please run the following command to ensure that all the containers are running without errors"
|
echo "+++++++++++ SUCCESS ++++++++++++++++++++++"
|
||||||
echo " cd $install_dir && sudo docker-compose ps -a"
|
echo "Your installation is complete. Please run the following command to ensure that all the containers are running without errors:"
|
||||||
echo -e "Peace out \U1F596"
|
echo ""
|
||||||
|
echo "cd $install_dir && sudo docker-compose ps -a"
|
||||||
|
echo "+++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Your application is running on http://localhost"
|
echo "Your application is running on http://localhost"
|
||||||
|
echo ""
|
||||||
echo "Need help troubleshooting?"
|
echo "Need help troubleshooting?"
|
||||||
echo "Join our discord server https://discord.com/invite/rBTTVJp"
|
echo "Join our discord server https://discord.com/invite/rBTTVJp"
|
||||||
|
echo ""
|
||||||
|
echo -e "Peace out \U1F596"
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@ services:
|
||||||
env_file:
|
env_file:
|
||||||
- ./docker.env
|
- ./docker.env
|
||||||
- ./encryption.env
|
- ./encryption.env
|
||||||
ports:
|
expose:
|
||||||
- "8080:8080"
|
- "8080"
|
||||||
links:
|
links:
|
||||||
- mongo
|
- mongo
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|
@ -49,8 +49,8 @@ services:
|
||||||
|
|
||||||
mongo:
|
mongo:
|
||||||
image: mongo
|
image: mongo
|
||||||
ports:
|
expose:
|
||||||
- "27017:27017"
|
- "27017"
|
||||||
environment:
|
environment:
|
||||||
- MONGO_INITDB_DATABASE=appsmith
|
- MONGO_INITDB_DATABASE=appsmith
|
||||||
- MONGO_INITDB_ROOT_USERNAME=$mongo_root_user
|
- MONGO_INITDB_ROOT_USERNAME=$mongo_root_user
|
||||||
|
|
@ -63,8 +63,8 @@ services:
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis
|
image: redis
|
||||||
ports:
|
expose:
|
||||||
- "6379:6379"
|
- "6379"
|
||||||
networks:
|
networks:
|
||||||
- appsmith
|
- appsmith
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user