#!/bin/bash # # Copyright 2016-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. # # $1 dirsrc # $2 autorelease build set -e dirsrc=$1 if [ -z "$2" ]; then BUILD="snapshots" else BUILD=$2 fi VERSION="1.1.0-SNAPSHOT" # docker root dir ROOT=`git rev-parse --show-toplevel`/test/csit/docker cd $ROOT dir=$dirsrc/target mkdir -p $dir if [ "$BUILD" = "snapshots" ]; then $ROOT/scripts/gen-dockerfiles.py $dirsrc else $ROOT/scripts/gen-dockerfiles.py $dirsrc --build $BUILD fi # Update build number in workaround files for file in `find $dirsrc -name 80-workaround.txt`; do sed -i "s|autorelease-[0-9]\{4\}|$BUILD|" $file done cp $ROOT/../../../distribution/LICENSE $dir cp -f $dirsrc/*.txt $dir 2>/dev/null || : if [ -f $dir/20-mysql.txt ]; then cp $ROOT/templates/init-mysql.sh $dir/init-mysql.sh else rm -f $dir/init-mysql.sh fi # empty 30-tomcat.txt would be created by gen-dockerfiles.py where required if [ -f $dir/30-tomcat.txt ]; then TOMCAT_VERSION=`$ROOT/scripts/get-tomcat-version.sh` cat > $dir/30-tomcat.txt < /service/bin/setenv.sh ENV CATALINA_HOME /service EOF fi cat > $dir/docker-entrypoint.sh <> $dir/docker-entrypoint.sh <:" exit 1 fi echo "MSB_ADDR=\$MSB_ADDR" echo # Wait for MSB initialization echo Wait for MSB initialization for i in {1..20}; do curl -sS -m 1 \$MSB_ADDR > /dev/null && break sleep \$i done EOF fi cat >> $dir/docker-entrypoint.sh <> $dir/docker-entrypoint.sh <> $dir/docker-entrypoint.sh <> $dir/docker-entrypoint.sh <> $dir/docker-entrypoint.sh <> $dir/docker-entrypoint.sh < init.log fi # Start the microservice ./instance-run.sh EOF cat > $dir/Dockerfile <> $dir/Dockerfile for file in instance-config.sh instance-init.sh instance-run.sh instance-workaround.sh; do if [ ! -f $dirsrc/$file ]; then cp -n $ROOT/templates/instance-script.sh $dirsrc/$file fi done cp -f $dirsrc/instance-*.sh $dir touch $dir/instance-config.sh touch $dir/instance-init.sh touch $dir/instance-run.sh touch $dir/instance-workaround.sh chmod +x $dir/*.sh cat > $dir/pom.xml < 4.0.0 org.openo.integration.docker ${dirsrc} ${VERSION} docker io.fabric8 docker-maven-plugin 0.19.0 true openoint/${dirsrc} . latest EOF