summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio David Gasparini <claudio.gasparini@pantheon.tech>2020-11-08 22:18:36 +0100
committerClaudio David Gasparini <claudio.gasparini@pantheon.tech>2020-11-10 11:54:44 +0000
commit900ba02f458b3b7adc593f57d1e7447ce6cce142 (patch)
treec3b404b9237d918940a8d681ebbf92154bbe28bc
parent1bd1c6c8ad38d1df70f93c25f82321faa06ae8fc (diff)
Dockerize the service
- automatically generate docker image - provide docker-compose to start the service together with dockerized postgres db Issue-ID: CPS-22 Signed-off-by: Claudio David Gasparini <claudio.gasparini@pantheon.tech> Change-Id: I846d14e87de50bfb1411e0c9b49e9f6c6cc8ebda
-rw-r--r--Dockerfile1
-rw-r--r--cps-parent/pom.xml42
-rw-r--r--cps-rest/pom.xml4
-rw-r--r--docker-compose/README.md3
-rw-r--r--docker-compose/docker-compose.yml26
5 files changed, 75 insertions, 1 deletions
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index 81fdf16d37..0000000000
--- a/Dockerfile
+++ /dev/null
@@ -1 +0,0 @@
-FROM openjdk:11-jre-slim \ No newline at end of file
diff --git a/cps-parent/pom.xml b/cps-parent/pom.xml
index 0fe2e101a5..ea9c98af66 100644
--- a/cps-parent/pom.xml
+++ b/cps-parent/pom.xml
@@ -16,10 +16,15 @@
<packaging>pom</packaging>
<properties>
+ <app>org.onap.cps.Application</app>
+ <base.image>openjdk:11-jre-slim</base.image>
<java.version>11</java.version>
+ <jib-maven-plugin.version>2.6.0</jib-maven-plugin.version>
<oparent.version>3.1.0</oparent.version>
+ <repository.name>nexus3.onap.org:10001/onap/cps-service</repository.name>
<spring-boot-maven-plugin.version>2.3.3.RELEASE</spring-boot-maven-plugin.version>
<swagger-codegen-maven-plugin.version>3.0.18</swagger-codegen-maven-plugin.version>
+ <tag.version>${project.version}</tag.version>
</properties>
<dependencyManagement>
@@ -173,6 +178,43 @@
</includes>
</configuration>
</plugin>
+ <plugin>
+ <groupId>com.google.cloud.tools</groupId>
+ <artifactId>jib-maven-plugin</artifactId>
+ <version>${jib-maven-plugin.version}</version>
+ <configuration>
+ <container>
+ <mainClass>${app}</mainClass>
+ <creationTime>USE_CURRENT_TIMESTAMP</creationTime>
+ </container>
+ <from>
+ <image>${base.image}</image>
+ </from>
+ <to>
+ <image>${repository.name}</image>
+ <tags>
+ <tag>${tag.version}</tag>
+ </tags>
+ </to>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <id>build</id>
+ <goals>
+ <goal>dockerBuild</goal>
+ </goals>
+ </execution>
+ <!-- FIXME Enable this once migrated to onap,
+ <execution>
+ <phase>deploy</phase>
+ <id>buildAndPush</id>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>-->
+ </executions>
+ </plugin>
</plugins>
</build>
</project> \ No newline at end of file
diff --git a/cps-rest/pom.xml b/cps-rest/pom.xml
index 3c92a4e209..fc3e6325e2 100644
--- a/cps-rest/pom.xml
+++ b/cps-rest/pom.xml
@@ -85,6 +85,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
+ <plugin>
+ <groupId>com.google.cloud.tools</groupId>
+ <artifactId>jib-maven-plugin</artifactId>
+ </plugin>
<!-- Swagger code generation. -->
<plugin>
<groupId>io.swagger.codegen.v3</groupId>
diff --git a/docker-compose/README.md b/docker-compose/README.md
new file mode 100644
index 0000000000..d23f033495
--- /dev/null
+++ b/docker-compose/README.md
@@ -0,0 +1,3 @@
+```bash
+VERSION=0.0.1-SNAPSHOT DB_HOST=localhost DB_USERNAME=cps DB_PASSWORD=cps docker-compose up
+``` \ No newline at end of file
diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml
new file mode 100644
index 0000000000..6894d3f2ca
--- /dev/null
+++ b/docker-compose/docker-compose.yml
@@ -0,0 +1,26 @@
+version: "3.7"
+
+services:
+ cps:
+ restart: unless-stopped
+ image: nexus3.onap.org:10001/onap/cps-service:${VERSION}
+ container_name: cps-service
+ environment:
+ DB_HOST: ${DB_HOST}
+ DB_USERNAME: ${DB_USERNAME}
+ DB_PASSWORD: ${DB_PASSWORD}
+ ports:
+ - "8080:8080"
+ network_mode: "host
+ depends_on:
+ - dbpostgresql
+
+ dbpostgresql:
+ container_name: dbpostgresql
+ image: postgres
+ ports:
+ - '5432:5432'
+ environment:
+ DB_NAME: cpsdb
+ DB_USERNAME: ${DB_USERNAME}
+ DB_PASSWORD: ${DB_PASSWORD} \ No newline at end of file