@@ -0,0 +1,40 @@ | |||
#!/bin/bash | |||
# | |||
# Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/ | |||
# | |||
# Build and push a docker image to docker hub, if needed. | |||
# Run by jenkins after a successful build of the main Bubble repository. | |||
# | |||
# If an image has already been pushed with the current version, we do nothing. | |||
# If no image has been pushed with the current version, we build it and push it. | |||
# | |||
function die { | |||
echo 1>&2 "${1}" | |||
exit 1 | |||
} | |||
THISDIR="$(cd "$(dirname "${0}")" && pwd)" | |||
BUBBLE_DIR="$(cd "${THISDIR}/../.." && pwd)" | |||
echo "Determining Bubble version..." | |||
META_FILE="${BUBBLE_DIR}/bubble-server/src/main/resources/META-INF/bubble/bubble.properties" | |||
VERSION="$(cat "${META_FILE}" | grep bubble.version | awk -F '=' '{print $2}' | awk -F ' ' '{print $NF}' | awk '{$1=$1};1')" | |||
if [[ -z "${VERSION}" ]] ; then | |||
die "Error determining version from: ${META_FILE}" | |||
fi | |||
echo "Found Bubble version ${VERSION}" | |||
echo "Checking to see if this version already exists on dockerhub..." | |||
if docker manifest inspect getbubble/launcher:${VERSION} 2> /dev/null ; then | |||
echo "Version already exists on dockerhub, not re-publishing: ${VERSION}" | |||
exit 0 | |||
fi | |||
echo "Version does not exist on dockerhub, building and pushing it..." | |||
BUBBLE_DOCKER="${BUBBLE_DIR}/docker/bubble.sh" | |||
${BUBBLE_DOCKER} build || die "Error building docker image" | |||
${BUBBLE_DOCKER} push || die "Error pushing docker image" | |||
echo "Successfully built/pushed to dockerhub: ${VERSION}" |
@@ -1 +1 @@ | |||
bubble.version=Adventure 1.4.0 | |||
bubble.version=Adventure 1.4.1 |
@@ -2,25 +2,18 @@ | |||
# | |||
# Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/ | |||
# | |||
# Build, run or push a docker container for a Bubble launcher | |||
# Build, run or push a docker container for a Bubble launcher. Intended for developer use. | |||
# | |||
# -- Building a Docker image: | |||
# bubble.sh [mode] [version] | |||
# | |||
# bubble.sh build [tag-name] | |||
# mode : build, run or push | |||
# build - build the docker image | |||
# run - run the docker image | |||
# push - push to docker hub | |||
# | |||
# tag-name : name of the docker tag to apply, default is getbubble/launcher:VERSION | |||
# version : version to use, default is read from bubble-server/src/main/resources/META-INF/bubble/bubble.properties | |||
# | |||
# -- Running a Docker image: | |||
# | |||
# bubble.sh run [tag-name] | |||
# | |||
# tag-name : name of the docker tag to use, default is getbubble/launcher:VERSION | |||
# | |||
# -- Pushing a Docker image: | |||
# | |||
# bubble.sh push [tag-name] | |||
# | |||
# tag-name : name of the docker tag to push, default is getbubble/launcher:VERSION | |||
# The docker tag used will be getbubble/launcher:version | |||
# | |||
function die { | |||
@@ -29,24 +22,28 @@ function die { | |||
} | |||
THISDIR="$(cd "$(dirname "${0}")" && pwd)" | |||
cd "${THISDIR}/.." || die "Directory not found: ${THISDIR}/.." | |||
DEFAULT_TAG="getbubble/launcher:0.3" | |||
BUBBLE_DIR="$(cd "${THISDIR}/.." && pwd)" | |||
MODE=${1:?no mode specified, use build or run} | |||
TAG=${2:-${DEFAULT_TAG}} | |||
META_FILE="${BUBBLE_DIR}/bubble-server/src/main/resources/META-INF/bubble/bubble.properties" | |||
VERSION="${2:-$(cat ${META_FILE} | grep bubble.version | awk -F '=' '{print $2}' | awk -F ' ' '{print $NF}' | awk '{$1=$1};1')}" | |||
if [[ -z "${VERSION}" ]] ; then | |||
die "Error determining version from: ${META_FILE}" | |||
fi | |||
BUBBLE_TAG="getbubble/launcher:${VERSION}" | |||
if [[ "${MODE}" == "build" ]] ; then | |||
if [[ $(find bubble-server/target -type f -name "bubble-server-*.jar" | wc -l | tr -d ' ') -eq 0 ]] ; then | |||
die "No bubble jar found in $(pwd)/bubble-server/target" | |||
fi | |||
docker build -t ${TAG} . || die "Error building docker image" | |||
docker build -t ${BUBBLE_TAG} . || die "Error building docker image" | |||
elif [[ "${MODE}" == "run" ]] ; then | |||
docker run --env-file <(cat "${HOME}/.bubble.env" | sed -e 's/export //' | tr -d '"' | tr -d "'") -p 8090:8090 -t ${TAG} || die "Error running docker container" | |||
docker run --env-file <(cat "${HOME}/.bubble.env" | sed -e 's/export //' | tr -d '"' | tr -d "'") -p 8090:8090 -t ${BUBBLE_TAG} || die "Error running docker container" | |||
elif [[ "${MODE}" == "push" ]] ; then | |||
docker push ${TAG} || die "Error pushing docker image" | |||
docker push ${BUBBLE_TAG} || die "Error pushing docker image" | |||
else | |||
die "Invalid mode (expected build or run): ${MODE}" | |||
@@ -0,0 +1,86 @@ | |||
#!/bin/bash | |||
# | |||
# Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/ | |||
# | |||
# Run bubble launcher in a docker container. Intended for non-developers to run via curl | bash: | |||
# | |||
# Usage: | |||
# | |||
# launcher.sh | |||
# | |||
# This command will: | |||
# - install docker if not found | |||
# - pull and run bubble docker image | |||
# | |||
function die { | |||
echo 1>&2 "${1}" | |||
exit 1 | |||
} | |||
BUBBLE_META_URL="https://git.bubblev.org/bubblev/bubble/raw/branch/master/bubble-server/src/main/resources/META-INF/bubble/bubble.properties" | |||
VERSION="$(curl -s ${BUBBLE_META_URL} | grep bubble.version | awk -F '=' '{print $2}' | awk -F ' ' '{print $NF}' | awk '{$1=$1};1')" | |||
if [[ -z "${VERSION}" ]] ; then | |||
die "Error determining version from URL: ${BUBBLE_META_URL}" | |||
fi | |||
BUBBLE_TAG="getbubble/launcher:${VERSION}" | |||
function setup_docker_linux() { | |||
# Ensure apt is up to date | |||
sudo apt update -y | |||
# Ensure apt can install packages over https | |||
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common | |||
# Install Docker GPG key | |||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |||
# Add Docker apt repo | |||
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" | |||
# Refresh apt after adding repo | |||
sudo apt update -y | |||
# Install docker | |||
sudo apt install -y docker-ce | |||
} | |||
function setup_docker_macosx() { | |||
if [[ -z "$(which brew)" ]] ; then | |||
die "Homebrew not installed (brew command not found). Install homebrew by running: | |||
/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)\" | |||
" | |||
fi | |||
brew install docker docker-machine || die "Error installing docker and docker-machine" | |||
brew cask install virtualbox || die "Error installing virtualbox (check Security Settings)" | |||
docker-machine create --driver virtualbox default | |||
} | |||
function setup_docker() { | |||
PLATFORM="$(uname -s)" | |||
if [[ -z "${PLATFORM}" ]] ; then | |||
die "'uname -a command' returned empty string!" | |||
fi | |||
if [[ -z "$(which docker)" ]] ; then | |||
echo "docker command not found" | |||
echo "Installing docker via sudo (you may need to enter your password) ..." | |||
if [[ "${PLATFORM}" == "Linux" ]] ; then | |||
setup_docker_linux | |||
elif [[ "${PLATFORM}" == "Darwin" ]] ; then | |||
setup_docker_macosx | |||
eval "$(docker-machine env default)" | |||
else | |||
die "Don't know how to install docker on ${PLATFORM}" | |||
fi | |||
fi | |||
# Pull bubble docker image | |||
docker pull ${BUBBLE_TAG} | |||
# Run bubble docker image | |||
docker run -p 8090:8090 -t ${BUBBLE_TAG} || die "Error running docker container" | |||
} | |||
setup_docker |