From 3fb91dc34bcde5489681f6470cae7f01c8b246d0 Mon Sep 17 00:00:00 2001 From: Andrew Gauld Date: Tue, 21 Jan 2020 14:47:38 +0000 Subject: runtimeapi & genprocessor pom.xml docker changes Change-Id: I1595bf1c08dae161530c4dcdbc3e53b909164a10 Issue-ID: DCAEGEN2-1860 Signed-off-by: Andrew Gauld --- mod/genprocessor/docker/README.md | 51 ---- mod/genprocessor/docker/http/Dockerfile | 6 - mod/genprocessor/docker/http/nginx.conf | 22 -- mod/genprocessor/docker/http/start.sh | 24 -- mod/genprocessor/docker/job/Dockerfile | 15 -- mod/genprocessor/nginx.conf | 22 ++ mod/genprocessor/pom.xml | 275 ++++++++++----------- .../main/java/org/onap/dcae/genprocessor/App.java | 25 +- mod/runtimeapi/runtime-web/Dockerfile | 10 - mod/runtimeapi/runtime-web/pom.xml | 31 ++- 10 files changed, 206 insertions(+), 275 deletions(-) delete mode 100644 mod/genprocessor/docker/README.md delete mode 100644 mod/genprocessor/docker/http/Dockerfile delete mode 100644 mod/genprocessor/docker/http/nginx.conf delete mode 100755 mod/genprocessor/docker/http/start.sh delete mode 100644 mod/genprocessor/docker/job/Dockerfile create mode 100644 mod/genprocessor/nginx.conf delete mode 100644 mod/runtimeapi/runtime-web/Dockerfile diff --git a/mod/genprocessor/docker/README.md b/mod/genprocessor/docker/README.md deleted file mode 100644 index 47bdc14..0000000 --- a/mod/genprocessor/docker/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# Genprocessor: Docker - -`http` - http server that serves up the DCAE Nifi jars as files under the path `/nifi-jars` -`job` - background job that continuously polls the onboarding API for components and generates jars from components - -The usage here will assume the use of a docker volume to persist data. - -Create a volume: - -``` -docker volume create genprocessor -``` - -## job - -Build: - -``` -$ cd ../ -$ docker build -t genprocessor-job -f docker/job/Dockerfile . -``` - -Run: - -``` -docker run -v genprocessor:/work -e GENPROC_ONBOARDING_API_HOST=http://some-hostname/onboarding -d genprocessor-job -``` - -NOTE: Above onboarding API is to the one running in iLab. - -Run as part of the stack: - -``` -docker run -v genprocessor:/work --link onboarding-api:onboarding-api -d genprocessor-job -``` - -## http - -Build: - -``` -$ cd http -$ docker build -t genprocessor-http . -``` - -Run: - -``` -$ docker run -p 8080:80 -d -v genprocessor:/www/data:ro genprocessor-http -``` - diff --git a/mod/genprocessor/docker/http/Dockerfile b/mod/genprocessor/docker/http/Dockerfile deleted file mode 100644 index 0cafbf4..0000000 --- a/mod/genprocessor/docker/http/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM nginx:latest - -COPY nginx.conf /etc/nginx/conf.d/default.conf -COPY start.sh /code/start.sh - -CMD /code/start.sh diff --git a/mod/genprocessor/docker/http/nginx.conf b/mod/genprocessor/docker/http/nginx.conf deleted file mode 100644 index bd53c07..0000000 --- a/mod/genprocessor/docker/http/nginx.conf +++ /dev/null @@ -1,22 +0,0 @@ -server { - listen 80; - server_name localhost; - - location / { - root /usr/share/nginx/html; - index index.html index.htm; - } - - # redirect server error pages to the static page /50x.html - # - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /usr/share/nginx/html; - } - - location /nifi-jars { - root /www/data; - autoindex on; - autoindex_format json; - } -} diff --git a/mod/genprocessor/docker/http/start.sh b/mod/genprocessor/docker/http/start.sh deleted file mode 100755 index 45ff3e9..0000000 --- a/mod/genprocessor/docker/http/start.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# ============LICENSE_START======================================================= -# Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# ============LICENSE_END========================================================= - -if [ -d "/www/data/nifi-jars" ]; then - nginx -g "daemon off;" -else - echo "\"/www/data/nifi-jars\" directory missing" - echo "You must perform a volume mount to this directory in the container" - exit 1 -fi diff --git a/mod/genprocessor/docker/job/Dockerfile b/mod/genprocessor/docker/job/Dockerfile deleted file mode 100644 index b70a06c..0000000 --- a/mod/genprocessor/docker/job/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM maven:3-jdk-8 - -COPY . /code -WORKDIR /code -RUN mvn package dependency:copy-dependencies -ENV GENPROC_WORKING_DIR=/work -ENV GENPROC_ONBOARDING_API_HOST=http://onboarding-api/onboarding -ENV GENPROC_PROCESSOR_CLASSFILE_PATH=/code/target/classes/sandbox/DCAEProcessor.class -ENV GENPROC_SLEEP_SEC=10 - -ENV _RUN_COMMAND="java -cp \"target/genprocessor-1.0.1.jar:target/dependency/*\" sandbox.App gen" -RUN printf "#!/bin/bash\nwhile true\ndo\n\t$_RUN_COMMAND\n\tsleep $GENPROC_SLEEP_SEC\ndone" > /code/run.sh \ - & chmod +x /code/run.sh - -CMD /code/run.sh diff --git a/mod/genprocessor/nginx.conf b/mod/genprocessor/nginx.conf new file mode 100644 index 0000000..bd53c07 --- /dev/null +++ b/mod/genprocessor/nginx.conf @@ -0,0 +1,22 @@ +server { + listen 80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + + location /nifi-jars { + root /www/data; + autoindex on; + autoindex_format json; + } +} diff --git a/mod/genprocessor/pom.xml b/mod/genprocessor/pom.xml index 6caf715..3b916ca 100644 --- a/mod/genprocessor/pom.xml +++ b/mod/genprocessor/pom.xml @@ -2,55 +2,52 @@ - 4.0.0 - - org.onap.oparent - oparent - 2.0.0 - - org.onap.dcaegen2.platform.mod - genprocessor - 1.0.0 - dcaegen2-platform-mod-genprocessor - - UTF-8 - true - 1.8 - yyyyMMdd'T'HHmmss - + 4.0.0 + + org.onap.oparent + oparent + 2.0.0 + + org.onap.dcaegen2.platform.mod + genprocessor + 1.0.0 + dcaegen2-platform-mod-genprocessor + + UTF-8 + true + 1.8 + yyyyMMdd'T'HHmmss + nexus3.onap.org:10001 + ${env.NEXUS3_PUSH_REGISTRY} + org.onap.dcae.genprocessor.App + + 1.9.2 + - - org.apache.nifi - nifi-api - 1.9.2 + org.apache.nifi + nifi-api + ${nifi.version} - org.apache.nifi - nifi-record-serialization-service-api - 1.9.2 + org.apache.nifi + nifi-record-serialization-service-api + ${nifi.version} - org.apache.nifi - nifi-record - 1.9.2 + org.apache.nifi + nifi-record + ${nifi.version} - org.apache.nifi - nifi-processor-utils - 1.9.2 + org.apache.nifi + nifi-processor-utils + ${nifi.version} - org.apache.nifi - nifi-utils - 1.9.2 - - - junit - junit - 4.11 - test + org.apache.nifi + nifi-utils + ${nifi.version} org.javassist @@ -58,120 +55,114 @@ 3.25.0-GA - ch.qos.logback - logback-classic - 1.2.3 + ch.qos.logback + logback-classic + 1.2.3 - com.fasterxml.jackson.core - jackson-core - 2.10.0.pr1 + com.fasterxml.jackson.core + jackson-core + 2.10.0.pr1 - com.fasterxml.jackson.core - jackson-databind - 2.10.0.pr1 + com.fasterxml.jackson.core + jackson-databind + 2.10.0.pr1 org.apache.commons commons-text 1.7 + + junit + junit + 4.11 + test + - - - - - - maven-clean-plugin - 3.1.0 - - - - maven-resources-plugin - 3.0.2 - - - maven-compiler-plugin - 3.8.0 - - - maven-surefire-plugin - 2.22.1 - - - maven-jar-plugin - 3.0.2 - - - - true - lib/ - org.onap.dcae.genprocessor.App - - - - - - maven-install-plugin - 2.5.2 - - - maven-deploy-plugin - 2.8.2 - - true - - - - - maven-site-plugin - 3.7.1 - - - maven-project-info-reports-plugin - 3.0.0 - - - maven-assembly-plugin - - - package - - single - - - - - - jar-with-dependencies - - - - true - lib/ - org.onap.dcae.genprocessor.App - - - - - - - maven-dependency-plugin - - - package - - copy-dependencies - - - ${project.build.directory}/lib - - - - - - + + + io.fabric8 + docker-maven-plugin + + true + ${docker.pull.registry} + ${docker.push.registry} + + + onap/${project.groupId}.${project.artifactId}-http + ${onap.nexus.dockerregistry.daily} + + nginx:latest + + latest + ${project.version} + ${project.version}-${maven.build.timestamp}Z + + + / + + + + ./nginx.conf + /etc/nginx/conf.d + default.conf + + + + + + + nginx + -g + daemon off; + + + + + + onap/${project.groupId}.${project.artifactId}-job + ${onap.nexus.dockerregistry.daily} + + openjdk:8-jre-alpine + + latest + ${project.version} + ${project.version}-${maven.build.timestamp}Z + + + artifact-with-dependencies + + /maven + + /work + http://onboarding-api/onboarding + /code/target/classes/sandbox/DCAEPROCESSOR.class + 10 + + + + java + -cp + /maven/* + ${start-class} + + + + + + + + + + build + push + + + + + diff --git a/mod/genprocessor/src/main/java/org/onap/dcae/genprocessor/App.java b/mod/genprocessor/src/main/java/org/onap/dcae/genprocessor/App.java index 9996b71..7cee8b0 100644 --- a/mod/genprocessor/src/main/java/org/onap/dcae/genprocessor/App.java +++ b/mod/genprocessor/src/main/java/org/onap/dcae/genprocessor/App.java @@ -308,13 +308,34 @@ public class App { return false; } - public static void main(String[] args) { + public static void main(String[] args) throws InterruptedException { if (args.length == 0) { + args = new String[] { "gen" }; + String sleepstr = System.getenv("GENPROC_SLEEP_SEC"); + long sleepdur = (sleepstr != null)? 1000 * Long.parseLong(sleepstr): 0; + do { + try { + main2(args); + } catch (Exception e) { + LOG.error(e.toString(), e); + } + Thread.sleep(sleepdur); + } while (sleepdur > 0); + return; + } else { + main2(args); + } + } + + + public static void main2(String[] args) { + String argsStr = String.join(", ", args); + if (argsStr.contains("-h")) { LOG.info("Here are the possible args:"); LOG.info(" "); + return; } - String argsStr = String.join(", ", args); boolean shouldGenerate = argsStr.contains("gen") ? true : false; boolean shouldLoad = argsStr.contains("load") ? true : false; boolean shouldPackage = argsStr.contains("package") ? true : false; diff --git a/mod/runtimeapi/runtime-web/Dockerfile b/mod/runtimeapi/runtime-web/Dockerfile deleted file mode 100644 index 5d17d41..0000000 --- a/mod/runtimeapi/runtime-web/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM openjdk:8-jre-alpine -WORKDIR /usr/app -VOLUME /tmp -ADD target/runtime-web-1.0.0.jar runtime-web-1.0.0.jar - -EXPOSE 9090 - -ENTRYPOINT ["java", \ - "-Djava.security.egd=file:/dev/./urandom", \ - "-jar", "runtime-web-1.0.0.jar"] diff --git a/mod/runtimeapi/runtime-web/pom.xml b/mod/runtimeapi/runtime-web/pom.xml index 27cc960..3b39845 100644 --- a/mod/runtimeapi/runtime-web/pom.xml +++ b/mod/runtimeapi/runtime-web/pom.xml @@ -66,25 +66,50 @@ org.springframework.boot spring-boot-maven-plugin + + + + repackage + + + io.fabric8 docker-maven-plugin true - IfNotPresent + ${docker.pull.registry} + ${docker.push.registry} onap/${project.groupId}.${project.artifactId} ${onap.nexus.dockerregistry.daily} - ${project.basedir} - none + openjdk:8-jre-alpine latest ${project.version} ${project.version}-${maven.build.timestamp}Z + + artifact + + /maven + + /tmp + + + 9090 + + + + java + -Djava.security.egd=file:/dev/./urandom + -jar + ${project.artifactId}-${project.version}.${project.packaging} + + -- cgit 1.2.3-korg