From 6e8ef8ac3a9f9504ff4a5ea9991197010930d834 Mon Sep 17 00:00:00 2001 From: Kiran Kamineni Date: Tue, 20 Mar 2018 15:12:13 -0700 Subject: [PATCH] Adding bash script to call docker build Adding the necessary bash scripts to be called for docker build These will be called by the jenkins job for the nightly docker build Issue-ID: AAF-100 Change-Id: Iae0c095d44849ae65583247fc7026f313d1ee0b7 Signed-off-by: Kiran Kamineni --- sms-service/bin/Dockerfile | 35 +++++++---------------------- sms-service/bin/LICENSE.txt | 18 +++++++++++++++ sms-service/bin/build_image.sh | 45 +++++++++++++++++++++++++++++++++++++ sms-service/bin/make_build_image.sh | 9 ++++++++ 4 files changed, 80 insertions(+), 27 deletions(-) create mode 100644 sms-service/bin/LICENSE.txt create mode 100755 sms-service/bin/build_image.sh create mode 100755 sms-service/bin/make_build_image.sh diff --git a/sms-service/bin/Dockerfile b/sms-service/bin/Dockerfile index 9e9863b..d663f80 100644 --- a/sms-service/bin/Dockerfile +++ b/sms-service/bin/Dockerfile @@ -1,33 +1,14 @@ FROM alpine:3.7 -MAINTAINER onap-aaf-sms +MAINTAINER aaf-sms -ENV VAULT_VERSION 0.9.4 -ENV CONSUL_VERSION 1.0.1 - -LABEL name="sms-vault-consul" -LABEL version=0.0.1 +LABEL name="aaf-sms" +LABEL version=1.0.0 LABEL maintainer="vamshi krishna " +EXPOSE 10443 - ADD https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip /tmp/vault.zip - RUN unzip -d /bin /tmp/vault.zip && \ - chmod 755 /bin/vault && \ - rm /tmp/vault.zip - - ADD https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip /tmp/consul.zip - RUN unzip -d /bin /tmp/consul.zip && \ - chmod 755 /bin/consul && \ - rm /tmp/consul.zip - - -EXPOSE 8200 -VOLUME "/config" -ADD ./config /config/ - -ENTRYPOINT ["/bin/consul"] -CMD ["agent", "-config-file", "config/consul.json"] - - -ENTRYPOINT ["/bin/vault"] -CMD ["server", "-config", "config/vault.hcl"] +ADD auth /sms/auth/ +ADD sms /sms/bin/sms +RUN chmod +x /sms/bin/sms +ENTRYPOINT ["/sms/bin/sms"] \ No newline at end of file diff --git a/sms-service/bin/LICENSE.txt b/sms-service/bin/LICENSE.txt new file mode 100644 index 0000000..5f63bb7 --- /dev/null +++ b/sms-service/bin/LICENSE.txt @@ -0,0 +1,18 @@ + + ============LICENSE_START========================================== + =================================================================== + Copyright © 2018 Intel Corp, Inc + All rights reserved. + =================================================================== + 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. + ============LICENSE_END============================================ diff --git a/sms-service/bin/build_image.sh b/sms-service/bin/build_image.sh new file mode 100755 index 0000000..3e29c0c --- /dev/null +++ b/sms-service/bin/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.1.0" +PROJECT="aaf" +IMAGE="sms" +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 \ No newline at end of file diff --git a/sms-service/bin/make_build_image.sh b/sms-service/bin/make_build_image.sh new file mode 100755 index 0000000..5281f42 --- /dev/null +++ b/sms-service/bin/make_build_image.sh @@ -0,0 +1,9 @@ +#!/bin/bash +DIRNAME=`dirname $0` +DOCKER_BUILD_DIR=`cd $DIRNAME/; pwd` +cd ${DOCKER_BUILD_DIR} + +(cd ../src/sms && make build) +cp ../target/sms . + +sudo ./build_image.sh -- 2.16.6