Add files for build and docker 51/41751/4
authorraag8290 <romain.gimbert@orange.com>
Mon, 9 Apr 2018 14:23:03 +0000 (16:23 +0200)
committerMatthieuGeerebaert <matthieu.geerebaert@orange.com>
Tue, 10 Apr 2018 13:00:16 +0000 (15:00 +0200)
- version.properties
- plugin docker
- application-docker.properties
- docker files
- ready

Change-Id: Ic6884b2df3d31518b70a5d2b8cd1a2fd94d73a15
Issue-ID: EXTAPI-49
Signed-off-by: romaingimbert <romain.gimbert@orange.com>
.maven-dockerignore [new file with mode: 0644]
Dockerfile [new file with mode: 0644]
docker-compose.yml [new file with mode: 0644]
pom.xml
src/main/resources/application-docker.properties [new file with mode: 0644]
version.properties [new file with mode: 0644]

diff --git a/.maven-dockerignore b/.maven-dockerignore
new file mode 100644 (file)
index 0000000..07fa861
--- /dev/null
@@ -0,0 +1 @@
+target/docker/
diff --git a/Dockerfile b/Dockerfile
new file mode 100644 (file)
index 0000000..5f43f6b
--- /dev/null
@@ -0,0 +1,4 @@
+FROM openjdk:8-jdk-alpine
+ADD target/nbi-rest-services-1.0.0-SNAPSHOT.jar app.jar
+ENV JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Dspring.profiles.active=docker -jar"
+ENTRYPOINT exec java $JAVA_OPTS  /app.jar
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644 (file)
index 0000000..e6fbf97
--- /dev/null
@@ -0,0 +1,30 @@
+version: "3.0"
+services:
+  mongo:
+    image: mongo
+    volumes:
+      - /var/lib/mongo
+    ports:
+    - 27017:27017
+    command: --smallfiles
+
+  mariadb:
+    image: mariadb
+    restart: always
+    volumes:
+      - /var/lib/mariadb
+    environment:
+      MYSQL_DATABASE: nbi
+      MYSQL_ROOT_PASSWORD: toto
+# APP  ***************************************************************************************
+  nbi:
+    build: .
+    image: nbi
+    ports:
+    - 8080:8080
+    depends_on:
+    - mariadb
+    - mongo
+volumes:
+  mariadb:
+  mongo:
diff --git a/pom.xml b/pom.xml
index d03e11e..a85cb4c 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -35,6 +35,7 @@
                <relativePath /> <!-- lookup parent from repository -->
        </parent>
 
+
        <properties>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
                <releaseNexusPath>content/repositories/releases/</releaseNexusPath>
                <stagingNexusPath>content/repositories/staging/</stagingNexusPath>
                <java.version>1.8</java.version>
+               <docker.pull.registry>nexus3.onap.org:10001</docker.pull.registry>
+               <docker.push.registry>nexus3.onap.org:10003</docker.push.registry>
+               <timestamp>${maven.build.timestamp}</timestamp>
+               <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
+               <!--docker -->
+               <docker.tag>${project.version}-${timestamp}</docker.tag>
+               <docker.latest.tag>${project.version}-latest</docker.latest.tag>
        </properties>
 
        <repositories>
                <repository>
                        <id>ecomp-snapshots</id>
                        <name>Snapshot Repository</name>
-                       <url>${nexusproxy}/${snapshotNexusPath}</url>
+                       <url>https://nexus.onap.org/content/repositories/releases/</url>
                </repository>
                <repository>
                        <id>ecomp-staging</id>
                        <name>Staging Repository</name>
-                       <url>${nexusproxy}/${stagingNexusPath}</url>
+                       <url>https://nexus.onap.org/content/repositories/staging/</url>
                </repository>
        </repositories>
 
-       <distributionManagement>
-               <repository>
-                       <id>ecomp-releases</id>
-                       <name>Release Repository</name>
-                       <url>${nexusproxy}/${releaseNexusPath}</url>
-               </repository>
-               <snapshotRepository>
-                       <id>ecomp-snapshots</id>
-                       <name>Snapshot Repository</name>
-                       <url>${nexusproxy}/${snapshotNexusPath}</url>
-               </snapshotRepository>
-       </distributionManagement>
-
        <licenses>
                <license>
                        <name>Apache2</name>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                </dependency>
+               <dependency>
+                       <groupId>org.mariadb.jdbc</groupId>
+                       <artifactId>mariadb-java-client</artifactId>
+                       <version>1.1.7</version>
+               </dependency>
 
                <!-- swagger -->
 
                        <scope>test</scope>
                </dependency>
 
-               <!-- test h2 -->
+               <!-- test h2  -->
 
                <dependency>
                        <groupId>com.h2database</groupId>
                        </plugin>
                </plugins>
        </build>
+
+
+
+       <profiles>
+               <profile>
+                       <id>docker</id>
+                       <build>
+                               <plugins>
+                                       <plugin>
+                                               <groupId>io.fabric8</groupId>
+                                               <artifactId>docker-maven-plugin</artifactId>
+                                               <version>0.19.1</version>
+                                               <configuration>
+                                                       <verbose>true</verbose>
+                                                       <apiVersion>1.23</apiVersion>
+                                                       <pullRegistry>${docker.pull.registry}</pullRegistry>
+                                                       <pushRegistry>${docker.push.registry}</pushRegistry>
+                                                       <images>
+                                                               <image>
+                                                                       <name>onap/externalapi/nbi</name>
+                                                                       <alias>onap/externalapi/nbi</alias>
+                                                                       <build>
+                                                                               <cleanup>true</cleanup>
+                                                                               <tags>
+                                                                                       <tag>${docker.tag}</tag>
+                                                                                       <tag>${docker.latest.tag}</tag>
+                                                                               </tags>
+                                                                               <dockerFileDir>${project.basedir}</dockerFileDir>
+                                                                       </build>
+                                                               </image>
+                                                       </images>
+                                               </configuration>
+                                               <executions>
+                                                       <execution>
+                                                               <id>clean-images</id>
+                                                               <phase>pre-clean</phase>
+                                                               <goals>
+                                                                       <goal>remove</goal>
+                                                               </goals>
+                                                               <configuration>
+                                                                       <removeAll>true</removeAll>
+                                                                       <image>nbi</image>
+                                                               </configuration>
+                                                       </execution>
+                                                       <execution>
+                                                               <id>generate-images</id>
+                                                               <phase>package</phase>
+                                                               <goals>
+                                                                       <goal>build</goal>
+                                                               </goals>
+                                                       </execution>
+                                                       <execution>
+                                                               <id>push-images</id>
+                                                               <phase>deploy</phase>
+                                                               <goals>
+                                                                       <goal>push</goal>
+                                                               </goals>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
+                               </plugins>
+                       </build>
+               </profile>
+       </profiles>
+
 </project>
diff --git a/src/main/resources/application-docker.properties b/src/main/resources/application-docker.properties
new file mode 100644 (file)
index 0000000..01070d4
--- /dev/null
@@ -0,0 +1,48 @@
+# LOGGING
+logging.level.org.onap.nbi=INFO
+
+# ONAP
+onap.lcpCloudRegionId=RegionOne
+onap.tenantId=31047205ce114b60833b23e400d6a535
+onap.cloudOwner=CloudOwner
+
+# NBI
+nbi.url=http://127.0.0.1:8080/nbi/api/v1
+nbi.callForVNF=false
+
+# SDC
+sdc.host=http://127.0.0.1:8090
+sdc.header.ecompInstanceId=Rene
+sdc.header.authorization=Basic YWFpOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2YW9HR21KdlV5MlU=
+
+# AAI
+aai.host=http://127.0.0.1:8090
+aai.header.authorization=Basic QUFJOkFBSQ==
+aai.api.id=AAI
+
+# SO
+so.host=http://127.0.0.1:8090
+so.header.authorization=
+so.api.id=SO
+
+# MONGO
+spring.data.mongodb.uri=mongodb://mongo:27017/ServiceOrderDB
+
+# MYSQL
+spring.datasource.testWhileIdle=true
+spring.datasource.validationQuery=SELECT 1
+spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
+spring.datasource.url=jdbc:mariadb://mariadb:3306/nbi
+spring.jpa.show-sql=false
+spring.datasource.username=root
+spring.datasource.password=toto
+spring.jpa.hibernate.ddl-auto=create-drop
+spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy
+
+# H2
+# spring.datasource.url=jdbc:h2:mem:~/db
+# spring.datasource.username=sa
+# spring.datasource.password=
+# spring.datasource.driver-class-name=org.h2.Driver
+# spring.h2.console.enabled=true
+# spring.h2.console.path=/h2-console
\ No newline at end of file
diff --git a/version.properties b/version.properties
new file mode 100644 (file)
index 0000000..d3e09bb
--- /dev/null
@@ -0,0 +1,13 @@
+# Versioning variables
+# Note that these variables cannot be structured (e.g. : version.release or version.snapshot etc... )
+# because they are used in Jenkins, whose plug-in doesn't support...
+
+major=1
+minor=2
+patch=1
+
+base_version=${major}.${minor}.${patch}
+
+# Release must be completed with git revision # in Jenkins
+release_version=${base_version}
+snapshot_version=${base_version}-SNAPSHOT