The main Bubble source repository. Contains the Bubble API server, the web UI, documentation and utilities. https://getbubblenow.com
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 

197 satır
5.7 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 ensure_docker_group() {
  37. CALLER="$(whoami)"
  38. if [[ "${CALLER}" != "root" && "$(sudo id -Gn "${CALLER}" | grep -c docker | tr -d ' ')" -eq 0 ]]; then
  39. echo "Adding user ${CALLER} to docker group ..."
  40. sudo usermod -a -G docker "${CALLER}"
  41. fi
  42. }
  43. function setup_docker_debian() {
  44. # Ensure apt is up to date
  45. sudo apt update -y
  46. # Remove obsolete packages
  47. sudo apt-get remove docker docker-engine docker.io containerd runc
  48. # Ensure apt can install packages over https
  49. sudo apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  50. # Install docker GPG key
  51. curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
  52. # Add docker repo
  53. sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
  54. # Refresh apt after adding repo
  55. sudo apt update -y
  56. # Install docker
  57. sudo apt install -y docker-ce docker-ce-cli containerd.io
  58. ensure_docker_group
  59. }
  60. function setup_docker_ubuntu() {
  61. # Ensure apt is up to date
  62. sudo apt update -y
  63. # Remove obsolete packages
  64. sudo apt-get remove docker docker-engine docker.io containerd runc
  65. # Ensure apt can install packages over https
  66. sudo apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  67. # Install docker GPG key
  68. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  69. # Add docker repo
  70. sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  71. # Refresh apt after adding repo
  72. sudo apt update -y
  73. # Install docker
  74. sudo apt install -y docker-ce
  75. ensure_docker_group
  76. }
  77. function setup_docker_generic_linux() {
  78. curl -fsSL https://get.docker.com | sudo sh -
  79. }
  80. function setup_docker_linux() {
  81. DISTRO="$(cat /etc/os-release | grep "^NAME" | awk -F '=' '{print $2}' | tr -d '"')"
  82. if [[ $(echo -n ${DISTRO} | grep -c Debian | tr -d ' ') -gt 0 ]]; then
  83. setup_docker_debian
  84. elif [[ $(echo -n ${DISTRO} | grep -c Ubuntu | tr -d ' ') -gt 0 ]]; then
  85. setup_docker_ubuntu
  86. else
  87. setup_docker_generic_linux
  88. fi
  89. }
  90. function setup_docker_macosx() {
  91. if [[ -z "$(which brew)" ]]; then
  92. die "Homebrew not installed (brew command not found). Install homebrew by running:
  93. /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)\"
  94. "
  95. fi
  96. brew install docker docker-machine || die "Error installing docker and docker-machine"
  97. brew cask install virtualbox || die "Error installing virtualbox (check Security Settings)"
  98. docker-machine create --driver virtualbox default
  99. }
  100. function setup_docker() {
  101. echo "Installing docker via sudo ..."
  102. if [[ $(whoami) != "root" ]]; then
  103. echo "Note: you may need to enter your password (for Linux user $(whoami)) to enable sudo commands"
  104. fi
  105. if [[ "${PLATFORM}" == "Linux" ]]; then
  106. setup_docker_linux
  107. elif [[ "${PLATFORM}" == "Darwin" ]]; then
  108. setup_docker_macosx
  109. eval "$(docker-machine env default)"
  110. docker-machine start default
  111. else
  112. die "Don't know how to install docker on ${PLATFORM}"
  113. fi
  114. }
  115. function run_launcher() {
  116. PLATFORM="$(uname -s)"
  117. if [[ -z "${PLATFORM}" ]]; then
  118. die "'uname -s' returned empty string!"
  119. fi
  120. if [[ -z "$(which docker)" ]]; then
  121. setup_docker
  122. if [[ -z "$(which docker)" ]]; then
  123. die "Error installing docker
  124. Install docker manually from https://docs.docker.com/engine/install/
  125. Then re-run this script
  126. "
  127. fi
  128. fi
  129. if [[ "${PLATFORM}" == "Linux" ]]; then
  130. ensure_docker_group
  131. fi
  132. # Determine bubble docker tag
  133. BUBBLE_TAG=$(get_bubble_tag)
  134. # Determine OS user
  135. CALLER="$(whoami)"
  136. # Pull bubble docker image
  137. if [[ "${CALLER}" == "root" ]] ; then
  138. docker pull "${BUBBLE_TAG}" || die "Error pulling docker image: ${BUBBLE_TAG}"
  139. else
  140. sudo su - "${CALLER}" -c "docker pull ${BUBBLE_TAG}" || die "Error pulling docker image: ${BUBBLE_TAG}"
  141. fi
  142. # Determine email for LetsEncrypt certs
  143. if [[ -z "${LETSENCRYPT_EMAIL}" ]]; then
  144. echo
  145. echo -n "Email address for LetsEncrypt certificates: "
  146. read -r LETSENCRYPT_EMAIL
  147. fi
  148. # Run bubble docker image
  149. if [[ "${CALLER}" == "root" ]] ; then
  150. docker run \
  151. -p 8090:8090 \
  152. -e LETSENCRYPT_EMAIL="${LETSENCRYPT_EMAIL}" \
  153. -t "${BUBBLE_TAG}"
  154. else
  155. sudo su - "${CALLER}" -c "docker run \
  156. -p 8090:8090 \
  157. -e LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL} \
  158. -t ${BUBBLE_TAG}"
  159. fi
  160. }
  161. run_launcher