From daf0dfe8308a259d168734d3fe98212cadad1a9e Mon Sep 17 00:00:00 2001 From: priyanshu Date: Mon, 28 May 2018 15:29:26 +0300 Subject: Activity Spec docker enhancements Activity Spec Changes for docker in Kubernetes Change-Id: I987fe097792ccd5d41a0ad811602dad72259d45f Issue-ID: SDC-1048 Signed-off-by: priyanshu --- .../activity-spec/activity-spec-init/Dockerfile | 2 - services/activity-spec/activity-spec-init/start.sh | 16 +- .../activity-spec/activity-spec-web/Dockerfile | 27 ---- .../activity-spec-assembly/configuration.yaml | 9 -- .../activity-spec-assembly/logback.xml | 173 --------------------- .../activity-spec-assembly/start.sh | 11 -- .../activity-spec-docker-assembly/Dockerfile | 24 +++ .../Activity_Spec_Manual_Steps_And_Commands.txt | 14 ++ .../ReadMe/configuration.yaml | 11 ++ .../activity-spec-docker-assembly/start.sh | 10 ++ .../src/main/resources/config/logback.xml | 173 +++++++++++++++++++++ services/activity-spec/activity-spec-web/pom.xml | 69 +++++++- 12 files changed, 310 insertions(+), 229 deletions(-) delete mode 100644 services/activity-spec/activity-spec-web/Dockerfile delete mode 100644 services/activity-spec/activity-spec-web/activity-spec-assembly/configuration.yaml delete mode 100644 services/activity-spec/activity-spec-web/activity-spec-assembly/logback.xml delete mode 100644 services/activity-spec/activity-spec-web/activity-spec-assembly/start.sh create mode 100644 services/activity-spec/activity-spec-web/activity-spec-docker-assembly/Dockerfile create mode 100644 services/activity-spec/activity-spec-web/activity-spec-docker-assembly/ReadMe/Activity_Spec_Manual_Steps_And_Commands.txt create mode 100644 services/activity-spec/activity-spec-web/activity-spec-docker-assembly/ReadMe/configuration.yaml create mode 100644 services/activity-spec/activity-spec-web/activity-spec-docker-assembly/start.sh create mode 100644 services/activity-spec/activity-spec-web/activity-spec-service/src/main/resources/config/logback.xml diff --git a/services/activity-spec/activity-spec-init/Dockerfile b/services/activity-spec/activity-spec-init/Dockerfile index 09361461dd..a940b20c5f 100644 --- a/services/activity-spec/activity-spec-init/Dockerfile +++ b/services/activity-spec/activity-spec-init/Dockerfile @@ -2,8 +2,6 @@ FROM alpine:3.7 RUN apk add --no-cache 'python<3' py-pip && pip install cqlsh==4.0.1 -ENV CASSANDRA_PORT=9160 - COPY create_activityspec_db.cql . COPY start.sh . diff --git a/services/activity-spec/activity-spec-init/start.sh b/services/activity-spec/activity-spec-init/start.sh index defc8efedf..582f0bde0a 100644 --- a/services/activity-spec/activity-spec-init/start.sh +++ b/services/activity-spec/activity-spec-init/start.sh @@ -1,8 +1,18 @@ #!/bin/sh -if [[ -z "${CASSANDRA_HOST}" ]]; then - echo "CASSANDRA_HOST environment variable must be set" +if [[ -z "${CS_USER}" ]]; then + echo "CS_USER environment variable must be set" exit 1 fi -cqlsh -f /create_activityspec_db.cql $CASSANDRA_HOST $CASSANDRA_PORT \ No newline at end of file +if [[ -z "${CS_PASSWORD}" ]]; then + echo "CS_PASSWORD environment variable must be set" + exit 1 +fi + +if [[ -z "${CS_HOST}" ]]; then + echo "CS_HOST environment variable must be set" + exit 1 +fi + +cqlsh -u $CS_USER -p $CS_PASSWORD -f /create_activityspec_db.cql $CS_HOST $CS_PORT diff --git a/services/activity-spec/activity-spec-web/Dockerfile b/services/activity-spec/activity-spec-web/Dockerfile deleted file mode 100644 index fe7e20bd3c..0000000000 --- a/services/activity-spec/activity-spec-web/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -FROM jetty:9.4.9-alpine - -EXPOSE 8080 -EXPOSE 8443 -EXPOSE 5005 - -ARG ARTIFACT_VERSION - -ENV LOGBACK_FILE_DIR /etc/onap/activity-spec/be/ - -# See https://hub.docker.com/_/jetty/ -ARG WEBAPPS_DIR=${JETTY_BASE}/webapps/ - -COPY activity-spec-api-docs/target/activity-spec-api-docs-${ARTIFACT_VERSION}.war ${WEBAPPS_DIR} - -COPY activity-spec-war/target/activity-spec-war-${ARTIFACT_VERSION}.war ${WEBAPPS_DIR} - -COPY activity-spec-assembly/configuration.yaml . -COPY activity-spec-assembly/start.sh . -COPY activity-spec-assembly/logback.xml ${LOGBACK_FILE_DIR} - -USER root - -RUN chown jetty:jetty start.sh -RUN chmod 744 start.sh - -ENTRYPOINT ["./start.sh"] \ No newline at end of file diff --git a/services/activity-spec/activity-spec-web/activity-spec-assembly/configuration.yaml b/services/activity-spec/activity-spec-web/activity-spec-assembly/configuration.yaml deleted file mode 100644 index cc54430ba3..0000000000 --- a/services/activity-spec/activity-spec-web/activity-spec-assembly/configuration.yaml +++ /dev/null @@ -1,9 +0,0 @@ -cassandraConfig: - cassandraHosts: ['CASSANDRA_HOST'] - reconnectTimeout : 30000 - authenticate: false - username: asdc_user - password: Aa1234%^! - ssl: false - truststorePath : /path/path - truststorePassword : Aa123456 \ No newline at end of file diff --git a/services/activity-spec/activity-spec-web/activity-spec-assembly/logback.xml b/services/activity-spec/activity-spec-web/activity-spec-assembly/logback.xml deleted file mode 100644 index 949510aac9..0000000000 --- a/services/activity-spec/activity-spec-web/activity-spec-assembly/logback.xml +++ /dev/null @@ -1,173 +0,0 @@ - - - - - - - - - - - - - - ${log.location}/error.log - - - INFO - - - - - AUDIT - - NEUTRAL - DENY - - - - - METRICS - - NEUTRAL - DENY - - - - ${log.location}/error.log.%i - - 1 - 10 - - - - 20MB - - - - - %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%level||%X{ErrorCode}|%X{ErrorDescription}|%msg%n - - - - - - - - ${log.location}/debug.log - - - DEBUG - ACCEPT - DENY - - - - ${log.location}/debug.log.%i - - 1 - 10 - - - - 20MB - - - - - %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestId}|%msg%n - - - - - - - - - - - - ${log.location}/audit.log - - - - AUDIT - - DENY - ACCEPT - - - - ${log.location}/audit.log.%i - - 1 - 10 - - - - 20MB - - - - - %X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceId}|%level||%X{ServerIpAddress}|%X{ElapsedTime}|%X{Server}|%X{ClientIpAddress}||||||||%msg%n - - - - - - - ${log.location}/metrics.log - - - - METRICS - - DENY - ACCEPT - - - - ${log.location}/metrics.log.%i - - 1 - 10 - - - - 20MB - - - - - %X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceId}|%level||%X{ServerIpAddress}|%X{ElapsedTime}|%X{Server}|%X{ClientIpAddress}||||||||||%msg%n - - - - - - - - - - - - \ No newline at end of file diff --git a/services/activity-spec/activity-spec-web/activity-spec-assembly/start.sh b/services/activity-spec/activity-spec-web/activity-spec-assembly/start.sh deleted file mode 100644 index d4a02293d9..0000000000 --- a/services/activity-spec/activity-spec-web/activity-spec-assembly/start.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -if [[ -z "${CASSANDRA_HOST}" ]]; then - echo "CASSANDRA_HOST environment variable must be set" - exit 1 -fi - -#Replace 'CASSANDRA_HOST' in configuration.yaml with value of CASSANDRA_HOST environment variable -sed -i "s/CASSANDRA_HOST/${CASSANDRA_HOST}/" configuration.yaml - -java -jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 "$JETTY_HOME/start.jar" -Dconfiguration.yaml=configuration.yaml -Dlogback.configurationFile=${LOGBACK_FILE_DIR}/logback.xml \ No newline at end of file diff --git a/services/activity-spec/activity-spec-web/activity-spec-docker-assembly/Dockerfile b/services/activity-spec/activity-spec-web/activity-spec-docker-assembly/Dockerfile new file mode 100644 index 0000000000..adbde5e441 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-docker-assembly/Dockerfile @@ -0,0 +1,24 @@ +FROM jetty:9.4.9-alpine + +EXPOSE 8080 +EXPOSE 8443 +EXPOSE 5005 + +USER root + +RUN mkdir -p /etc/onap/activity-spec/be +RUN mkdir -p /var/log/ONAP/activity-spec/be + +ENV CONFIG_FILES_DIR /etc/onap/activity-spec/be +ENV LOGS_DIR /var/log/ONAP/activity-spec/be + +ADD activity-spec-api-docs-*.war ${JETTY_BASE}/webapps/ +ADD activity-spec-war-*.war ${JETTY_BASE}/webapps/ + +COPY start.sh . +COPY logback.xml ${CONFIG_FILES_DIR} + +RUN chown -R jetty:jetty ${JETTY_BASE}/webapps +RUN chmod 744 start.sh + +ENTRYPOINT [ "./start.sh" ] \ No newline at end of file diff --git a/services/activity-spec/activity-spec-web/activity-spec-docker-assembly/ReadMe/Activity_Spec_Manual_Steps_And_Commands.txt b/services/activity-spec/activity-spec-web/activity-spec-docker-assembly/ReadMe/Activity_Spec_Manual_Steps_And_Commands.txt new file mode 100644 index 0000000000..c724498349 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-docker-assembly/ReadMe/Activity_Spec_Manual_Steps_And_Commands.txt @@ -0,0 +1,14 @@ +# Steps to run activiti-spec docker + +1. Create a directory on host machine to hold configuration file. +2. Copy the provided configuration.yaml in this new;y created directory and populate real enviornment value of Cassandra to which activity-spec web service needs to be connected. +3. Execute below commands to start docker containers. + +# 1. Start activity-spec container +docker run -d --name -e JAVA_OPTIONS="-Xmx128m -Xms128m -Xss1m" -v :/etc/onap/activity-spec/be/config -p :8080 +# 2. Start activity-spec-init container +docker run -d --name -e CS_HOST= -e CS_PORT= -e CS_USER= -e CS_PASSWORD= + +# Example Commands +docker run -d --name sdc-act -e JAVA_OPTIONS="-Xmx128m -Xms128m -Xss1m" -v /data/environments:/etc/onap/activity-spec/be/config -p 8090:8080 onap/activity-spec:1.2.0-SNAPSHOT +docker run -d --name sdc-act-init -e CS_HOST=172.17.0.2 -e CS_USER=asdc_user -e CS_PORT=9160 -e CS_PASSWORD=Aa1234%^! onap/activity-spec-init:1.2.0-SNAPSHOT diff --git a/services/activity-spec/activity-spec-web/activity-spec-docker-assembly/ReadMe/configuration.yaml b/services/activity-spec/activity-spec-web/activity-spec-docker-assembly/ReadMe/configuration.yaml new file mode 100644 index 0000000000..bedf36c5db --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-docker-assembly/ReadMe/configuration.yaml @@ -0,0 +1,11 @@ +cassandraConfig: + cassandraHosts: ['${CS_HOST}'] + reconnectTimeout : 30000 + socketReadTimeout: 20000 + socketConnectTimeout: 20000 + authenticate: true + username: ${CS_USER} + password: ${CS_PASSWORD} + ssl: ${CS_SSL_ENABLED} + truststorePath : ${CS_TRUST_PATH} + truststorePassword : ${CS_TRUST_PASSWORD} \ No newline at end of file diff --git a/services/activity-spec/activity-spec-web/activity-spec-docker-assembly/start.sh b/services/activity-spec/activity-spec-web/activity-spec-docker-assembly/start.sh new file mode 100644 index 0000000000..993ace67bf --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-docker-assembly/start.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +JAVA_OPTIONS=" ${JAVA_OPTIONS} \ + -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 + -Dconfig.home=${CONFIG_FILES_DIR}/config \ + -Dlog.home=${LOGS_DIR} \ + -Dlogback.configurationFile=${CONFIG_FILES_DIR}/logback.xml \ + -Dconfiguration.yaml=${CONFIG_FILES_DIR}/config/configuration.yaml" + +java -jar "$JETTY_HOME/start.jar" ${JAVA_OPTIONS} \ No newline at end of file diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/resources/config/logback.xml b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/resources/config/logback.xml new file mode 100644 index 0000000000..949510aac9 --- /dev/null +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/resources/config/logback.xml @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + ${log.location}/error.log + + + INFO + + + + + AUDIT + + NEUTRAL + DENY + + + + + METRICS + + NEUTRAL + DENY + + + + ${log.location}/error.log.%i + + 1 + 10 + + + + 20MB + + + + + %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%level||%X{ErrorCode}|%X{ErrorDescription}|%msg%n + + + + + + + + ${log.location}/debug.log + + + DEBUG + ACCEPT + DENY + + + + ${log.location}/debug.log.%i + + 1 + 10 + + + + 20MB + + + + + %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestId}|%msg%n + + + + + + + + + + + + ${log.location}/audit.log + + + + AUDIT + + DENY + ACCEPT + + + + ${log.location}/audit.log.%i + + 1 + 10 + + + + 20MB + + + + + %X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceId}|%level||%X{ServerIpAddress}|%X{ElapsedTime}|%X{Server}|%X{ClientIpAddress}||||||||%msg%n + + + + + + + ${log.location}/metrics.log + + + + METRICS + + DENY + ACCEPT + + + + ${log.location}/metrics.log.%i + + 1 + 10 + + + + 20MB + + + + + %X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceId}|%level||%X{ServerIpAddress}|%X{ElapsedTime}|%X{Server}|%X{ClientIpAddress}||||||||||%msg%n + + + + + + + + + + + + \ No newline at end of file diff --git a/services/activity-spec/activity-spec-web/pom.xml b/services/activity-spec/activity-spec-web/pom.xml index a1df9771fd..d565010c75 100644 --- a/services/activity-spec/activity-spec-web/pom.xml +++ b/services/activity-spec/activity-spec-web/pom.xml @@ -26,6 +26,70 @@ + + maven-resources-plugin + 3.0.2 + + + copy-activity-spec-docker-assembly + verify + + copy-resources + + + target/activity-spec-docker-assembly + + + ${project.basedir}/activity-spec-docker-assembly + + + + + + copy-static-configuration-files + verify + + copy-resources + + + target/activity-spec-docker-assembly + + + ${project.basedir}/activity-spec-service/src/main/resources/config + + logback.xml + + + + + + + copy-resources + verify + + copy-resources + + + target/activity-spec-docker-assembly + + + ${project.basedir}/activity-spec-war/target + + activity-spec-war-${project.version}.war + + + + ${project.basedir}/activity-spec-api-docs/target + + + activity-spec-api-docs-${project.version}.war + + + + + + + io.fabric8 docker-maven-plugin @@ -37,11 +101,8 @@ ${project.version} - ${project.basedir} + ${project.basedir}/target/activity-spec-docker-assembly Dockerfile - - ${project.version} - -- cgit 1.2.3-korg