aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuoc Nghia Nguyen <quocnghia.nguyen@orange.com>2018-04-13 13:56:42 +0200
committerQuoc Nghia Nguyen <quocnghia.nguyen@orange.com>2018-04-13 14:25:44 +0200
commit6b8c1f5d9844c92774243834aa3f0f7136a1e222 (patch)
tree3e0efed348f2165c6ded3427fff7a11e3977c310
parent65352f84525c13c7469ba435b3a0adbc83ae4cfc (diff)
Externalized app params for deployment
- .env: contains environment variables which override application's default properties - Dockerfile & docker-compose.yml: takes environment variables into account - application.properties: included external services configurations Change-Id: I49937e66d514a42a174cff3bf6c383ecfc8e28e0 Issue-ID: EXTAPI-49 Signed-off-by: Quoc Nghia Nguyen <quocnghia.nguyen@orange.com>
-rw-r--r--.env38
-rw-r--r--Dockerfile12
-rw-r--r--docker-compose.yml20
-rw-r--r--src/main/resources/application-docker.properties64
-rw-r--r--src/main/resources/application-localhost.properties66
-rw-r--r--src/main/resources/application.properties39
-rw-r--r--src/test/resources/application.properties8
7 files changed, 104 insertions, 143 deletions
diff --git a/.env b/.env
new file mode 100644
index 0000000..42319ef
--- /dev/null
+++ b/.env
@@ -0,0 +1,38 @@
+# APPLICATION
+SERVER_CONTEXTPATH=/nbi/api/v1
+SERVER_PORT=8080
+LOGGING_LEVEL=INFO
+
+# ONAP
+ONAP_LCPCLOUDREGIONID=
+ONAP_TENANTID=
+ONAP_CLOUDOWNER=
+
+# NBI
+NBI_URL=http://localhost:8080/nbi/api/v1
+NBI_CALLFORVNF=false
+
+# SDC
+SDC_HOST=http://localhost:8090
+SDC_HEADER_ECOMPINSTANCEID=
+SDC_HEADER_AUTHORIZATION=
+
+# AAI
+AAI_HOST=http://localhost:8090
+AAI_HEADER_AUTHORIZATION=
+AAI_API_ID=AAI
+
+# SO
+SO_HOST=http://localhost:8090
+SO_HEADER_AUTHORIZATION=
+SO_API_ID=SO
+
+# MONGO
+SPRING_DATA_MONGODB_HOST=localhost
+SPRING_DATA_MONGODB_PORT=27017
+SPRING_DATA_MONGODB_DATABASE=ServiceOrderDB
+
+# MYSQL
+SPRING_DATASOURCE_URL=jdbc:mariadb://localhost:3306/nbi
+SPRING_DATASOURCE_USERNAME=root
+SPRING_DATASOURCE_PASSWORD=secret \ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
index a3c56b2..09b2019 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,7 +1,11 @@
-FROM openjdk:8-jdk-alpine
+FROM openjdk:8-jre-alpine
+ARG SERVER_PORT
ARG PKG_FILENAME=nbi-rest-services-1.0.0-SNAPSHOT.jar
-
ADD target/$PKG_FILENAME 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
+
+ENV SERVER_PORT=${SERVER_PORT:-8080}
+ENV JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -jar"
+
+EXPOSE $SERVER_PORT
+ENTRYPOINT java $JAVA_OPTS -jar /app.jar
diff --git a/docker-compose.yml b/docker-compose.yml
index e6fbf97..3aeb66e 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,27 +1,31 @@
version: "3.0"
services:
mongo:
- image: mongo
+ image: mongo:3
+ restart: always
volumes:
- /var/lib/mongo
- ports:
- - 27017:27017
command: --smallfiles
mariadb:
- image: mariadb
+ image: mariadb:10
restart: always
volumes:
- /var/lib/mariadb
environment:
MYSQL_DATABASE: nbi
- MYSQL_ROOT_PASSWORD: toto
+ MYSQL_ROOT_PASSWORD: $SPRING_DATASOURCE_PASSWORD
# APP ***************************************************************************************
nbi:
- build: .
- image: nbi
+ build:
+ context: .
+ args:
+ SERVER_PORT: $SERVER_PORT
ports:
- - 8080:8080
+ - $SERVER_PORT:$SERVER_PORT
+ environment:
+ SPRING_DATASOURCE_URL: jdbc:mariadb://mariadb:3306/nbi
+ SPRING_DATA_MONGODB_HOST: mongo
depends_on:
- mariadb
- mongo
diff --git a/src/main/resources/application-docker.properties b/src/main/resources/application-docker.properties
deleted file mode 100644
index 098b43f..0000000
--- a/src/main/resources/application-docker.properties
+++ /dev/null
@@ -1,64 +0,0 @@
-#
-# Copyright (c) 2018 Orange
-#
-# 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.
-#
-
-# 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/src/main/resources/application-localhost.properties b/src/main/resources/application-localhost.properties
deleted file mode 100644
index f542f60..0000000
--- a/src/main/resources/application-localhost.properties
+++ /dev/null
@@ -1,66 +0,0 @@
-#
-# Copyright (c) 2018 Orange
-#
-# 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.
-#
-
-# 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.host=localhost
-spring.data.mongodb.port=27017
-spring.data.mongodb.database=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://localhost:3306/nbi
-spring.jpa.show-sql=false
-spring.datasource.username=root
-spring.datasource.password=toto
-spring.jpa.hibernate.ddl-auto=update
-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/src/main/resources/application.properties b/src/main/resources/application.properties
index 4ddd54f..bb07e4d 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -21,3 +21,42 @@ server.port = 8080
# LOGGING
logging.level.=INFO
+# ONAP
+onap.lcpCloudRegionId=
+onap.tenantId=
+onap.cloudOwner=
+
+# NBI
+nbi.url=http://localhost:8080/nbi/api/v1
+nbi.callForVNF=false
+
+# SDC
+sdc.host=http://localhost:8090
+sdc.header.ecompInstanceId=
+sdc.header.authorization=
+
+# AAI
+aai.host=http://localhost:8090
+aai.header.authorization=
+aai.api.id=AAI
+
+# SO
+so.host=http://localhost:8090
+so.header.authorization=
+so.api.id=SO
+
+# MONGO
+spring.data.mongodb.host=localhost
+spring.data.mongodb.port=27017
+spring.data.mongodb.database=ServiceOrderDB
+
+# MYSQL
+spring.datasource.url=jdbc:mariadb://localhost:3306/nbi
+spring.datasource.username=root
+spring.datasource.password=secret
+spring.datasource.testWhileIdle=true
+spring.datasource.validationQuery=SELECT 1
+spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
+spring.jpa.show-sql=false
+spring.jpa.hibernate.ddl-auto=update
+spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy \ No newline at end of file
diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties
index 0128997..f6df654 100644
--- a/src/test/resources/application.properties
+++ b/src/test/resources/application.properties
@@ -45,4 +45,10 @@ so.host=http://127.0.0.1:8091
so.header.authorization=
so.api.id=SO
-
+# H2
+spring.datasource.url=jdbc:h2:mem:~/db;DB_CLOSE_ON_EXIT=false
+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