The main Bubble source repository. Contains the Bubble API server, the web UI, documentation and utilities. https://getbubblenow.com
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

90 righe
3.5 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 images
  11. # run - run a docker image. set the BUBBLE_RUN_SLIM env var to `true` to run the slim image.
  12. # push - push images 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. # We build two images, a full one and a slim one.
  19. # The full image is larger (will take longer to download), but will startup faster.
  20. # The slim image is smaller (will be faster to download), but will take longer to start up.
  21. #
  22. # The full image has the Bubble jar, updated packages and packer pre-installed.
  23. # The slim image has default packages and installs packer and the Bubble jar when it first runs.
  24. #
  25. # If you want to change the "getbubble/launcher" part of the Docker tag, set the BUBBLE_DOCKER_REPO
  26. # environment variable in your shell environment.
  27. #
  28. # When using the 'run' mode, you'll be asked for an email address to associate with any LetsEncrypt
  29. # certificates that will be created.
  30. #
  31. # If you want to run this unattended, set the LETSENCRYPT_EMAIL environment variable
  32. # in your ~/.bubble.env file or in your shell environment.
  33. #
  34. function die {
  35. echo 1>&2 "${1}"
  36. exit 1
  37. }
  38. THISDIR="$(cd "$(dirname "${0}")" && pwd)"
  39. BUBBLE_DIR="$(cd "${THISDIR}/.." && pwd)"
  40. MODE=${1:?no mode specified, use build or run}
  41. META_FILE="${BUBBLE_DIR}/bubble-server/src/main/resources/META-INF/bubble/bubble.properties"
  42. VERSION="${2:-$(cat "${META_FILE}" | grep bubble.version | awk -F '=' '{print $2}' | awk -F ' ' '{print $NF}' | awk '{$1=$1};1')}"
  43. if [[ -z "${VERSION}" ]] ; then
  44. die "Error determining version from: ${META_FILE}"
  45. fi
  46. DOCKER_REPO="getbubble"
  47. if [[ ! -z "${BUBBLE_DOCKER_REPO}" ]] ; then
  48. DOCKER_REPO="${BUBBLE_DOCKER_REPO}"
  49. fi
  50. BUBBLE_TAG="${DOCKER_REPO}/launcher:${VERSION}"
  51. BUBBLE_SLIM_TAG="${DOCKER_REPO}/slim-launcher:${VERSION}"
  52. BUBBLE_ENV="${HOME}/.bubble.env"
  53. if [[ "${MODE}" == "build" ]] ; then
  54. if [[ $(find bubble-server/target -type f -name "bubble-server-*.jar" | wc -l | tr -d ' ') -eq 0 ]] ; then
  55. die "No bubble jar found in $(pwd)/bubble-server/target"
  56. fi
  57. docker build --no-cache -t "${BUBBLE_TAG}" . || die "Error building docker image"
  58. docker build --no-cache -f Dockerfile.slim -t "${BUBBLE_SLIM_TAG}" . || die "Error building slim docker image"
  59. elif [[ "${MODE}" == "run" ]] ; then
  60. if [[ $(cat "${BUBBLE_ENV}" | grep -v '^#' | grep -c LETSENCRYPT_EMAIL) -eq 0 ]] ; then
  61. if [[ -z "${LETSENCRYPT_EMAIL}" ]] ; then
  62. echo ; echo -n "Email address for LetsEncrypt certificates: "
  63. read -r LETSENCRYPT_EMAIL
  64. fi
  65. echo "
  66. export LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
  67. " >> "${BUBBLE_ENV}"
  68. fi
  69. if [[ ! -z "${BUBBLE_RUN_SLIM}" && "${BUBBLE_RUN_SLIM}" == "true" ]] ; then
  70. RUN_TAG="${BUBBLE_SLIM_TAG}"
  71. else
  72. RUN_TAG="${BUBBLE_TAG}"
  73. fi
  74. docker run --env-file <(cat "${BUBBLE_ENV}" | sed -e 's/export //' | tr -d '"' | tr -d "'") -p 8090:8090 -t "${RUN_TAG}" || die "Error running docker container"
  75. elif [[ "${MODE}" == "push" ]] ; then
  76. docker push "${BUBBLE_TAG}" || die "Error pushing docker image"
  77. docker push "${BUBBLE_SLIM_TAG}" || die "Error pushing slim docker image"
  78. else
  79. die "Invalid mode (expected build or run): ${MODE}"
  80. fi