From abf88f3e93f86f6e0639290a399b05db9b9c6097 Mon Sep 17 00:00:00 2001 From: YongchaoWu Date: Thu, 12 Dec 2019 20:45:12 +0100 Subject: [PATCH 1/1] add mvn plugin for dockerfile build run: mvn dockerfile:build, to build docker image locally for testing Issue-ID: NONRTRIC-79 Change-Id: I5812a7c863625a0a7e29be9491002c9ef558e713 Signed-off-by: YongchaoWu --- policy-agent/Dockerfile | 35 ++++++++++++++++++++++ policy-agent/config/application.yaml | 2 +- policy-agent/pom.xml | 15 ++++++++-- .../org/oransc/policyagent/repository/Ric.java | 3 +- .../oransc/policyagent/tasks/StartupService.java | 1 + .../configuration/ApplicationConfigTest.java | 4 +++ .../policyagent/tasks/StartupServiceTest.java | 1 + 7 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 policy-agent/Dockerfile diff --git a/policy-agent/Dockerfile b/policy-agent/Dockerfile new file mode 100644 index 00000000..7119f071 --- /dev/null +++ b/policy-agent/Dockerfile @@ -0,0 +1,35 @@ +# +# ============LICENSE_START======================================================= +# Copyright (C) 2019 Nordix Foundation. +# ================================================================================ +# 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= +# +FROM adoptopenjdk/openjdk11:latest + +WORKDIR /opt/app/policy-agent +RUN mkdir -p /var/log/policy-agent +RUN mkdir -p /opt/app/policy-agent/etc/cert/ + + +ADD /config/application.yaml /opt/app/policy-agent/config/ +ADD /target/policy-agent-1.0.0-SNAPSHOT.jar /opt/app/policy-agent/ + + +RUN chmod -R 777 /opt/app/policy-agent/config/ + +ENTRYPOINT ["/usr/bin/java", "-jar", "/opt/app/policy-agent/policy-agent-1.0.0-SNAPSHOT.jar"] + + diff --git a/policy-agent/config/application.yaml b/policy-agent/config/application.yaml index ee59a268..776afd7f 100644 --- a/policy-agent/config/application.yaml +++ b/policy-agent/config/application.yaml @@ -16,6 +16,6 @@ logging: org.springframework.data: ERROR org.springframework.web.reactive.function.client.ExchangeFunctions: ERROR org.onap.dcaegen2.collectors.datafile: WARN - file: /var/log/ONAP/application.log + file: /var/log/policy-agent/application.log app: filepath: /opt/app/policy-agent/config/application_configuration.json diff --git a/policy-agent/pom.xml b/policy-agent/pom.xml index 5ab2663b..a4388706 100644 --- a/policy-agent/pom.xml +++ b/policy-agent/pom.xml @@ -23,9 +23,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework + org.oransc policy-agent - 0.0.0 + 1.0.0-SNAPSHOT The Apache Software License, Version 2.0 @@ -174,6 +174,17 @@ false + + com.spotify + dockerfile-maven-plugin + + oransc/policy-agent + ${project.version} + + ${project.build.finalName}.jar + + + org.codehaus.mojo build-helper-maven-plugin diff --git a/policy-agent/src/main/java/org/oransc/policyagent/repository/Ric.java b/policy-agent/src/main/java/org/oransc/policyagent/repository/Ric.java index 7580bf8e..3caadaed 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/repository/Ric.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/repository/Ric.java @@ -23,6 +23,7 @@ package org.oransc.policyagent.repository; import java.util.Collections; import java.util.List; import java.util.Vector; + import org.oransc.policyagent.configuration.RicConfig; import org.oransc.policyagent.repository.Ric.RicState; @@ -139,7 +140,7 @@ public class Ric { * * @param type the type to check if it is supported. * - * @return true if the given type issupported by this Ric, false otherwise. + * @return true if the given type issupported by this Ric, false otherwise. */ public boolean isSupportingType(PolicyType type) { return supportedPolicyTypes.contains(type); diff --git a/policy-agent/src/main/java/org/oransc/policyagent/tasks/StartupService.java b/policy-agent/src/main/java/org/oransc/policyagent/tasks/StartupService.java index a6accbbf..1fa0aa81 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/tasks/StartupService.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/tasks/StartupService.java @@ -21,6 +21,7 @@ package org.oransc.policyagent.tasks; import java.util.Vector; + import org.oransc.policyagent.clients.RicClient; import org.oransc.policyagent.configuration.ApplicationConfig; import org.oransc.policyagent.configuration.RicConfig; diff --git a/policy-agent/src/test/java/org/oransc/policyagent/configuration/ApplicationConfigTest.java b/policy-agent/src/test/java/org/oransc/policyagent/configuration/ApplicationConfigTest.java index 830a821c..34ebdf99 100644 --- a/policy-agent/src/test/java/org/oransc/policyagent/configuration/ApplicationConfigTest.java +++ b/policy-agent/src/test/java/org/oransc/policyagent/configuration/ApplicationConfigTest.java @@ -31,12 +31,14 @@ import static org.mockito.Mockito.verify; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.read.ListAppender; + import com.google.common.base.Charsets; import com.google.common.io.Resources; import com.google.gson.JsonIOException; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.JsonSyntaxException; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -46,6 +48,7 @@ import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Properties; import java.util.Vector; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsClient; @@ -53,6 +56,7 @@ import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.EnvProperti import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.ImmutableEnvProperties; import org.oransc.policyagent.exceptions.ServiceException; import org.oransc.policyagent.utils.LoggingUtils; + import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/policy-agent/src/test/java/org/oransc/policyagent/tasks/StartupServiceTest.java b/policy-agent/src/test/java/org/oransc/policyagent/tasks/StartupServiceTest.java index d08077f1..4dcceb6c 100644 --- a/policy-agent/src/test/java/org/oransc/policyagent/tasks/StartupServiceTest.java +++ b/policy-agent/src/test/java/org/oransc/policyagent/tasks/StartupServiceTest.java @@ -30,6 +30,7 @@ import static org.mockito.Mockito.when; import static org.oransc.policyagent.repository.Ric.RicState.ACTIVE; import java.util.Vector; + import org.junit.jupiter.api.Test; import org.oransc.policyagent.clients.RicClient; import org.oransc.policyagent.configuration.ApplicationConfig; -- 2.16.6