aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRishi.Chail <rishi.chail@est.tech>2021-05-04 16:34:09 +0100
committerRishi.Chail <rishi.chail@est.tech>2021-05-06 15:00:20 +0100
commit26af9368115f5f7296aa4123f38b4e1c81a40b8d (patch)
treed162f097439c7419534a0b9d0bf51607ffd191a2
parent2bd625b905936425802d02f3bc067d5f56412188 (diff)
Provide docker compose for temporal service
Added docker image (200Mb) Added docker compose to start with timescale db Issue-ID: CPS-359 Signed-off-by: Rishi.Chail <rishi.chail@est.tech> Change-Id: I47120edcea78730405086eca393fbc08a41e0745
-rwxr-xr-x[-rw-r--r--].gitignore10
-rwxr-xr-x[-rw-r--r--]README.md32
-rwxr-xr-xdocker-compose.yml43
-rwxr-xr-x[-rw-r--r--]pom.xml63
-rwxr-xr-x[-rw-r--r--]src/main/resources/application.yml3
5 files changed, 146 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index 6609c05..cd944e3 100644..100755
--- a/.gitignore
+++ b/.gitignore
@@ -29,4 +29,12 @@ build/
.vscode/
### MAC OS ###
-.DS_Store \ No newline at end of file
+.DS_Store
+
+### Eclipse ###
+.settings/
+bin/
+tmp/
+.metadata
+*.tmp
+.checkstyle \ No newline at end of file
diff --git a/README.md b/README.md
index 45ebd4e..d7d200e 100644..100755
--- a/README.md
+++ b/README.md
@@ -1,8 +1,34 @@
-# CPS Temporal Service
+# Building and running CPS Temporal locally
-For now, this repo contains a very minimalist skeleton of the application.
+## Building Java Archive only
-## Local DB setup
+Following command builds Java executable jar to `target/cps-temporal-x.y.z-SNAPSHOT` JAR file
+without generating any docker images:
+
+```bash
+mvn clean install
+```
+
+## Building Java Archive and local Docker image
+
+Following command builds the JAR file and also generates the Docker image:
+
+```bash
+mvn clean install -Pcps-temporal-docker -Ddocker.repository.push=
+```
+
+## Running via Docker Compose
+
+`docker-compose.yml` file is provided to be run with `docker-compose` tool and local image previously built.
+It starts both Postgres Timescale database and CPS Temporal service.
+
+Execute following command from project root folder:
+
+```bash
+docker-compose up -d
+```
+
+## Alternative local db setup
A Postgres instance with Timescale extension can be started by running the following command:
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100755
index 0000000..fae1cbc
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,43 @@
+# ============LICENSE_START=======================================================
+# Copyright (C) 2021 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.
+# ============LICENSE_END=========================================================
+
+version: "3.7"
+
+services:
+
+ cps-temporal:
+ container_name: cps-temporal
+ image: onap/cps-temporal:latest
+ ports:
+ - '8082:8080'
+ environment:
+ DB_HOST: timescaledb
+ DB_PORT: 5432
+ DB_USERNAME: cpstemporal
+ DB_PASSWORD: cpstemporal
+ restart: unless-stopped
+ depends_on:
+ - timescaledb
+
+ timescaledb:
+ container_name: timescaledb
+ image: timescale/timescaledb:2.1.1-pg13
+ ports:
+ - '5432:5432'
+ environment:
+ POSTGRES_DB: cpstemporaldb
+ POSTGRES_USER: ${DB_USERNAME}
+ POSTGRES_PASSWORD: ${DB_PASSWORD}
diff --git a/pom.xml b/pom.xml
index 49dce9f..5579823 100644..100755
--- a/pom.xml
+++ b/pom.xml
@@ -2,6 +2,7 @@
<!--
============LICENSE_START=======================================================
Copyright (c) 2021 Bell Canada.
+ Modifications Copyright (C) 2021 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -35,10 +36,17 @@
<description>CPS Temporal Service</description>
<properties>
+ <app>org.onap.cps.temporal.Application</app>
+ <docker.repository.pull>nexus3.onap.org:10001/</docker.repository.pull>
+ <docker.repository.push>nexus3.onap.org:10003/</docker.repository.push>
+ <image.base>${docker.repository.pull}onap/integration-java11:8.0.0</image.base>
+ <image.name>${docker.repository.push}onap/cps-temporal</image.name>
<java.version>11</java.version>
<minimum-coverage>0.8</minimum-coverage>
<cps.checkstyle.version>1.0.1</cps.checkstyle.version>
<cps.spotbugs.version>1.0.1</cps.spotbugs.version>
+ <jib-maven-plugin.version>3.0.0</jib-maven-plugin.version>
+ <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
<oparent.version>3.2.0</oparent.version>
<spotbugs-maven-plugin.version>4.1.3</spotbugs-maven-plugin.version>
<spotbugs.slf4j.version>1.8.0-beta4</spotbugs.slf4j.version>
@@ -346,5 +354,60 @@
</executions>
</plugin>
</plugins>
+
+ <pluginManagement>
+ <plugins>
+ <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>
+ <tags>
+ <tag>latest</tag>
+ </tags>
+ <image>${image.name}:${project.version}-${maven.build.timestamp}</image>
+ </to>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <id>build</id>
+ <goals>
+ <goal>dockerBuild</goal>
+ </goals>
+ </execution>
+ <execution>
+ <phase>deploy</phase>
+ <id>buildAndPush</id>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
</build>
+
+ <profiles>
+ <profile>
+ <id>cps-temporal-docker</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.google.cloud.tools</groupId>
+ <artifactId>jib-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 0db1792..ff70e46 100644..100755
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -1,5 +1,6 @@
# ============LICENSE_START=======================================================
# Copyright (c) 2021 Bell Canada.
+# Modifications Copyright (C) 2021 Nordix Foundation.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,7 +17,7 @@
spring:
datasource:
- url: jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME}
+ url: jdbc:postgresql://${DB_HOST}:${DB_PORT}/cpstemporaldb
username: ${DB_USERNAME}
password: ${DB_PASSWORD}
liquibase: