Automated docker nginx proxy integrated with letsencrypt. Based on https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

start.sh 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/bash
  2. #
  3. # This file should be used to prepare and run your WebProxy after set up your .env file
  4. # Source: https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion
  5. #
  6. # 1. Check if .env file exists
  7. if [ -e .env ]; then
  8. source .env
  9. else
  10. echo "Please set up your .env file before starting your environment."
  11. exit 1
  12. fi
  13. # 2. Create docker network
  14. docker network create $NETWORK $NETWORK_OPTIONS
  15. # 3. Verify if second network is configured
  16. if [ ! -z ${SERVICE_NETWORK+X} ]; then
  17. docker network create $SERVICE_NETWORK $SERVICE_NETWORK_OPTIONS
  18. fi
  19. # 4. Download the latest version of nginx.tmpl
  20. curl https://raw.githubusercontent.com/jwilder/nginx-proxy/master/nginx.tmpl > nginx.tmpl
  21. # 5. Update local images
  22. docker-compose pull
  23. # 6. Add any special configuration if it's set in .env file
  24. # Check if user set to use Special Conf Files
  25. if [ ! -z ${USE_NGINX_CONF_FILES+X} ] && [ "$USE_NGINX_CONF_FILES" = true ]; then
  26. # Create the conf folder if it does not exists
  27. mkdir -p $NGINX_FILES_PATH/conf.d
  28. # Copy the special configurations to the nginx conf folder
  29. cp -R ./conf.d/* $NGINX_FILES_PATH/conf.d
  30. # Check if there was an error and try with sudo
  31. if [ $? -ne 0 ]; then
  32. sudo cp -R ./conf.d/* $NGINX_FILES_PATH/conf.d
  33. fi
  34. # If there was any errors inform the user
  35. if [ $? -ne 0 ]; then
  36. echo
  37. echo "#######################################################"
  38. echo
  39. echo "There was an error trying to copy the nginx conf files."
  40. echo "The webproxy will still work, your custom configuration"
  41. echo "will not be loaded."
  42. echo
  43. echo "#######################################################"
  44. fi
  45. fi
  46. # 7. Start proxy
  47. # Check if you have multiple network
  48. if [ -z ${SERVICE_NETWORK+X} ]; then
  49. docker-compose up -d
  50. else
  51. docker-compose -f docker-compose-multiple-networks.yml up -d
  52. fi
  53. exit 0