Selaa lähdekoodia

WIP. fixing docker port mapping. add missing file headers

tags/v1.5.4
Jonathan Cobb 3 vuotta sitten
vanhempi
commit
a8304d0a58
16 muutettua tiedostoa jossa 141 lisäystä ja 14 poistoa
  1. +2
    -0
      bin/bbuild
  2. +69
    -8
      bin/bdocker
  3. +4
    -0
      bubble-server/src/main/java/bubble/cloud/compute/ComputeDeploymentConfig.java
  4. +4
    -0
      bubble-server/src/main/java/bubble/cloud/compute/docker/DockerComputeDriver.java
  5. +4
    -0
      bubble-server/src/main/java/bubble/cloud/geoLocation/whois/WhoisConfig.java
  6. +4
    -0
      bubble-server/src/main/java/bubble/cloud/geoLocation/whois/WhoisGeoLocationDriver.java
  7. +1
    -1
      bubble-server/src/main/resources/bubble-config.yml
  8. +14
    -0
      bubble-server/src/main/resources/docker/run_bubble.sh
  9. +13
    -0
      bubble-server/src/main/resources/docker/run_bubble_slim.sh
  10. +3
    -0
      bubble-server/src/main/resources/docker/run_cron.sh
  11. +0
    -1
      bubble-server/src/main/resources/docker/run_postgresql.sh
  12. +3
    -0
      bubble-server/src/main/resources/docker/run_supervisor.sh
  13. +1
    -0
      bubble-server/src/main/resources/logback.xml
  14. +3
    -0
      bubble-server/src/main/resources/packer/roles/common/tasks/docker.yml
  15. +1
    -1
      bubble-web
  16. +15
    -3
      launcher

+ 2
- 0
bin/bbuild Näytä tiedosto

@@ -1,5 +1,7 @@
#!/bin/bash
#
# Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
#
# Build the bubble jar
#
# Usage:


+ 69
- 8
bin/bdocker Näytä tiedosto

@@ -10,6 +10,8 @@
# build - build the docker images
# run - run a docker image. set the BUBBLE_RUN_SLIM env var to `true` to run the slim image.
# push - push images docker hub
# term - open a bash terminal on a running container
# clean - remove containers and images related to the version
#
# version : version to use, default is read from bubble-server/src/main/resources/META-INF/bubble/bubble.properties
#
@@ -28,9 +30,15 @@
# When using the 'run' mode, you'll be asked for an email address to associate with any LetsEncrypt
# certificates that will be created.
#
# Upon successful startup, the bubble launcher will be listening on port 8090
# If you'd prefer to use a different port, set the BUBBLE_PORT environment variable.
#
# If you want to run this unattended, set the LETSENCRYPT_EMAIL environment variable
# in your ~/.bubble.env file or in your shell environment.
#
# By default, this does not use the docker cache. If you want to use the cache,
# set the BUBBLE_DOCKER_CACHE environment variable to any value.
#
SCRIPT="${0}"
SCRIPT_DIR="$(cd "$(dirname "${SCRIPT}")" && pwd)"
. "${SCRIPT_DIR}"/bubble_common
@@ -48,39 +56,92 @@ DOCKER_REPO="getbubble"
if [[ -n "${BUBBLE_DOCKER_REPO}" ]] ; then
DOCKER_REPO="${BUBBLE_DOCKER_REPO}"
fi
BUBBLE_TAG="${DOCKER_REPO}/launcher:${VERSION}"
BUBBLE_SLIM_TAG="${DOCKER_REPO}/slim-launcher:${VERSION}"

REPO_LAUNCHER="${DOCKER_REPO}/launcher"
BUBBLE_TAG="${REPO_LAUNCHER}:${VERSION}"

REPO_SLIM_LAUNCHER="${DOCKER_REPO}/slim-launcher"
BUBBLE_SLIM_TAG="${REPO_SLIM_LAUNCHER}:${VERSION}"

BUBBLE_ENV="${HOME}/.bubble.env"

CACHE="--no-cache"
if [[ -n "${BUBBLE_DOCKER_CACHE}" ]] ; then
CACHE=""
fi

EXPOSE=""
if [[ -z "${BUBBLE_PORT}" ]] ; then
BUBBLE_PORT=8090
else
EXPOSE="--expose ${BUBBLE_PORT}"
fi

if [[ "${MODE}" == "build" ]] ; then
if [[ $(find bubble-server/target -type f -name "bubble-server-*-prod.jar" | wc -l | tr -d ' ') -eq 0 ]] ; then
die "No bubble jar found in $(pwd)/bubble-server/target"
fi
docker build --no-cache -t "${BUBBLE_TAG}" . || die "Error building docker image"
docker build --no-cache -f Dockerfile.slim -t "${BUBBLE_SLIM_TAG}" . || die "Error building slim docker image"
docker build ${CACHE} -t "${BUBBLE_TAG}" . || die "Error building docker image"
docker build ${CACHE} -f Dockerfile.slim -t "${BUBBLE_SLIM_TAG}" . || die "Error building slim docker image"

elif [[ "${MODE}" == "run" ]] ; then
# Copy existing env if found
ENV_FILE=$(mktemp /tmp/.bubble.env.XXXXXXX)
if [[ -f "${BUBBLE_ENV}" ]] ; then
cat "${BUBBLE_ENV}" > "${ENV_FILE}"
fi

# Define API port
echo "
export BUBBLE_SERVER_PORT=${BUBBLE_PORT}" >> "${ENV_FILE}"

# Define LetsEncrypt email, from env var or stdin
if [[ $(cat "${BUBBLE_ENV}" | grep -v '^#' | grep -c LETSENCRYPT_EMAIL) -eq 0 ]] ; then
if [[ -z "${LETSENCRYPT_EMAIL}" ]] ; then
echo ; echo -n "Email address for LetsEncrypt certificates: "
read -r LETSENCRYPT_EMAIL
fi
echo "
export LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
" >> "${BUBBLE_ENV}"
export LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}" >> "${ENV_FILE}"
fi
if [[ -n "${BUBBLE_RUN_SLIM}" && "${BUBBLE_RUN_SLIM}" == "true" ]] ; then
RUN_TAG="${BUBBLE_SLIM_TAG}"
else
RUN_TAG="${BUBBLE_TAG}"
fi
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"

DOCKER_ENV_FILE=$(mktemp /tmp/.docker.env.XXXXXX)
cat "${ENV_FILE}" | sed -e 's/export //' | tr -d '"' | tr -d "'" > "${DOCKER_ENV_FILE}"
docker run ${EXPOSE} --env-file "${DOCKER_ENV_FILE}" -p ${BUBBLE_PORT}:${BUBBLE_PORT} -t "${RUN_TAG}"
rm -f "${ENV_FILE}" "${DOCKER_ENV_FILE}"

elif [[ "${MODE}" == "push" ]] ; then
docker push "${BUBBLE_TAG}" || die "Error pushing docker image"
docker push "${BUBBLE_SLIM_TAG}" || die "Error pushing slim docker image"

elif [[ "${MODE}" == "term" ]] ; then
# Expect only one container running that matches BUBBLE_TAG
CONTAINER_CT="$(docker container ls | grep -c "${BUBBLE_TAG}" | tr -d ' ')"
if [[ -z "${CONTAINER_CT}" || "${CONTAINER_CT}" == "0" ]] ; then
die "No docker container found with tag ${BUBBLE_TAG}"
fi
if [[ ${CONTAINER_CT} -gt 1 ]] ; then
die "Multiple docker containers found with tag ${BUBBLE_TAG}"
fi

# Run bash in that container
exec docker exec -it "$(docker container ls | grep "${BUBBLE_TAG}" | awk '{print $1}')" /bin/bash

elif [[ "${MODE}" == "clean" ]] ; then
# Remove containers
docker container ls | grep "${BUBBLE_TAG}" | awk '{print $1}' | xargs docker container rm -f
docker container ls | grep "${BUBBLE_SLIM_TAG}" | awk '{print $1}' | xargs docker container rm -f

# Remove images
docker image ls | grep "${REPO_LAUNCHER}" | grep "${VERSION}" | awk '{print $3}' | xargs docker image rm -f
docker image ls | grep "${REPO_SLIM_LAUNCHER}" | grep "${VERSION}" | awk '{print $3}' | xargs docker image rm -f

else
die "Invalid mode (expected build or run): ${MODE}"
die "$("${0}" --help)
***** invalid mode: ${MODE}"
fi

+ 4
- 0
bubble-server/src/main/java/bubble/cloud/compute/ComputeDeploymentConfig.java Näytä tiedosto

@@ -1,3 +1,7 @@
/**
* Copyright (c) 2020 Bubble, Inc. All rights reserved.
* For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
*/
package bubble.cloud.compute;

import lombok.Getter;


+ 4
- 0
bubble-server/src/main/java/bubble/cloud/compute/docker/DockerComputeDriver.java Näytä tiedosto

@@ -1,3 +1,7 @@
/**
* Copyright (c) 2020 Bubble, Inc. All rights reserved.
* For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
*/
package bubble.cloud.compute.docker;

import bubble.ApiConstants;


+ 4
- 0
bubble-server/src/main/java/bubble/cloud/geoLocation/whois/WhoisConfig.java Näytä tiedosto

@@ -1,3 +1,7 @@
/**
* Copyright (c) 2020 Bubble, Inc. All rights reserved.
* For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
*/
package bubble.cloud.geoLocation.whois;

import lombok.Getter;


+ 4
- 0
bubble-server/src/main/java/bubble/cloud/geoLocation/whois/WhoisGeoLocationDriver.java Näytä tiedosto

@@ -1,3 +1,7 @@
/**
* Copyright (c) 2020 Bubble, Inc. All rights reserved.
* For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
*/
package bubble.cloud.geoLocation.whois;

import bubble.cloud.geoLocation.GeoLocateServiceDriverBase;


+ 1
- 1
bubble-server/src/main/resources/bubble-config.yml Näytä tiedosto

@@ -11,7 +11,7 @@ publicUriBase: {{PUBLIC_BASE_URI}}
openApi:
title: Bubble API Reference
description: This is the Bubble API. It is used by the Bubble web UI, native apps, and CLI tools.<br/><br/>[Learn more about Bubble](https://getbubblenow.com/)<br/><br/>[Bubble Git Server](https://git.bubblev.org/bubblev/)<br/><br/>[Bubble on Github](https://github.com/GetBubbleNow/)
contactEmail: {{OPENAPI_CONTACT_EMAIL}}
contactEmail: {{#exists OPENAPI_CONTACT_EMAIL}}{{{OPENAPI_CONTACT_EMAIL}}}{{else}}no-reply@local.local{{/exists}}
terms: https://getbubblenow.com/terms/
licenseName: Bubble License
licenseUrl: https://getbubblenow.com/bubble-license/


+ 14
- 0
bubble-server/src/main/resources/docker/run_bubble.sh Näytä tiedosto

@@ -2,6 +2,20 @@
#
# Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
#
# Run the Bubble API server. This is intended to be run from within a docker container
#
# This script normally exists as /etc/service/bubble/run on a Bubble launcher docker container
#
# See docs/docker-launcher.md for more information
# Full URL for more info: https://git.bubblev.org/bubblev/bubble/src/branch/master/docs/docker-launcher.md
#

if [[ -n "${BUBBLE_SERVER_PORT}" ]] ; then
echo "export BUBBLE_SERVER_PORT=${BUBBLE_SERVER_PORT}" >> /bubble/bubble.env
echo "export BUBBLE_W00T=w00t" >> /bubble/bubble.env
else
echo "export BUBBLE_LAME0=l4m3" >> /bubble/bubble.env
fi

exec /usr/bin/java \
-Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Dbubble.listenAll=true \


+ 13
- 0
bubble-server/src/main/resources/docker/run_bubble_slim.sh Näytä tiedosto

@@ -2,12 +2,21 @@
#
# Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
#
# Run the Bubble API server. This is intended to be run from within a docker container
#
# This script normally exists as /etc/service/bubble/run on a Bubble launcher docker container
#
# See docs/docker-launcher.md for more information
# Full URL for more info: https://git.bubblev.org/bubblev/bubble/src/branch/master/docs/docker-launcher.md
#

# Install packer
/usr/local/bin/install_packer.sh || (echo "Error ensuring Packer is installed" ; exit 1)

LATEST_BUBBLE_JAR_URL=https://jenkins.bubblev.org/public/releases/bubble/latest/bubble.zip
BUBBLE_JAR=/bubble/bubble.jar

# Download and install the jar if needed
if [[ ! -f ${BUBBLE_JAR} ]] ; then
BUBBLE_JAR_TEMP="$(mktemp ${BUBBLE_JAR}.temp.XXXXXX)"
curl -s ${LATEST_BUBBLE_JAR_URL} > "${BUBBLE_JAR_TEMP}" || (echo "Error downloading bubble.jar from ${LATEST_BUBBLE_JAR_URL}" ; exit 1)
@@ -15,6 +24,10 @@ if [[ ! -f ${BUBBLE_JAR} ]] ; then
mv "$(find /bubble -type f -name bubble.jar)" ${BUBBLE_JAR} || (echo "Error moving bubble.jar into place" ; exit 1)
fi

if [[ -n "${BUBBLE_SERVER_PORT}" ]] ; then
echo "export BUBBLE_SERVER_PORT=${BUBBLE_SERVER_PORT}" >> /bubble/bubble.env
fi

exec /usr/bin/java \
-Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Dbubble.listenAll=true \
-XX:+UseG1GC -XX:MaxGCPauseMillis=400 \


+ 3
- 0
bubble-server/src/main/resources/docker/run_cron.sh Näytä tiedosto

@@ -1,2 +1,5 @@
#!/bin/bash
#
# Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
#
exec cron -f

+ 0
- 1
bubble-server/src/main/resources/docker/run_postgresql.sh Näytä tiedosto

@@ -1,7 +1,6 @@
#!/bin/sh
#
# Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
# adapted from https://stackoverflow.com/q/11092358
#
# This script is run by Supervisor to start PostgreSQL in foreground mode.
#


+ 3
- 0
bubble-server/src/main/resources/docker/run_supervisor.sh Näytä tiedosto

@@ -1,3 +1,6 @@
#!/bin/bash
#
# Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
#
supervisord --nodaemon


+ 1
- 0
bubble-server/src/main/resources/logback.xml Näytä tiedosto

@@ -83,6 +83,7 @@
<!-- <logger name="bubble.resources.notify.InboundNotifyResource" level="TRACE" />-->
<logger name="bubble.client" level="WARN" />
<logger name="bubble.main.rekey" level="INFO" />
<logger name="bubble.server.BubbleServer" level="DEBUG" />
<logger name="bubble" level="INFO" />

<root level="INFO">


+ 3
- 0
bubble-server/src/main/resources/packer/roles/common/tasks/docker.yml Näytä tiedosto

@@ -1,3 +1,6 @@
#
# Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
#
- name: Install packages missing on docker ubuntu
apt:
name: [ 'curl', 'rsync', 'cron', 'iptables', 'redis', 'postgresql', 'supervisor' ]


+ 1
- 1
bubble-web

@@ -1 +1 @@
Subproject commit efab1b4b4bcb15d8cacfd0357810235603b249a6
Subproject commit 2d07f2265973752b7ca9e78c42198f4af0212146

+ 15
- 3
launcher Näytä tiedosto

@@ -197,24 +197,36 @@ Then re-run this script.
fi

# Determine port
EXPOSE=""
if [[ -z "${BUBBLE_PORT}" ]] ; then
BUBBLE_PORT=8090
else
EXPOSE="--expose ${BUBBLE_PORT}"
fi

# Run bubble docker image
if [[ "${CALLER}" == "root" ]] ; then
docker run \
docker run ${EXPOSE} \
-p ${BUBBLE_PORT}:${BUBBLE_PORT} \
-e LETSENCRYPT_EMAIL="${LETSENCRYPT_EMAIL}" \
-e BUBBLE_PORT=${BUBBLE_PORT} \
-t "${DOCKER_TAG}"
else
docker run \
echo "docker run ${EXPOSE} \
-p ${BUBBLE_PORT}:${BUBBLE_PORT} \
-e LETSENCRYPT_EMAIL=\"${LETSENCRYPT_EMAIL}\" \
-e BUBBLE_PORT=${BUBBLE_PORT} \
-t \"${DOCKER_TAG}\"" && exit 0

docker run ${EXPOSE} \
-p ${BUBBLE_PORT}:${BUBBLE_PORT} \
-e LETSENCRYPT_EMAIL="${LETSENCRYPT_EMAIL}" \
-e BUBBLE_PORT=${BUBBLE_PORT} \
-t "${DOCKER_TAG}" || \
echo "***** error running 'docker run' as ${CALLER}, trying via sudo ..." && \
sudo su - "${CALLER}" -c "docker run \
sudo su - "${CALLER}" -c "docker run ${EXPOSE} \
-p ${BUBBLE_PORT}:${BUBBLE_PORT} \
-e BUBBLE_PORT=${BUBBLE_PORT} \
-e LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL} \
-t ${DOCKER_TAG}"
fi


Ladataan…
Peruuta
Tallenna