The main Bubble source repository. Contains the Bubble API server, the web UI, documentation and utilities. https://getbubblenow.com
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

167 lignes
4.9 KiB

  1. #!/bin/bash
  2. #
  3. # Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
  4. #
  5. # Run bubble launcher in a docker container. Works on Linux or Mac OS.
  6. #
  7. # /bin/bash -c "$(curl -sL https://git.bubblev.org/bubblev/bubble/raw/branch/master/docker/launcher.sh)"
  8. #
  9. # This command will:
  10. # - install docker if no "docker" command found
  11. # - pull bubble launcher docker image
  12. # - run bubble launcher docker image
  13. #
  14. # You'll be asked for an email address to associate with any LetsEncrypt certificates that will be created.
  15. #
  16. # If you want to run this unattended, set the LETSENCRYPT_EMAIL environment variable.
  17. #
  18. # Upon successful startup, the bubble launcher will be listening on port 8090
  19. #
  20. # Open http://127.0.0.1:8090/ in a web browser to continue with activation.
  21. #
  22. function die {
  23. echo 1>&2 "
  24. ***** ${1}
  25. "
  26. exit 1
  27. }
  28. function get_bubble_tag() {
  29. BUBBLE_RELEASE_URL="https://jenkins.bubblev.org/public/releases/bubble/latest.txt"
  30. VERSION="$(curl -s ${BUBBLE_RELEASE_URL} | awk -F '_' '{print $2}' | awk -F '.' '{print $1"."$2"."$3}')"
  31. if [[ -z "${VERSION}" ]] ; then
  32. die "Error determining version from URL: ${BUBBLE_RELEASE_URL}"
  33. fi
  34. echo -n "getbubble/launcher:${VERSION}"
  35. }
  36. function setup_docker_debian() {
  37. # Ensure apt is up to date
  38. sudo apt update -y
  39. # Remove obsolete packages
  40. sudo apt-get remove docker docker-engine docker.io containerd runc
  41. # Ensure apt can install packages over https
  42. sudo apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  43. # Install docker GPG key
  44. curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
  45. # Add docker repo
  46. sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
  47. # Refresh apt after adding repo
  48. sudo apt update -y
  49. # Install docker
  50. sudo apt install -y docker-ce docker-ce-cli containerd.io
  51. }
  52. function setup_docker_ubuntu() {
  53. # Ensure apt is up to date
  54. sudo apt update -y
  55. # Remove obsolete packages
  56. sudo apt-get remove docker docker-engine docker.io containerd runc
  57. # Ensure apt can install packages over https
  58. sudo apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  59. # Install docker GPG key
  60. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  61. # Add docker repo
  62. sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  63. # Refresh apt after adding repo
  64. sudo apt update -y
  65. # Install docker
  66. sudo apt install -y docker-ce
  67. }
  68. function setup_docker_generic_linux() {
  69. curl -fsSL https://get.docker.com | sudo sh -
  70. }
  71. function setup_docker_linux() {
  72. DISTRO="$(cat /etc/os-release | grep "^NAME" | awk -F '=' '{print $2}' | tr -d '"')"
  73. if [[ $(echo -n ${DISTRO} | grep -c Debian | tr -d ' ') -gt 0 ]] ; then
  74. setup_docker_debian
  75. elif [[ $(echo -n ${DISTRO} | grep -c Ubuntu | tr -d ' ') -gt 0 ]] ; then
  76. setup_docker_ubuntu
  77. else
  78. setup_docker_generic_linux
  79. fi
  80. }
  81. function setup_docker_macosx() {
  82. if [[ -z "$(which brew)" ]] ; then
  83. die "Homebrew not installed (brew command not found). Install homebrew by running:
  84. /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)\"
  85. "
  86. fi
  87. brew install docker docker-machine || die "Error installing docker and docker-machine"
  88. brew cask install virtualbox || die "Error installing virtualbox (check Security Settings)"
  89. docker-machine create --driver virtualbox default
  90. }
  91. function setup_docker() {
  92. echo "Installing docker via sudo ..."
  93. if [[ $(whoami) != "root" ]] ; then
  94. echo "Note: you may need to enter your password (for Linux user $(whoami)) to enable sudo commands"
  95. fi
  96. if [[ "${PLATFORM}" == "Linux" ]] ; then
  97. setup_docker_linux
  98. elif [[ "${PLATFORM}" == "Darwin" ]] ; then
  99. setup_docker_macosx
  100. eval "$(docker-machine env default)"
  101. docker-machine start default
  102. else
  103. die "Don't know how to install docker on ${PLATFORM}"
  104. fi
  105. }
  106. function run_launcher() {
  107. PLATFORM="$(uname -s)"
  108. if [[ -z "${PLATFORM}" ]] ; then
  109. die "'uname -s' returned empty string!"
  110. fi
  111. if [[ -z "$(which docker)" ]] ; then
  112. setup_docker
  113. if [[ -z "$(which docker)" ]] ; then
  114. die "Error installing docker
  115. Install docker manually from https://docs.docker.com/engine/install/
  116. Then re-run this script
  117. "
  118. fi
  119. fi
  120. # Determine bubble docker tag
  121. BUBBLE_TAG=$(get_bubble_tag)
  122. # Pull bubble docker image
  123. docker pull ${BUBBLE_TAG} || die "Error pulling docker image: ${BUBBLE_TAG}"
  124. # Determine email for LetsEncrypt certs
  125. if [[ -z "${LETSENCRYPT_EMAIL}" ]] ; then
  126. echo ; echo -n "Email address for LetsEncrypt certificates: "
  127. read -r LETSENCRYPT_EMAIL
  128. fi
  129. # Run bubble docker image
  130. docker run \
  131. -p 8090:8090 \
  132. -e LETSENCRYPT_EMAIL="${LETSENCRYPT_EMAIL}" \
  133. -t ${BUBBLE_TAG}
  134. }
  135. run_launcher