From b1ccfce0b229d544bf08b1c197a2365b40369796 Mon Sep 17 00:00:00 2001 From: "Claudio D. Gasparini" Date: Thu, 4 Feb 2021 09:33:28 +0100 Subject: Decouple application configuration file Agreement is that application configuration should live on OOM - leave an example of the configuration file under docker compose to run locally, instead of use OOM. Mainly for devs - document on README how to run the app with IDE or with docker compose - remove duplicate code on poms Issue-ID: CPS-175 Signed-off-by: Claudio D. Gasparini Change-Id: I328e89dba78cdf4d8abab51e3be5cb6d641064db --- cps-application/pom.xml | 29 ++---------- cps-application/src/main/resources/application.yml | 51 ---------------------- cps-rest/pom.xml | 2 +- docker-compose/README.md | 21 +++++++-- docker-compose/application.yml | 51 ++++++++++++++++++++++ docker-compose/docker-compose.yml | 31 +++++++++++++ 6 files changed, 105 insertions(+), 80 deletions(-) delete mode 100644 cps-application/src/main/resources/application.yml create mode 100644 docker-compose/application.yml diff --git a/cps-application/pom.xml b/cps-application/pom.xml index a159ad883a..744efb2d2f 100644 --- a/cps-application/pom.xml +++ b/cps-application/pom.xml @@ -68,6 +68,10 @@ org.springframework.boot spring-boot-maven-plugin + + com.google.cloud.tools + jib-maven-plugin + @@ -76,21 +80,12 @@ false - ${project.groupId} cps-rest - - - - com.google.cloud.tools - jib-maven-plugin - - - xnf-docker @@ -109,14 +104,6 @@ cps-nf-proxy-rest - - - - com.google.cloud.tools - jib-maven-plugin - - - cps-xnf-docker @@ -139,14 +126,6 @@ cps-nf-proxy-rest - - - - com.google.cloud.tools - jib-maven-plugin - - - \ No newline at end of file diff --git a/cps-application/src/main/resources/application.yml b/cps-application/src/main/resources/application.yml deleted file mode 100644 index c3ceecde0a..0000000000 --- a/cps-application/src/main/resources/application.yml +++ /dev/null @@ -1,51 +0,0 @@ -server: - port: 8080 - -rest: - api: - cps-base-path: /cps/api - xnf-base-path: /cps-nf-proxy/api - -spring: - main: - banner-mode: "off" - jpa: - ddl-auto: create - open-in-view: false - properties: - hibernate: - enable_lazy_load_no_trans: true - dialect: org.hibernate.dialect.PostgreSQLDialect - - datasource: - url: jdbc:postgresql://${DB_HOST}:5432/cpsdb - username: ${DB_USERNAME} - password: ${DB_PASSWORD} - driverClassName: org.postgresql.Driver - initialization-mode: always - - cache: - type: caffeine - cache-names: yangSchema - caffeine: - spec: maximumSize=10000,expireAfterAccess=10m -# Actuator -management: - endpoints: - web: - base-path: /manage - exposure: - include: info,health,loggers - endpoint: - health: - show-details: always - # kubernetes probes: liveness and readiness - probes: - enabled: true - loggers: - enabled: true - -logging: - level: - org: - springframework: INFO diff --git a/cps-rest/pom.xml b/cps-rest/pom.xml index 6ee0c4fdd1..5bd223d301 100755 --- a/cps-rest/pom.xml +++ b/cps-rest/pom.xml @@ -12,7 +12,7 @@ cps-rest - 0.53 + 0.51 diff --git a/docker-compose/README.md b/docker-compose/README.md index ca395df07a..3d68c3ff4b 100644 --- a/docker-compose/README.md +++ b/docker-compose/README.md @@ -2,18 +2,33 @@ To run the application locally using `docker-compose`, execute following command from this `docker-compose` folder: -Generate the containers +Compile without generating the docker images + +```bash +mvn clean install -Pcps-docker -Pxnf-docker -Pcps-xnf-docker -Djib.skip +``` + +Generate the docker images ```bash mvn clean install -Pcps-docker -Pxnf-docker -Pcps-xnf-docker ``` -or for generate an specific type + +for generate a specific type of docker images ```bash mvn clean install -Pcps-docker ``` + Run the containers ```bash VERSION=0.0.1-SNAPSHOT DB_HOST=dbpostgresql DB_USERNAME=cps DB_PASSWORD=cps docker-compose up -d -``` \ No newline at end of file +``` + +Run application from Intellj IDE + +you need first to enable the maven profile desired under tab Maven +then go to Run -> Edit configurations + 1- Working directory -> select docker-compose folder e.g. ~/workspace/onap/cps/docker-compose/ + 2- Enviroment variables -> add variables configuration e.g. DB_HOST=127.0.0.1;DB_USERNAME=cps;DB_PASSWORD=cps \ No newline at end of file diff --git a/docker-compose/application.yml b/docker-compose/application.yml new file mode 100644 index 0000000000..c3ceecde0a --- /dev/null +++ b/docker-compose/application.yml @@ -0,0 +1,51 @@ +server: + port: 8080 + +rest: + api: + cps-base-path: /cps/api + xnf-base-path: /cps-nf-proxy/api + +spring: + main: + banner-mode: "off" + jpa: + ddl-auto: create + open-in-view: false + properties: + hibernate: + enable_lazy_load_no_trans: true + dialect: org.hibernate.dialect.PostgreSQLDialect + + datasource: + url: jdbc:postgresql://${DB_HOST}:5432/cpsdb + username: ${DB_USERNAME} + password: ${DB_PASSWORD} + driverClassName: org.postgresql.Driver + initialization-mode: always + + cache: + type: caffeine + cache-names: yangSchema + caffeine: + spec: maximumSize=10000,expireAfterAccess=10m +# Actuator +management: + endpoints: + web: + base-path: /manage + exposure: + include: info,health,loggers + endpoint: + health: + show-details: always + # kubernetes probes: liveness and readiness + probes: + enabled: true + loggers: + enabled: true + +logging: + level: + org: + springframework: INFO diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index accdbd4dbf..beae091f1b 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -4,6 +4,8 @@ services: cps: container_name: cps-service image: nexus3.onap.org:10001/onap/cps-service:${VERSION} + volumes: + - "./application.yml:/app/application.yml" ports: - "8881:8080" environment: @@ -14,6 +16,35 @@ services: depends_on: - dbpostgresql + cps-nf-proxy: + container_name: cps-nf-proxy + image: nexus3.onap.org:10001/onap/cps-nf-proxy:${VERSION} + volumes: + - "./application.yml:/app/application.yml" + ports: + - "8882:8080" + environment: + DB_HOST: ${DB_HOST} + DB_USERNAME: ${DB_USERNAME} + DB_PASSWORD: ${DB_PASSWORD} + restart: unless-stopped + depends_on: + - dbpostgresql + + cps-and-nf-proxy: + container_name: cps-and-nf-proxy + image: nexus3.onap.org:10001/onap/cps-and-nf-proxy:${VERSION} + volumes: + - "./application.yml:/app/application.yml" + ports: + - "8883:8080" + environment: + DB_HOST: ${DB_HOST} + DB_USERNAME: ${DB_USERNAME} + DB_PASSWORD: ${DB_PASSWORD} + restart: unless-stopped + depends_on: + - dbpostgresql dbpostgresql: container_name: dbpostgresql -- cgit 1.2.3-korg