Skip to content
This repository has been archived by the owner on Dec 14, 2019. It is now read-only.

Commit

Permalink
Rewrite Dockerfile and merge both images
Browse files Browse the repository at this point in the history
Also refactored deploy script.
  • Loading branch information
arkocal authored and wagmarcel committed Jun 15, 2018
1 parent c441ac3 commit 08f0a42
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 47 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.dockerignore
Dockerfile
33 changes: 30 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,39 @@ FROM jamesdbloom/docker-java8-maven

RUN apt-get update -qq && apt-get install -y build-essential python-setuptools

ADD pom.xml /app/pom.xml
ADD src /app/src

WORKDIR /app

RUN mvn clean install -DskipTests




FROM ubuntu:xenial
RUN apt-get update -qq && apt-get upgrade -y

RUN apt-get install -y curl unzip openjdk-8-jre-headless python-setuptools

RUN curl --location --retry 3 --insecure https://github.com/gearpump/gearpump/releases/download/0.8.0/gearpump-2.11-0.8.0.zip -o tmp.zip && unzip -q tmp.zip && rm tmp.zip && chmod +x gearpump-2.11-0.8.0/bin/*

ADD gear.conf gearpump-2.11-0.8.0/conf/gear.conf

RUN sed -i -e "s/gearpump.root.logger=RollingFileAppender/gearpump.root.logger=RollingFileAppender,console/g" gearpump-2.11-0.8.0/conf/log4j.properties
RUN sed -i -e "s/gearpump.application.logger=ApplicationLogAppender/gearpump.application.logger=ApplicationLogAppender,console/g" gearpump-2.11-0.8.0/conf/log4j.properties

EXPOSE 8090

RUN easy_install poster
RUN easy_install requests
RUN easy_install pip
RUN pip install kafka-python

ADD . /app
COPY --from=0 /app/ /app
RUN chmod +x /app/bootstrap.sh

WORKDIR /app

RUN mvn clean install -DskipTests
WORKDIR /app/
# CMD ["bash", "bootstrap.sh"]
CMD bash
12 changes: 0 additions & 12 deletions Dockerfile-gearpump

This file was deleted.

6 changes: 6 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source /app/target/classes/resources/version.properties &&
export RULE_ENGINE_PACKAGE_NAME=gearpump-rule-engine-${VERSION}-jar-with-dependencies.jar &&

/app/wait-for-it.sh localhost:8090 -t 300 -- /app/local-deploy.sh &

/gearpump-2.11-0.8.0/bin/local & /gearpump-2.11-0.8.0/bin/services
60 changes: 33 additions & 27 deletions deployer/src/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015 Intel Corporation
# Copyright (c) 2015-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -11,46 +11,52 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Deploy gearpump application locally

import argparse
Application is a jar located at $RULE_ENGINE_PACKAGE_NAME,
Gearpump must run locally, port number is read from $GEARPUMP,
which stores a whole URL.
"""
import os

import time

import cloudfoundry_bridge
from gearpump_api import GearpumpApi

from kafka import KafkaConsumer

def main():

parser = argparse.ArgumentParser()
parser.add_argument("--local", action="store_true")
args = parser.parse_args()

cloud_bridge = cloudfoundry_bridge.CloudfoundryBridge()

config = cloud_bridge.build_config(local=args.local)

gearpump_api = GearpumpApi(uri=cloud_bridge.gearpump_dashboard_url, credentials=cloud_bridge.gearpump_credentials)
import cloudfoundry_bridge

rule_engine_jar_name = os.environ['RULE_ENGINE_PACKAGE_NAME']
def wait_for_frontend():
"""Wait for OISP frontend hearbeat."""
kafka_server = os.environ["KAFKA"]
heartbeat_topic = os.environ["KAFKA_HEARTBEAT_TOPIC"]
consumer = KafkaConsumer(heartbeat_topic, bootstrap_servers=kafka_server,
auto_offset_reset='latest')

consumer = KafkaConsumer(config['kafka_heartbeat_topic'], bootstrap_servers=config['kafka_servers'], auto_offset_reset='latest')

for message in consumer:
# Frontend heartbeat message is dashboard for historical reasons
if message.value == "dashboard":
break

print 'Submitting application - %s into gearpump ...' % rule_engine_jar_name
print("Frontend is up")

gearpump_api.submit_app(filename=rule_engine_jar_name, app_name=config['application_name'], gearpump_app_config=config, force=True)

break
def main():
"""Deploy app to local gearpump instance."""
rule_engine_jar_name = os.environ['RULE_ENGINE_PACKAGE_NAME']

# Cloudfoundry needs frontend
wait_for_frontend()
cloud_bridge = cloudfoundry_bridge.CloudfoundryBridge()
config = cloud_bridge.build_config(local=True)

# We are only interested in port number because we deploy locally
gearpump_port = os.environ["GEARPUMP"].split(":")[1]
gearpump_api = GearpumpApi(uri="http://localhost:{}".format(gearpump_port),
credentials=cloud_bridge.gearpump_credentials)
print("Submitting application '{}' into gearpump ...".format(rule_engine_jar_name))
gearpump_api.submit_app(filename=rule_engine_jar_name,
app_name=config['application_name'],
gearpump_app_config=config, force=True)

if not args.local:
while True:
time.sleep(60)

if __name__ == "__main__":
main()
5 changes: 2 additions & 3 deletions local-deploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (c) 2016 Intel Corporation
# Copyright (c) 2016-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,8 +14,7 @@
# limitations under the License.
#

mvn clean install &&
source target/classes/resources/version.properties &&
export RULE_ENGINE_PACKAGE_NAME=gearpump-rule-engine-${VERSION}-jar-with-dependencies.jar &&
cd deployer &&
python src/app.py --local
python src/app.py
3 changes: 1 addition & 2 deletions local-push-to-gearpump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@
source target/classes/resources/version.properties &&
export RULE_ENGINE_PACKAGE_NAME=gearpump-rule-engine-${VERSION}-jar-with-dependencies.jar &&
cd deployer &&
pip install kafka-python &&
python src/app.py --local
python src/app.py --local

0 comments on commit 08f0a42

Please sign in to comment.