diff options
-rw-r--r-- | champ-service/src/main/bin/start.sh | 28 | ||||
-rw-r--r-- | champ-service/src/main/docker/Dockerfile | 27 |
2 files changed, 54 insertions, 1 deletions
diff --git a/champ-service/src/main/bin/start.sh b/champ-service/src/main/bin/start.sh index bf29db5..a062b63 100644 --- a/champ-service/src/main/bin/start.sh +++ b/champ-service/src/main/bin/start.sh @@ -54,6 +54,32 @@ if [ -z "$GRAPHIMPL_DEPS" ]; then exit 1 fi +# Changes related to:AAI-2175 +# Change aai champ container processes to run as non-root on the host +USER_ID=${LOCAL_USER_ID:-9001} +GROUP_ID=${LOCAL_GROUP_ID:-9001} +CHAMP_LOGS=/var/log/onap/AAI-CHAMP + +if [ $(cat /etc/passwd | grep aaiadmin | wc -l) -eq 0 ]; then + + groupadd aaiadmin -g ${GROUP_ID} || { + echo "Unable to create the group id for ${GROUP_ID}"; + exit 1; + } + useradd --shell=/bin/bash -u ${USER_ID} -g ${GROUP_ID} -o -c "" -m aaiadmin || { + echo "Unable to create the user id for ${USER_ID}"; + exit 1; + } +fi; + +chown -R aaiadmin:aaiadmin ${MICRO_HOME} +chown -R aaiadmin:aaiadmin ${APP_HOME} +chown -R aaiadmin:aaiadmin ${CHAMP_LOGS} + +find ${MICRO_HOME} -name "*.sh" -exec chmod +x {} + + +gosu aaiadmin ln -s /logs $MICRO_HOME/logs +JAVA_CMD="exec gosu aaiadmin java"; PROPS="-DAPP_HOME=$APP_HOME" PROPS="$PROPS -DCONFIG_HOME=$CONFIG_HOME" PROPS="$PROPS -Dlogging.config=$APP_HOME/bundleconfig/etc/logback.xml" @@ -70,4 +96,4 @@ fi JVM_MAX_HEAP=${MAX_HEAP:-1024} set -x -exec java -Xmx${JVM_MAX_HEAP}m $PROPS -Dloader.path="${GRAPHIMPL_DEPS}" -jar "${APP_HOME}/champ-service.jar" +${JAVA_CMD} -Xmx${JVM_MAX_HEAP}m $PROPS -Dloader.path="${GRAPHIMPL_DEPS}" -jar "${APP_HOME}/champ-service.jar" diff --git a/champ-service/src/main/docker/Dockerfile b/champ-service/src/main/docker/Dockerfile index df0ef2d..501491f 100644 --- a/champ-service/src/main/docker/Dockerfile +++ b/champ-service/src/main/docker/Dockerfile @@ -3,6 +3,33 @@ FROM @aai.docker.namespace@/aai-common-@aai.base.image@:@aai.base.image.version@ ARG MICRO_HOME=/opt/app/champ-service ARG BIN_HOME=$MICRO_HOME/bin ARG GRAPHLIB_HOME=$MICRO_HOME/graph-deps +#AAI-2175 Additional optional steps for Ubuntu +RUN if ((uname -v | grep -i "ubuntu") || ( cat /etc/*release|grep -i "ubuntu") ) ; then \ + ##################################### + #if JAVA doesnt exist then install it: + ###################################### + if type java 2>/dev/null; then \ + echo "skipping java installation"; \ + else \ + apt-get update && apt-get install -y software-properties-common; \ + ## sudo -E is required to preserve the environment. If you remove that line, it will most like freeze at this step + sudo -E add-apt-repository ppa:openjdk-r/ppa && apt-get update && apt-get install -y openjdk-8-jdk ; \ + ## Setup JAVA_HOME, this is useful for docker commandline + JAVA_HOME=usr/lib/jvm/java-8-openjdk-amd64; \ + export JAVA_HOME ; \ + fi; \ + ########################################## + #Install gosu if not present + ########################################## + if type gosu 2>/dev/null; then \ + echo "skipping gosu installation"; \ + else \ + set -x ; \ + add-apt-repository -y ppa:tianon/gosu; \ + sudo apt-get update; \ + sudo apt-get install gosu; \ + fi;\ +fi # Build up the deployment folder structure RUN mkdir -p $MICRO_HOME |