The main Bubble source repository. Contains the Bubble API server, the web UI, documentation and utilities. https://getbubblenow.com
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

push_docker 2.9 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 and push a docker image to docker hub, if needed.
  6. # Run by jenkins after a successful build of the main Bubble repository.
  7. #
  8. # If an image has already been pushed with the current version, we do nothing.
  9. # If no image has been pushed with the current version, we build it and push it.
  10. #
  11. # Environment Variables:
  12. #
  13. # BUBBLE_DOCKER_USER - dockerhub username for "docker login"
  14. # BUBBLE_DOCKER_PASS - dockerhub password for "docker login"
  15. #
  16. function die {
  17. echo 1>&2 "${1}"
  18. exit 1
  19. }
  20. function ensure_docker_experimental_enabled() {
  21. DOCKER_DIR=${HOME}/.docker
  22. mkdir -p "${DOCKER_DIR}" || die "Error creating ${DOCKER_DIR}"
  23. if [[ -f ${DOCKER_DIR}/config.json ]] ; then
  24. TMP_CONFIG=$(mktemp /tmp/config.json.XXXX) &&
  25. jq '. + {"experimental": "enabled"}' < "${DOCKER_DIR}/config.json" > "${TMP_CONFIG}" &&
  26. mv "${TMP_CONFIG}" "${DOCKER_DIR}/config.json" || ( rm -f "${TMP_CONFIG}" ; die "Error adding experimental flag to ${DOCKER_DIR}/config.json" )
  27. if [[ -f ${TMP_CONFIG} ]] ; then rm -f "${TMP_CONFIG}" ; fi
  28. echo "ensure_docker_experimental_enabled: updated ${DOCKER_DIR}/config.json --> "
  29. cat "${DOCKER_DIR}/config.json"
  30. else
  31. echo '{"experimental": "enabled"}' > ~/.docker/config.json
  32. echo "ensure_docker_experimental_enabled: created ${DOCKER_DIR}/config.json --> "
  33. cat "${DOCKER_DIR}/config.json"
  34. fi
  35. }
  36. if [[ -z "${BUBBLE_DOCKER_USER}" ]] ; then
  37. die "No BUBBLE_DOCKER_USER env var found"
  38. fi
  39. if [[ -z "${BUBBLE_DOCKER_PASS}" ]] ; then
  40. die "No BUBBLE_DOCKER_PASS env var found"
  41. fi
  42. set +x
  43. THISDIR="$(cd "$(dirname "${0}")" && pwd)"
  44. BUBBLE_DIR="$(cd "${THISDIR}/../.." && pwd)"
  45. echo "Logging in to docker ..."
  46. echo -n "${BUBBLE_DOCKER_PASS}" | docker login -u "${BUBBLE_DOCKER_USER}" --password-stdin || die "Error logging in to docker"
  47. echo "Determining Bubble version ..."
  48. META_FILE="${BUBBLE_DIR}/bubble-server/src/main/resources/META-INF/bubble/bubble.properties"
  49. VERSION="$(cat "${META_FILE}" | grep bubble.version | awk -F '=' '{print $2}' | awk -F ' ' '{print $NF}' | awk '{$1=$1};1')"
  50. if [[ -z "${VERSION}" ]] ; then
  51. die "Error determining version from: ${META_FILE}"
  52. fi
  53. echo "Found Bubble version ${VERSION}"
  54. echo "Building docker bubble version ${VERSION} ..."
  55. BUBBLE_DOCKER="${BUBBLE_DIR}/docker/bubble.sh"
  56. ${BUBBLE_DOCKER} build || die "Error building docker image"
  57. echo "Checking to see if version ${VERSION} already exists on dockerhub..."
  58. ensure_docker_experimental_enabled
  59. if docker manifest inspect "getbubble/launcher:${VERSION}" > /dev/null 2> /dev/null ; then
  60. echo "Version ${VERSION} already exists on dockerhub, not re-publishing"
  61. exit 0
  62. fi
  63. echo "Version ${VERSION} does not exist on dockerhub, pushing it ..."
  64. ${BUBBLE_DOCKER} push || die "Error pushing docker image"
  65. echo "Successfully pushed to dockerhub: ${VERSION}"