diff options
Diffstat (limited to 'aai-resources/src/main/resources/docker/docker-entrypoint.sh')
-rw-r--r-- | aai-resources/src/main/resources/docker/docker-entrypoint.sh | 90 |
1 files changed, 61 insertions, 29 deletions
diff --git a/aai-resources/src/main/resources/docker/docker-entrypoint.sh b/aai-resources/src/main/resources/docker/docker-entrypoint.sh index 47ee81f..ab7098a 100644 --- a/aai-resources/src/main/resources/docker/docker-entrypoint.sh +++ b/aai-resources/src/main/resources/docker/docker-entrypoint.sh @@ -18,44 +18,76 @@ # ============LICENSE_END========================================================= ### -cd /var/chef; +# Set the current path to be the application home and common libs home +APP_HOME=$(pwd); +COMMONLIBS_HOME="/opt/app/commonLibs"; -CHEF_CONFIG_REPO=${CHEF_CONFIG_REPO:-aai-config}; +export CHEF_CONFIG_REPO=${CHEF_CONFIG_REPO:-aai-config}; +export CHEF_GIT_URL=${CHEF_GIT_URL:-http://gerrit.onap.org/r/aai}; +export CHEF_CONFIG_GIT_URL=${CHEF_CONFIG_GIT_URL:-$CHEF_GIT_URL}; +export CHEF_DATA_GIT_URL=${CHEF_DATA_GIT_URL:-$CHEF_GIT_URL}; -CHEF_GIT_URL=${CHEF_GIT_URL:-http://nexus.onap.org/r/aai}; +USER_ID=${LOCAL_USER_ID:-9001} -CHEF_CONFIG_GIT_URL=${CHEF_CONFIG_GIT_URL:-$CHEF_GIT_URL}; -CHEF_DATA_GIT_URL=${CHEF_DATA_GIT_URL:-$CHEF_GIT_URL}; +if [ $(cat /etc/passwd | grep aaiadmin | wc -l) -eq 0 ]; then + useradd --shell=/bin/bash -u ${USER_ID} -o -c "" -m aaiadmin || { + echo "Unable to create the user id for ${USER_ID}"; + exit 1; + } +fi; -if [ ! -d "aai-config" ]; then +chown -R aaiadmin:aaiadmin /opt/app /var/chef /opt/aai/logroot - git clone --depth 1 -b ${CHEF_BRANCH} --single-branch ${CHEF_CONFIG_GIT_URL}/${CHEF_CONFIG_REPO}.git aai-config || { - echo "Error: Unable to clone the aai-config repo with url: ${CHEF_GIT_URL}/${CHEF_CONFIG_REPO}.git"; - exit; - } +gosu aaiadmin ./init-chef.sh - (cd aai-config/cookbooks/${project.artifactId}/ && \ - for f in $(ls); do mv $f ../; done && \ - cd ../ && rmdir ${project.artifactId}); -fi +httpPort=8087; +httpsPort=8447; -if [ ! -d "aai-data" ]; then +cd ${APP_HOME}; - git clone --depth 1 -b ${CHEF_BRANCH} --single-branch ${CHEF_DATA_GIT_URL}/aai-data.git aai-data || { - echo "Error: Unable to clone the aai-data repo with url: ${CHEF_GIT_URL}"; - exit; - } +CP=${COMMONLIBS_HOME}/*; +CP="$CP":${APP_HOME}/etc; +CP="$CP":${APP_HOME}/lib/*; +CP="$CP":${APP_HOME}/extJars/logback-access-1.1.7.jar; +CP="$CP":${APP_HOME}/extJars/logback-core-1.1.7.jar; +CP="$CP":${APP_HOME}/extJars/aai-core-${AAI_CORE_VERSION}.jar; - chef-solo \ - -c /var/chef/aai-data/chef-config/dev/.knife/solo.rb \ - -j /var/chef/aai-config/cookbooks/runlist-${project.artifactId}.json \ - -E ${AAI_CHEF_ENV}; +# You can add additional jvm options by adding environment variable JVM_PRE_OPTS +# If you need to add more jvm options at the end then you can use JVM_POST_OPTS +JVM_OPTS="${JVM_PRE_OPTS} ${JVM_OPTS}"; +JVM_OPTS="${JVM_OPTS} -server -XX:NewSize=512m -XX:MaxNewSize=512m"; +JVM_OPTS="${JVM_OPTS} -XX:SurvivorRatio=8"; +JVM_OPTS="${JVM_OPTS} -XX:+DisableExplicitGC -verbose:gc -XX:+UseParNewGC"; +JVM_OPTS="${JVM_OPTS} -XX:+CMSParallelRemarkEnabled -XX:+CMSClassUnloadingEnabled"; +JVM_OPTS="${JVM_OPTS} -XX:+UseConcMarkSweepGC -XX:-UseBiasedLocking"; +JVM_OPTS="${JVM_OPTS} -XX:ParallelGCThreads=4"; +JVM_OPTS="${JVM_OPTS} -XX:LargePageSizeInBytes=128m "; +JVM_OPTS="${JVM_OPTS} -XX:+PrintGCDetails -XX:+PrintGCTimeStamps"; +JVM_OPTS="${JVM_OPTS} -Xloggc:${APP_HOME}/logs/gc/graph-query_gc.log"; +JVM_OPTS="${JVM_OPTS} -XX:+HeapDumpOnOutOfMemoryError"; +JVM_OPTS="${JVM_OPTS} ${JVM_POST_OPTS}"; - /opt/app/aai-resources/bin/createDBSchema.sh || { - echo "Error: Unable to create the db schema, please check if the hbase host is configured and up"; - exit; - } +# You can add additional java options by adding environment variable JAVA_PRE_OPTS +# If you need to add more jvm options at the end then you can use JAVA_POST_OPTS +JAVA_OPTS="${JAVA_PRE_OPTS} ${JAVA_OPTS}"; +JAVA_OPTS="${JAVA_OPTS} -Dsun.net.inetaddr.ttl=180"; +JAVA_OPTS="${JAVA_OPTS} -Dhttps.protocols=TLSv1.1,TLSv1.2"; +JAVA_OPTS="${JAVA_OPTS} -DSOACLOUD_SERVICE_VERSION=1.0.1"; +JAVA_OPTS="${JAVA_OPTS} -DAJSC_HOME=${APP_HOME}"; +JAVA_OPTS="${JAVA_OPTS} -DAJSC_CONF_HOME=${APP_HOME}/bundleconfig"; +JAVA_OPTS="${JAVA_OPTS} -DAJSC_SHARED_CONFIG=${APP_HOME}/bundleconfig"; +JAVA_OPTS="${JAVA_OPTS} -DAFT_HOME=${APP_HOME}"; +JAVA_OPTS="${JAVA_OPTS} -DAAI_CORE_VERSION=${AAI_CORE_VERSION}"; +JAVA_OPTS="${JAVA_OPTS} -Daai-core.version=${AAI_CORE_VERSION}"; +JAVA_OPTS="${JAVA_OPTS} -Dlogback.configurationFile=${APP_HOME}/bundleconfig/etc/logback.xml"; +JAVA_OPTS="${JAVA_OPTS} ${JAVA_POST_OPTS}"; -fi +JAVA_ARGS="${JAVA_PRE_ARGS} ${JAVA_ARGS}"; +JAVA_ARGS="${JAVA_ARGS} context=/"; +JAVA_ARGS="${JAVA_ARGS} port=$httpPort"; +JAVA_ARGS="${JAVA_ARGS} sslport=$httpsPort"; +JAVA_ARGS="${JAVA_ARGS} ${JAVA_POST_ARGS}"; -java -cp ${CLASSPATH}:/opt/app/commonLibs/*:/opt/app/aai-resources/etc:/opt/app/aai-resources/lib/*:/opt/app/aai-resources/extJars/logback-access-1.1.7.jar:/opt/app/aai-resources/extJars/logback-core-1.1.7.jar:/opt/app/aai-resources/extJars/aai-core-${AAI_CORE_VERSION}.jar -server -XX:NewSize=512m -XX:MaxNewSize=512m -XX:SurvivorRatio=8 -XX:+DisableExplicitGC -verbose:gc -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:-UseBiasedLocking -XX:ParallelGCThreads=4 -XX:LargePageSizeInBytes=128m -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Dsun.net.inetaddr.ttl=180 -XX:+HeapDumpOnOutOfMemoryError -Dhttps.protocols=TLSv1.1,TLSv1.2 -DSOACLOUD_SERVICE_VERSION=1.0.1 -DAJSC_HOME=/opt/app/aai-resources/ -DAJSC_CONF_HOME=/opt/app/aai-resources/bundleconfig -DAJSC_SHARED_CONFIG=/opt/app/aai-resources/bundleconfig -DAFT_HOME=/opt/app/aai-resources -DAAI_CORE_VERSION=${AAI_CORE_VERSION} -Daai-core.version=${AAI_CORE_VERSION} -Dlogback.configurationFile=/opt/app/aai-resources/bundleconfig/etc/logback.xml -Xloggc:/opt/app/aai-resources/logs/ajsc-jetty/gc/graph-query_gc.log com.att.ajsc.runner.Runner context=/ port=8087 sslport=8447 +JAVA_CMD="exec gosu aaiadmin java"; +# Run the following command as aai-admin using gosu and make that process main +${JAVA_CMD} -cp ${CLASSPATH}:${CP} ${JVM_OPTS} ${JAVA_OPTS} com.att.ajsc.runner.Runner ${JAVA_ARGS} "$@" |