Преглед изворни кода

enable launcher to run within docker container

tags/v1.4.4
Jonathan Cobb пре 4 година
родитељ
комит
fd85f9aa58
8 измењених фајлова са 127 додато и 2 уклоњено
  1. +40
    -0
      Dockerfile
  2. +1
    -1
      bubble-server/src/main/java/bubble/ApiConstants.java
  3. +4
    -1
      bubble-server/src/main/java/bubble/server/BubbleServer.java
  4. +0
    -0
     
  5. +45
    -0
      docker/bubble.sh
  6. +11
    -0
      docker/run_bubble.sh
  7. +21
    -0
      docker/run_postgresql.sh
  8. +5
    -0
      docker/run_redis.sh

+ 40
- 0
Dockerfile Прегледај датотеку

@@ -0,0 +1,40 @@
#
# Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
#
FROM phusion/baseimage:focal-1.0.0alpha1-amd64
MAINTAINER jonathan@getbubblenow.com
LABEL maintainer="jonathan@getbubblenow.com"
LABEL license="https://getbubblenow.com/license"

RUN apt update -y
RUN DEBIAN_FRONTEND=noninteractive apt upgrade -y --no-install-recommends
RUN DEBIAN_FRONTEND=noninteractive apt install openjdk-11-jre-headless postgresql redis-server jq python3 python3-pip curl unzip -y --no-install-recommends
RUN DEBIAN_FRONTEND=noninteractive apt install xtail -y --no-install-recommends
RUN pip3 install setuptools psycopg2-binary

RUN bash -c "sed -i -e 's/daemonize yes/daemonize no/g' /etc/redis/redis.conf"

RUN bash -c "sed -i -e 's/ md5/ trust/g' $(find /etc/postgresql -mindepth 1 -maxdepth 1 -type d | sort | tail -1)/main/pg_hba.conf"
RUN bash -c "service postgresql start && sleep 5s && service postgresql status && \
su - postgres bash -c 'createuser -h 127.0.0.1 -U postgres --createdb --createrole --superuser root' && \
su - postgres bash -c 'createuser -h 127.0.0.1 -U postgres --createdb bubble'"

RUN mkdir /etc/service/postgresql
COPY docker/run_postgresql.sh /etc/service/postgresql/run

RUN mkdir /etc/service/redis
COPY docker/run_redis.sh /etc/service/redis/run

RUN mkdir /bubble
COPY bin/install_packer.sh /usr/local/bin/
RUN /usr/local/bin/install_packer.sh

COPY bubble-server/target/bubble-server-*.jar /bubble/bubble.jar
COPY docker/bubble.env /bubble/bubble.env

RUN mkdir /etc/service/bubble
COPY docker/run_bubble.sh /etc/service/bubble/run

EXPOSE 8090

CMD ["/sbin/my_init"]

+ 1
- 1
bubble-server/src/main/java/bubble/ApiConstants.java Прегледај датотеку

@@ -119,7 +119,7 @@ public class ApiConstants {
static {
final String userHome = System.getProperty("user.home");
final String envHome = System.getenv("HOME");
if (!userHome.equals(envHome)) {
if (envHome != null && !userHome.equals(envHome)) {
log.warn("System.getProperty(\"user.home\") == "+userHome+" differs from System.getenv(\"HOME\") == "+envHome+", using HOME from environment: "+envHome);
HOME_DIR = envHome;
} else {


+ 4
- 1
bubble-server/src/main/java/bubble/server/BubbleServer.java Прегледај датотеку

@@ -37,6 +37,7 @@ import static org.cobbzilla.util.daemon.ZillaRuntime.die;
import static org.cobbzilla.util.daemon.ZillaRuntime.empty;
import static org.cobbzilla.util.io.FileUtil.abs;
import static org.cobbzilla.util.json.JsonUtil.json;
import static org.cobbzilla.util.network.NetworkUtil.IPv4_ALL_ADDRS;
import static org.cobbzilla.util.network.NetworkUtil.IPv4_LOCALHOST;
import static org.cobbzilla.util.system.OutOfMemoryErrorUncaughtExceptionHandler.EXIT_ON_OOME;

@@ -74,7 +75,9 @@ public class BubbleServer extends RestServerBase<BubbleConfiguration> {
restoreKey.set(null);
}

@Override protected String getListenAddress() { return IPv4_LOCALHOST; }
@Override protected String getListenAddress() { return listenAll() ? IPv4_ALL_ADDRS : IPv4_LOCALHOST; }

private boolean listenAll() { return Boolean.parseBoolean(System.getProperty("bubble.listenAll")); }

// config is loaded from the classpath
public static void main(String[] args) throws Exception {



+ 45
- 0
docker/bubble.sh Прегледај датотеку

@@ -0,0 +1,45 @@
#!/bin/bash
#
# Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
#
# Build or run a docker container for a Bubble launcher
#
# -- Building a Docker image:
#
# bubble.sh build [tag-name]
#
# tag-name : name of the docker tag to apply, default is bubble/bubble_launcher:X
#
# -- Running a Docker image:
#
# bubble.sh run [tag-name]
#
# tag-name : name of the docker tag to use, default is bubble/bubble_launcher:X
#

function die {
echo 1>&2 "${1}"
exit 1
}

THISDIR="$(cd "$(dirname "${0}")" && pwd)"
cd "${THISDIR}/.." || die "Directory not found: ${THISDIR}/.."

DEFAULT_TAG="bubble/bubble_launcher:0.2"

MODE=${1:?no mode specified, use build or run}
TAG=${2:-${DEFAULT_TAG}}

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 bubble/test:0.1 .

elif [[ "${MODE}" == "run" ]] ; then
docker run --env-file <(cat "${HOME}/.bubble.env" | sed -e 's/export //' | tr -d '"' | tr -d "'") -p 8090:8090 -t bubble/test:0.1

else
die "Invalid mode (expected build or run): ${MODE}"
fi


+ 11
- 0
docker/run_bubble.sh Прегледај датотеку

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

/usr/bin/java \
-Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Dbubble.listenAll=true \
-XX:+UseG1GC -XX:MaxGCPauseMillis=400 \
-cp /bubble/bubble.jar \
bubble.server.BubbleServer \
/bubble/bubble.env

+ 21
- 0
docker/run_postgresql.sh Прегледај датотеку

@@ -0,0 +1,21 @@
#!/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
#
# If you have more than one PostgreSQL version installed, there could be problems.
# This script assumes you have only one version installed

if [ -d /var/run/postgresql ]; then
chmod 2775 /var/run/postgresql
else
install -d -m 2775 -o postgres -g postgres /var/run/postgresql
fi

exec su postgres -c "$(find $(find /usr/lib/postgresql -type d -name bin | head -1) -type f -name postgres | head -1) \
-D $(find /usr/lib/postgresql -type d -name main | head -1) \
-c config_file=$(find /etc/postgresql -type d -name main | head -1)/postgresql.conf"

+ 5
- 0
docker/run_redis.sh Прегледај датотеку

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

Loading…
Откажи
Сачувај