From ad589b35655d6569d770267c5b6ccb7289c2e3e1 Mon Sep 17 00:00:00 2001 From: Jimmy Forsyth Date: Wed, 28 Aug 2019 14:40:35 -0400 Subject: Add docker profile for Alpine Issue-ID: AAI-2579 Change-Id: I5aed586722aab30cb6dae5e57f5a1dc6f32f5c1c Signed-off-by: Jimmy Forsyth --- src/main/assembly/descriptor.xml | 36 +++++++ src/main/bin/start.sh | 21 +++-- src/main/docker/Dockerfile | 23 +---- src/main/resources/logback.xml | 199 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 255 insertions(+), 24 deletions(-) create mode 100644 src/main/assembly/descriptor.xml create mode 100644 src/main/resources/logback.xml (limited to 'src') diff --git a/src/main/assembly/descriptor.xml b/src/main/assembly/descriptor.xml new file mode 100644 index 0000000..3fcef5b --- /dev/null +++ b/src/main/assembly/descriptor.xml @@ -0,0 +1,36 @@ + + build + false + + dir + + + + ${project.basedir}/src/main/resources + / + + logback.xml + + + + ${project.basedir}/src/main/bin + /bin + + **/* + + + + ${project.build.directory} + / + + ${project.artifactId}-${project.version}.jar + + + Dockerfile + *.sh + + + + diff --git a/src/main/bin/start.sh b/src/main/bin/start.sh index 8c4cdf5..f4707ad 100644 --- a/src/main/bin/start.sh +++ b/src/main/bin/start.sh @@ -19,16 +19,23 @@ # limitations under the License. # ============LICENSE_END========================================================= +# jre-alpine image has $JAVA_HOME set and added to $PATH +# ubuntu image requires to set $JAVA_HOME and add java to $PATH manually +if ( uname -v | grep -i "ubuntu" ); then + export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-`dpkg --print-architecture | awk -F- '{ print $NF }'` + export PATH=${JAVA_HOME}:$PATH +fi + APP_HOME="${APP_HOME:-/opt/app/babel}" if [ -z "${CONFIG_HOME}" ]; then - echo "CONFIG_HOME must be set in order to start the process" - exit 1 + echo "CONFIG_HOME must be set in order to start the process" + exit 1 fi if [ -z "${KEY_STORE_PASSWORD}" ]; then - echo "KEY_STORE_PASSWORD must be set in order to start the process" - exit 1 + echo "KEY_STORE_PASSWORD must be set in order to start the process" + exit 1 fi PROPS="-DAPP_HOME=${APP_HOME}" @@ -36,9 +43,11 @@ PROPS="${PROPS} -DCONFIG_HOME=${CONFIG_HOME}" PROPS="${PROPS} -Dtosca.mappings.config=${CONFIG_HOME}/tosca-mappings.json" PROPS="${PROPS} -DKEY_STORE_PASSWORD=${KEY_STORE_PASSWORD}" if [ ! -z "$REQUIRE_CLIENT_AUTH" ]; then - PROPS="$PROPS -Dserver.ssl.client-auth=${REQUIRE_CLIENT_AUTH}" + PROPS="$PROPS -Dserver.ssl.client-auth=${REQUIRE_CLIENT_AUTH}" fi JVM_MAX_HEAP=${MAX_HEAP:-1024} -exec java -Xmx${JVM_MAX_HEAP}m ${PROPS} -jar ${APP_HOME}/babel.jar +JARFILE=$(ls ./babel*.jar); + +exec java -Xmx${JVM_MAX_HEAP}m ${PROPS} -jar ${APP_HOME}/${JARFILE} diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile index 70088ae..03917f7 100644 --- a/src/main/docker/Dockerfile +++ b/src/main/docker/Dockerfile @@ -1,25 +1,12 @@ -FROM ubuntu:14.04 +FROM @aai.docker.namespace@/aai-common-@aai.base.image@:@aai.base.image.version@ ARG MICRO_HOME=/opt/app/babel -ARG BIN_HOME=$MICRO_HOME/bin -ARG JAR_FILE=babel.jar - -RUN apt-get update - -# Install and setup java8 -RUN 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 -RUN 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 -ENV JAVA_HOME usr/lib/jvm/java-8-openjdk-amd64 -RUN export JAVA_HOME # Build up the deployment folder structure RUN mkdir -p $MICRO_HOME -COPY ${JAR_FILE} $MICRO_HOME -RUN mkdir -p $BIN_HOME -COPY *.sh $BIN_HOME -RUN chmod 755 $BIN_HOME/* -RUN ln -s /logs $MICRO_HOME/logs +WORKDIR $MICRO_HOME +COPY /maven/babel/ . +RUN chmod 755 bin/* \ + && ln -s /logs $MICRO_HOME/logs CMD ["/opt/app/babel/bin/start.sh"] diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 0000000..f494b08 --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${logDirectory}/${generalLogName}.log + + ${logDirectory}/${generalLogName}.%d{yyyy-MM-dd}.log.zip + + 60 + + + ${errorLogPattern} + + + + + + INFO + + 256 + + + + + + + ${logDirectory}/${auditLogName}.log + + ${logDirectory}/${auditLogName}.%d{yyyy-MM-dd}.log.zip + + 60 + + + ${auditLogPattern} + + + + 256 + + + + + ${logDirectory}/${metricsLogName}.log + + ${logDirectory}/${metricsLogName}.%d{yyyy-MM-dd}.log.zip + + 60 + + + ${metricsLogPattern} + + + + + 256 + + + + + + ${logDirectory}/${debugLogName}.log + + + ${logDirectory}/${debugLogName}.%d{yyyy-MM-dd}.log.zip + + 60 + + + ${errorLogPattern} + + + + + + + + + e.level.toInt() < INFO.toInt() + + + DENY + NEUTRAL + + 256 + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit