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

75 рядки
2.6 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. # Build, run or push a docker container for a Bubble launcher. Intended for developer use.
  6. #
  7. # bubble.sh [mode] [version]
  8. #
  9. # mode : build, run or push
  10. # build - build the docker image
  11. # run - run the docker image
  12. # push - push to docker hub
  13. #
  14. # version : version to use, default is read from bubble-server/src/main/resources/META-INF/bubble/bubble.properties
  15. #
  16. # The docker tag used will be getbubble/launcher:version
  17. #
  18. # If you want to change the "getbubble/launcher" part of the Docker tag, set the BUBBLE_DOCKER_REPO
  19. # environment variable in your shell environment.
  20. #
  21. # When using the 'run' mode, you'll be asked for an email address to associate with any LetsEncrypt
  22. # certificates that will be created.
  23. #
  24. # If you want to run this unattended, set the LETSENCRYPT_EMAIL environment variable
  25. # in your ~/.bubble.env file or in your shell environment.
  26. #
  27. function die {
  28. echo 1>&2 "${1}"
  29. exit 1
  30. }
  31. THISDIR="$(cd "$(dirname "${0}")" && pwd)"
  32. BUBBLE_DIR="$(cd "${THISDIR}/.." && pwd)"
  33. MODE=${1:?no mode specified, use build or run}
  34. META_FILE="${BUBBLE_DIR}/bubble-server/src/main/resources/META-INF/bubble/bubble.properties"
  35. VERSION="${2:-$(cat ${META_FILE} | grep bubble.version | awk -F '=' '{print $2}' | awk -F ' ' '{print $NF}' | awk '{$1=$1};1')}"
  36. if [[ -z "${VERSION}" ]] ; then
  37. die "Error determining version from: ${META_FILE}"
  38. fi
  39. DOCKER_REPO="getbubble/launcher"
  40. if [[ ! -z "${BUBBLE_DOCKER_REPO}" ]] ; then
  41. DOCKER_REPO="${BUBBLE_DOCKER_REPO}"
  42. fi
  43. BUBBLE_TAG="${DOCKER_REPO}:${VERSION}"
  44. BUBBLE_ENV="${HOME}/.bubble.env"
  45. if [[ "${MODE}" == "build" ]] ; then
  46. if [[ $(find bubble-server/target -type f -name "bubble-server-*.jar" | wc -l | tr -d ' ') -eq 0 ]] ; then
  47. die "No bubble jar found in $(pwd)/bubble-server/target"
  48. fi
  49. docker build -t ${BUBBLE_TAG} . || die "Error building docker image"
  50. elif [[ "${MODE}" == "run" ]] ; then
  51. if [[ $(cat "${BUBBLE_ENV}" | grep -v '^#' | grep -c LETSENCRYPT_EMAIL) -eq 0 ]] ; then
  52. if [[ -z "${LETSENCRYPT_EMAIL}" ]] ; then
  53. echo ; echo -n "Email address for LetsEncrypt certificates: "
  54. read -r LETSENCRYPT_EMAIL
  55. fi
  56. echo "
  57. export LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
  58. " >> "${BUBBLE_ENV}"
  59. fi
  60. docker run --env-file <(cat "${BUBBLE_ENV}" | sed -e 's/export //' | tr -d '"' | tr -d "'") -p 8090:8090 -t ${BUBBLE_TAG} || die "Error running docker container"
  61. elif [[ "${MODE}" == "push" ]] ; then
  62. docker push ${BUBBLE_TAG} || die "Error pushing docker image"
  63. else
  64. die "Invalid mode (expected build or run): ${MODE}"
  65. fi