The main Bubble source repository. Contains the Bubble API server, the web UI, documentation and utilities. https://getbubblenow.com
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 

196 рядки
5.8 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. # Upon successful startup, the bubble launcher will be listening on port 8090
  15. #
  16. # Open http://127.0.0.1:8090/ in a web browser to continue with activation.
  17. #
  18. function die {
  19. echo 1>&2 "${1}"
  20. exit 1
  21. }
  22. function get_bubble_tag() {
  23. BUBBLE_RELEASE_URL="https://jenkins.bubblev.org/public/releases/bubble/latest.txt"
  24. VERSION="$(curl -s ${BUBBLE_RELEASE_URL} | awk -F '_' '{print $2}' | awk -F '.' '{print $1"."$2"."$3}')"
  25. if [[ -z "${VERSION}" ]] ; then
  26. die "Error determining version from URL: ${BUBBLE_RELEASE_URL}"
  27. fi
  28. echo -n "getbubble/launcher:${VERSION}"
  29. }
  30. function setup_docker_debian() {
  31. # Ensure apt is up to date
  32. sudo apt update -y
  33. # Remove obsolete packages
  34. sudo apt-get remove docker docker-engine docker.io containerd runc
  35. # Ensure apt can install packages over https
  36. sudo apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  37. # Install docker GPG key
  38. curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
  39. # Add docker repo
  40. sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
  41. # Refresh apt after adding repo
  42. sudo apt update -y
  43. # Install docker
  44. sudo apt install -y docker-ce docker-ce-cli containerd.io
  45. }
  46. function setup_docker_ubuntu() {
  47. # Ensure apt is up to date
  48. sudo apt update -y
  49. # Remove obsolete packages
  50. sudo apt-get remove docker docker-engine docker.io containerd runc
  51. # Ensure apt can install packages over https
  52. sudo apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  53. # Install docker GPG key
  54. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  55. # Add docker repo
  56. sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  57. # Refresh apt after adding repo
  58. sudo apt update -y
  59. # Install docker
  60. sudo apt install -y docker-ce
  61. }
  62. function setup_docker_centos_dnf() {
  63. # Update dnf
  64. sudo dnf update -y --nobest
  65. # Add docker repo
  66. sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  67. # Refresh dnf after adding repo
  68. sudo dnf update -y --nobest
  69. # Install docker
  70. sudo dnf install -y docker-ce --best --allowerasing
  71. # Start docker
  72. sudo systemctl start docker
  73. }
  74. function setup_docker_centos_yum() {
  75. # Remove obsolete docker packages
  76. sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
  77. # Add docker repo
  78. sudo yum install -y yum-utils
  79. sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  80. # Install docker
  81. sudo yum install docker-ce docker-ce-cli containerd.io
  82. # Start docker
  83. sudo systemctl start docker
  84. }
  85. function setup_docker_fedora_dnf() {
  86. # Update dnf
  87. sudo dnf update -y --nobest
  88. # Install docker
  89. sudo dnf install -y docker-ce
  90. # Start docker
  91. sudo systemctl start docker
  92. }
  93. function setup_docker_linux() {
  94. DISTRO="$(cat /etc/os-release | grep "^NAME" | awk -F '=' '{print $2}' | tr -d '"')"
  95. if [[ $(echo -n ${DISTRO} | grep -c Debian | tr -d ' ') -gt 0 ]] ; then
  96. setup_docker_debian
  97. elif [[ $(echo -n ${DISTRO} | grep -c Ubuntu | tr -d ' ') -gt 0 ]] ; then
  98. setup_docker_ubuntu
  99. elif [[ $(echo -n ${DISTRO} | grep -c CentOS | tr -d ' ') -gt 0 ]] ; then
  100. if [[ ! -z "$(which dnf)" ]] ; then
  101. setup_docker_centos_dnf
  102. elif [[ ! -z "$(which yum)" ]] ; then
  103. setup_docker_centos_yum
  104. else
  105. die "Neither dnf nor yum found, cannot install on CentOS.
  106. Please install docker manually from https://docker.io/"
  107. fi
  108. elif [[ $(echo -n ${DISTRO} | grep -c Fedora | tr -d ' ') -gt 0 ]] ; then
  109. setup_docker_fedora_dnf
  110. else
  111. die "Automatic docker installation for ${DISTRO} is not yet supported
  112. Please install docker manually from https://docker.io/"
  113. fi
  114. }
  115. function setup_docker_macosx() {
  116. if [[ -z "$(which brew)" ]] ; then
  117. die "Homebrew not installed (brew command not found). Install homebrew by running:
  118. /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)\"
  119. "
  120. fi
  121. brew install docker docker-machine || die "Error installing docker and docker-machine"
  122. brew cask install virtualbox || die "Error installing virtualbox (check Security Settings)"
  123. docker-machine create --driver virtualbox default
  124. }
  125. function setup_docker() {
  126. echo "Installing docker via sudo ..."
  127. if [[ $(whoami) != "root" ]] ; then
  128. echo "Note: you may need to enter your password (for Linux user $(whoami)) to enable sudo commands"
  129. fi
  130. if [[ "${PLATFORM}" == "Linux" ]] ; then
  131. setup_docker_linux
  132. elif [[ "${PLATFORM}" == "Darwin" ]] ; then
  133. setup_docker_macosx
  134. eval "$(docker-machine env default)"
  135. docker-machine start default
  136. else
  137. die "Don't know how to install docker on ${PLATFORM}"
  138. fi
  139. }
  140. function run_launcher() {
  141. PLATFORM="$(uname -s)"
  142. if [[ -z "${PLATFORM}" ]] ; then
  143. die "'uname -s' returned empty string!"
  144. fi
  145. if [[ -z "$(which docker)" ]] ; then
  146. setup_docker
  147. fi
  148. # Determine bubble docker tag
  149. BUBBLE_TAG=$(get_bubble_tag)
  150. # Pull bubble docker image
  151. docker pull ${BUBBLE_TAG} || die "Error pulling docker image: ${BUBBLE_TAG}"
  152. # Run bubble docker image
  153. docker run -p 8090:8090 -t ${BUBBLE_TAG}
  154. }
  155. run_launcher