aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuabingZhao <zhao.huabing@zte.com.cn>2017-08-15 19:22:03 +0800
committerHuabingZhao <zhao.huabing@zte.com.cn>2017-08-15 19:22:35 +0800
commit71488f1e6342dc8beaf26e633b6967b936c22c05 (patch)
treec6641fab148d61dc57cc45b2eeb252148d1aee00
parent86d68833aff7d24895a9512ab6fff0ed8439d753 (diff)
Add dockerfile for base image
Issue_Id: MSB-19 Change-Id: I4b1408a489a45052927fcc978e4803b545e06e06 Signed-off-by: HuabingZhao <zhao.huabing@zte.com.cn>
-rw-r--r--build4basedocker.sh46
-rw-r--r--distributions/msb-apigateway/src/main/basedocker/Dockerfile77
-rw-r--r--distributions/msb-apigateway/src/main/docker/Dockerfile13
3 files changed, 131 insertions, 5 deletions
diff --git a/build4basedocker.sh b/build4basedocker.sh
new file mode 100644
index 0000000..0f575cb
--- /dev/null
+++ b/build4basedocker.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+#
+# Copyright 2016-2017 ZTE, Inc. and others.
+#
+# 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.
+#
+
+
+DIRNAME=`dirname $0`
+RUNHOME=`cd $DIRNAME/; pwd`
+echo @RUNHOME@ $RUNHOME
+
+#cooy
+RELEASE_BASE_DIR=$RUNHOME/release
+echo @RELEASE_BASE_DIR@ $RELEASE_BASE_DIR
+
+RELEASE_DIR=${RELEASE_BASE_DIR}/msb-base
+rm -rf $RELEASE_DIR
+mkdir $RELEASE_DIR -p
+
+DOCKER_IMAGE_NAME=msb_base
+DOCKER_RELEASE_VERSION=latest
+
+cp -r $RUNHOME/distributions/msb-apigateway/src/main/basedocker/* ${RELEASE_DIR}
+cp $RUNHOME/ci/build_docker_image.sh ${RELEASE_DIR}
+#build docker image
+cd ${RELEASE_DIR}
+chmod +x build_docker_image.sh
+
+
+
+docker rmi ${DOCKER_IMAGE_NAME}:${DOCKER_RELEASE_VERSION}
+
+./build_docker_image.sh -n=${DOCKER_IMAGE_NAME} -v=${DOCKER_RELEASE_VERSION} -d=./docker
+
+
diff --git a/distributions/msb-apigateway/src/main/basedocker/Dockerfile b/distributions/msb-apigateway/src/main/basedocker/Dockerfile
new file mode 100644
index 0000000..02af8b1
--- /dev/null
+++ b/distributions/msb-apigateway/src/main/basedocker/Dockerfile
@@ -0,0 +1,77 @@
+# Dockerfile - msb-base
+FROM openresty/openresty:alpine
+
+#install java-1.8-openjdk
+
+ENV LANG C.UTF-8
+
+# add a simple script that can auto-detect the appropriate JAVA_HOME value
+# based on whether the JDK or only the JRE is installed
+RUN { \
+ echo '#!/bin/sh'; \
+ echo 'set -e'; \
+ echo; \
+ echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
+ } > /usr/local/bin/docker-java-home \
+ && chmod +x /usr/local/bin/docker-java-home
+ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk
+ENV PATH $PATH:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin
+
+ENV JAVA_VERSION 8u131
+ENV JAVA_ALPINE_VERSION 8.131.11-r2
+
+RUN set -x \
+ && apk add --no-cache \
+ openjdk8="$JAVA_ALPINE_VERSION" \
+ && [ "$JAVA_HOME" = "$(docker-java-home)" ]
+
+#install redis
+
+# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
+RUN addgroup -S redis && adduser -S -G redis redis
+
+# grab su-exec for easy step-down from root
+RUN apk add --no-cache 'su-exec>=0.2'
+
+ENV REDIS_VERSION 4.0.1
+ENV REDIS_DOWNLOAD_URL http://download.redis.io/releases/redis-4.0.1.tar.gz
+ENV REDIS_DOWNLOAD_SHA 2049cd6ae9167f258705081a6ef23bb80b7eff9ff3d0d7481e89510f27457591
+
+# for redis-sentinel see: http://redis.io/topics/sentinel
+RUN set -ex; \
+ \
+ apk add --no-cache --virtual .build-deps \
+ coreutils \
+ gcc \
+ linux-headers \
+ make \
+ musl-dev \
+ ; \
+ \
+ wget -O redis.tar.gz "$REDIS_DOWNLOAD_URL"; \
+ echo "$REDIS_DOWNLOAD_SHA *redis.tar.gz" | sha256sum -c -; \
+ mkdir -p /usr/src/redis; \
+ tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \
+ rm redis.tar.gz; \
+ \
+# disable Redis protected mode [1] as it is unnecessary in context of Docker
+# (ports are not automatically exposed when running inside Docker, but rather explicitly by specifying -p / -P)
+# [1]: https://github.com/antirez/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da
+ grep -q '^#define CONFIG_DEFAULT_PROTECTED_MODE 1$' /usr/src/redis/src/server.h; \
+ sed -ri 's!^(#define CONFIG_DEFAULT_PROTECTED_MODE) 1$!\1 0!' /usr/src/redis/src/server.h; \
+ grep -q '^#define CONFIG_DEFAULT_PROTECTED_MODE 0$' /usr/src/redis/src/server.h; \
+# for future reference, we modify this directly in the source instead of just supplying a default configuration flag because apparently "if you specify any argument to redis-server, [it assumes] you are going to specify everything"
+# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840
+# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default)
+ \
+ make -C /usr/src/redis -j "$(nproc)"; \
+ make -C /usr/src/redis install; \
+ \
+ rm -r /usr/src/redis; \
+ mkdir /usr/local/redis; \
+ cd /usr/local/bin; \
+ mv redis-server redis-cli /usr/local/redis; \
+ \
+ apk del .build-deps
+
+
diff --git a/distributions/msb-apigateway/src/main/docker/Dockerfile b/distributions/msb-apigateway/src/main/docker/Dockerfile
index 8762900..18891c2 100644
--- a/distributions/msb-apigateway/src/main/docker/Dockerfile
+++ b/distributions/msb-apigateway/src/main/docker/Dockerfile
@@ -1,6 +1,9 @@
-FROM alpine:3.5
-ADD msb-apigateway*.tar.gz /opt/application
+# Dockerfile - msb-apigateway
+FROM msb_base:latest
+COPY msb-apigateway*.tar.gz /usr/src
-ENV LD_LIBRARY_PATH /lib64
-WORKDIR /opt/application/msb-apigateway
-ENTRYPOINT exec $PWD/startup4docker.sh \ No newline at end of file
+RUN tar -xzf /usr/src/msb-apigateway*.tar.gz -C /usr/local --strip-components=1; \
+ rm /usr/src/msb-apigateway*.tar.gz
+
+WORKDIR /usr/local
+ENTRYPOINT exec $PWD/startup4docker.sh