diff options
author | luxin <luxin7@huawei.com> | 2018-03-28 11:36:40 +0800 |
---|---|---|
committer | luxin <luxin7@huawei.com> | 2018-03-28 11:36:40 +0800 |
commit | fd6abf9f3c76a4e2eedc45f007e001427b8b0eae (patch) | |
tree | 5a93a487e7c4fac2bc824d0d76eed459e8854fd7 | |
parent | 5e3ad2aeed27bd318ed6e7bb9d3180a02b9e3ccf (diff) |
Add docker script for multivimproxy
Change-Id: Ieaccc9b3225587d6c7f36b9b217a45356a133ba7
Issue-ID: VFC-644
Signed-off-by: luxin <luxin7@huawei.com>
-rw-r--r-- | docker/Dockerfile | 59 | ||||
-rw-r--r-- | docker/build_image.sh | 45 | ||||
-rw-r--r-- | docker/docker-entrypoint.sh | 68 | ||||
-rw-r--r-- | docker/instance-config.sh | 24 | ||||
-rw-r--r-- | docker/instance-init.sh | 22 | ||||
-rw-r--r-- | docker/instance-run.sh | 23 | ||||
-rw-r--r-- | docker/instance-workaround.sh | 16 |
7 files changed, 257 insertions, 0 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..9a002df --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,59 @@ +# +# This file was auto-generated by gen-all-dockerfiles.sh; do not modify manually. +# +# nfvo-multivimproxy/target/Dockerfile +# + +# 10-basebuild.txt + +FROM centos:7 + +RUN sed -i 's/enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf +RUN sed -i 's|#baseurl=http://mirror.centos.org/centos|baseurl=http://mirrors.ocf.berkeley.edu/centos|' /etc/yum.repos.d/*.repo +RUN yum update -y + +RUN yum install -y wget unzip socat java-1.8.0-openjdk-headless +RUN sed -i 's|#networkaddress.cache.ttl=-1|networkaddress.cache.ttl=10|' /usr/lib/jvm/jre/lib/security/java.security +ENV JAVA_HOME /usr/lib/jvm/jre + +WORKDIR /service + +# 20-mysql.txt + +# Set up mysql +#RUN wget -q http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm && rpm -ivh mysql-community-release-el7-5.noarch.rpm && rm -f mysql-community-release-el7-5.noarch.rpm +#RUN yum -y update +#RUN yum -y install -y mysql-server +#RUN mysql_install_db --user=mysql --datadir=/var/lib/mysql +#COPY init-mysql.sh . + +# 30-tomcat.txt - AUTOGENERATED, DO NOT MODIFY MANUALLY +# Set up tomcat +RUN wget -q http://mirrors.ocf.berkeley.edu/apache/tomcat/tomcat-8/v8.5.29/bin/apache-tomcat-8.5.29.tar.gz && tar --strip-components=1 -xf apache-tomcat-8.5.29.tar.gz && rm -f apache-tomcat-8.5.29.tar.gz && rm -rf webapps && mkdir -p webapps/ROOT +RUN echo 'export CATALINA_OPTS="$CATALINA_OPTS -Xms64m -Xmx256m -XX:MaxPermSize=64m"' > /service/bin/setenv.sh +ENV CATALINA_HOME /service + +# 50-microservice.txt - AUTOGENERATED, DO NOT MODIFY MANUALLY + +# Set up microservice + +RUN wget -q -O nfvo-multivimproxy.zip "https://nexus.onap.org/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.vfc.nfvo.multivimproxy&a=vfc-nfvo-multivimproxy-deployment&v=LATEST&e=zip" && unzip -q -o -B nfvo-multivimproxy.zip && rm -f nfvo-multivimproxy.zip +# Set permissions +RUN find . -type d -exec chmod o-w {} \; +RUN find . -name "*.sh" -exec chmod +x {} \; +EXPOSE 8486 + + + +# 90-entrypoint.txt + +RUN yum clean all + +COPY instance-config.sh . +COPY instance-init.sh . +COPY instance-run.sh . +COPY instance-workaround.sh . +COPY docker-entrypoint.sh . +ENTRYPOINT /service/docker-entrypoint.sh + +COPY LICENSE ./ONAP_LICENSE diff --git a/docker/build_image.sh b/docker/build_image.sh new file mode 100644 index 0000000..97e846d --- /dev/null +++ b/docker/build_image.sh @@ -0,0 +1,45 @@ +#!/bin/bash +DIRNAME=`dirname $0` +DOCKER_BUILD_DIR=`cd $DIRNAME/; pwd` +echo "DOCKER_BUILD_DIR=${DOCKER_BUILD_DIR}" +cd ${DOCKER_BUILD_DIR} + +BUILD_ARGS="--no-cache" +ORG="onap" +VERSION="1.0.0" +PROJECT="vfc" +IMAGE="multivimproxy" +DOCKER_REPOSITORY="nexus3.onap.org:10003" +IMAGE_NAME="${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/${IMAGE}" +TIMESTAMP=$(date +"%Y%m%dT%H%M%S") + +if [ $HTTP_PROXY ]; then + BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}" +fi +if [ $HTTPS_PROXY ]; then + BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}" +fi + +function build_image { + echo "Start build docker image: ${IMAGE_NAME}" + docker build ${BUILD_ARGS} -t ${IMAGE_NAME}:latest . +} + +function push_image_tag { + TAG_NAME=$1 + echo "Start push ${TAG_NAME}" + docker tag ${IMAGE_NAME}:latest ${TAG_NAME} + docker push ${TAG_NAME} +} + +function push_image { + echo "Start push ${IMAGE_NAME}:latest" + docker push ${IMAGE_NAME}:latest + + push_image_tag ${IMAGE_NAME}:${VERSION}-SNAPSHOT-latest + push_image_tag ${IMAGE_NAME}:${VERSION}-STAGING-latest + push_image_tag ${IMAGE_NAME}:${VERSION}-STAGING-${TIMESTAMP} +} + +build_image +push_image diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh new file mode 100644 index 0000000..07ba258 --- /dev/null +++ b/docker/docker-entrypoint.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# +# Copyright 2017 Huawei Technologies Co., Ltd. +# +# 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. +# +# +# This file was auto-generated by gen-all-dockerfiles.sh; do not modify manually. +# +# nfvo-multivimproxy/target/docker-entrypoint.sh +# + +if [ -z "$SERVICE_IP" ]; then + export SERVICE_IP=`hostname -i` +fi +echo +echo Environment Variables: +echo "SERVICE_IP=$SERVICE_IP" + +if [ -z "$MSB_ADDR" ]; then + echo "Missing required variable MSB_ADDR: Microservices Service Bus address <ip>:<port>" + exit 1 +fi +echo "MSB_ADDR=$MSB_ADDR" +echo + +# Wait for MSB initialization +echo Wait for MSB initialization +for i in {1..10}; do + curl -sS -m 1 $MSB_ADDR > /dev/null && break + sleep $i +done + +echo + +# Configure service based on docker environment variables +./instance-config.sh + +# Start mysql +#su mysql -c /usr/bin/mysqld_safe & + +# Perform one-time config +if [ ! -e init.log ]; then + # Perform workarounds due to defects in release binary + ./instance-workaround.sh + + # Init mysql; set root password + #./init-mysql.sh + + # microservice-specific one-time initialization + ./instance-init.sh + + date > init.log +fi + +# Start the microservice +./instance-run.sh + diff --git a/docker/instance-config.sh b/docker/instance-config.sh new file mode 100644 index 0000000..5b6b504 --- /dev/null +++ b/docker/instance-config.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# +# Copyright 2017 Huawei Technologies Co., Ltd. +# +# 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. +# +# Config MSB address +MSB_IP=`echo $MSB_ADDR | cut -d: -f 1` +sed -i "s|127\.0\.0\.1|${MSB_IP}|" etc/conf/restclient.json +cat etc/conf/restclient.json + +# Set self IP +sed -i "s|127\.0\.0\.1|$SERVICE_IP|" etc/adapterInfo/adapterinfo.json +cat etc/adapterInfo/adapterinfo.json diff --git a/docker/instance-init.sh b/docker/instance-init.sh new file mode 100644 index 0000000..1185d9a --- /dev/null +++ b/docker/instance-init.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +# Copyright 2017 Huawei Technologies Co., Ltd. +# +# 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. +# +# Set mysql root password +#sed -i 's|rootpass|rootpass|' ./webapps/ROOT/WEB-INF/classes/spring/Resmanagement/services.xml + +# Initialize MySQL schema +#cd bin +#./init_db.sh root rootpass 127.0.0.1 3306 diff --git a/docker/instance-run.sh b/docker/instance-run.sh new file mode 100644 index 0000000..88eec7c --- /dev/null +++ b/docker/instance-run.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# +# Copyright 2017 Huawei Technologies Co., Ltd. +# +# 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. +# +# Start microservice +cd bin +./start.sh +while [ ! -e ../logs/multivimproxy.log ]; do + sleep 1 +done +tail -F ../logs/multivimproxy.log diff --git a/docker/instance-workaround.sh b/docker/instance-workaround.sh new file mode 100644 index 0000000..40058f5 --- /dev/null +++ b/docker/instance-workaround.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# +# Copyright 2017 Huawei Technologies Co., Ltd. +# +# 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. +# |