From 26af9368115f5f7296aa4123f38b4e1c81a40b8d Mon Sep 17 00:00:00 2001 From: "Rishi.Chail" Date: Tue, 4 May 2021 16:34:09 +0100 Subject: 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 Change-Id: I47120edcea78730405086eca393fbc08a41e0745 --- .gitignore | 10 +++++- README.md | 32 +++++++++++++++++-- docker-compose.yml | 43 ++++++++++++++++++++++++++ pom.xml | 63 ++++++++++++++++++++++++++++++++++++++ src/main/resources/application.yml | 3 +- 5 files changed, 146 insertions(+), 5 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 README.md create mode 100755 docker-compose.yml mode change 100644 => 100755 pom.xml mode change 100644 => 100755 src/main/resources/application.yml diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 6609c05..cd944e3 --- 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 old mode 100644 new mode 100755 index 45ebd4e..d7d200e --- 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 old mode 100644 new mode 100755 index 49dce9f..5579823 --- a/pom.xml +++ b/pom.xml @@ -2,6 +2,7 @@