blob: cdd97fc710d9c5016a979f9c3cb767db1846d889 [file] [log] [blame]
Instrumental4ad47632018-07-13 15:49:26 -05001#!/bin/bash
Instrumental7a1817b2018-11-05 11:11:15 -06002#########
3# ============LICENSE_START====================================================
4# org.onap.aaf
5# ===========================================================================
6# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
7# ===========================================================================
8# Licensed under the Apache License, Version 2.0 (the "License");
9# you may not use this file except in compliance with the License.
10# You may obtain a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing, software
15# distributed under the License is distributed on an "AS IS" BASIS,
16# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17# See the License for the specific language governing permissions and
18# limitations under the License.
19# ============LICENSE_END====================================================
Sai Gandham66118342018-04-04 15:33:05 -050020#
21# Docker Building Script. Reads all the components generated by install, on per-version basis
22#
sandovalfrd6bda192019-03-21 14:21:09 -060023
24DOCKER_PULL_REGISTRY='nexus3.onap.org:10001\/'
25AAF_COMPONENTS=ALL
26
27# process input. originally, an optional positional parameter is used to designate a component.
28# A flagged parameter has been added to optionally indicate docker pull registry. Ideally, options
29# would be flagged but we're avoiding ripple effect of changing original usage
30if [ $# -gt 0 ]; then
31 if [ "$1" == "-r" ]; then
32 DOCKER_PULL_REGISTRY=$2
33 else
34 AAF_COMPONENTS=$1
35 if [[ $# -gt 1 && $2 == "-r" ]]; then
36 # If docker.io is indicated, registry var is void as that is docker default
37 if [ $3 == "docker.io" ]; then
38 DOCKER_PULL_REGISTRY=''
39 else
40 DOCKER_PULL_REGISTRY=$3
41 fi
42 fi
43 fi
44fi
45
46echo "$0: AAF_COMPONENTS=$AAF_COMPONENTS DOCKER_PULL_REGISTRY=$DOCKER_PULL_REGISTRY"
47
Instrumental924b18d2018-04-05 20:17:18 -050048# Pull in Variables from d.props
Instrumental9ec28952018-07-12 11:14:10 -050049if [ ! -e ./d.props ]; then
Instrumental4ad47632018-07-13 15:49:26 -050050 cp d.props.init d.props
Instrumental9ec28952018-07-12 11:14:10 -050051fi
52
Instrumentalf482ea02018-04-10 15:03:24 -050053. ./d.props
Instrumental9ec28952018-07-12 11:14:10 -050054
Instrumental94053612018-10-08 11:27:18 -050055DOCKER=${DOCKER:=docker}
56
Instrumentalbc299c02018-09-25 06:42:31 -050057echo "Building Containers for aaf components, version $VERSION"
58
Instrumental3019a282018-09-25 16:05:20 -050059# AAF_cass now needs a version...
Instrumental3505a522019-01-31 14:49:24 -060060cd ../auth-cass/docker
sandovalfrd6bda192019-03-21 14:21:09 -060061bash ./dbuild.sh $DOCKER_PULL_REGISTRY
Instrumental3505a522019-01-31 14:49:24 -060062cd -
Instrumental12414fe2019-01-22 10:27:32 -060063
64# AAF Base version - set the core image, etc
65sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
Instrumental628b7102019-02-15 19:40:04 -060066 -e 's/${DUSER}/'${DUSER}'/g' \
sandovalfrd6bda192019-03-21 14:21:09 -060067 -e 's/${REGISTRY}/'${DOCKER_PULL_REGISTRY}'/g' \
Instrumental12414fe2019-01-22 10:27:32 -060068 Dockerfile.base > Dockerfile
69$DOCKER build -t ${ORG}/${PROJECT}/aaf_base:${VERSION} .
70$DOCKER tag ${ORG}/${PROJECT}/aaf_base:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_base:${VERSION}
71$DOCKER tag ${ORG}/${PROJECT}/aaf_base:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_base:latest
72rm Dockerfile
Instrumental3019a282018-09-25 16:05:20 -050073
Instrumental32cdd552018-07-19 13:29:32 -050074# Create the AAF Config (Security) Images
Instrumental9ec28952018-07-12 11:14:10 -050075cd ..
Instrumental9fe11532018-10-23 17:40:47 -050076cp auth-cmd/target/aaf-auth-cmd-$VERSION-full.jar sample/bin
Instrumentale2fa0e62019-02-07 11:09:32 -060077cp auth-batch/target/aaf-auth-batch-$VERSION-full.jar sample/bin
Instrumentalbc299c02018-09-25 06:42:31 -050078cp -Rf ../conf/CA sample
Instrumental32cdd552018-07-19 13:29:32 -050079
Instrumental12414fe2019-01-22 10:27:32 -060080
Instrumental32cdd552018-07-19 13:29:32 -050081# AAF Config image (for AAF itself)
Instrumental12414fe2019-01-22 10:27:32 -060082sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
83 -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
84 -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
Instrumental628b7102019-02-15 19:40:04 -060085 -e 's/${DUSER}/'${DUSER}'/g' \
Instrumental12414fe2019-01-22 10:27:32 -060086 docker/Dockerfile.config > sample/Dockerfile
Instrumental94053612018-10-08 11:27:18 -050087$DOCKER build -t ${ORG}/${PROJECT}/aaf_config:${VERSION} sample
88$DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_config:${VERSION}
Instrumental3505a522019-01-31 14:49:24 -060089$DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_config:latest
Instrumental32cdd552018-07-19 13:29:32 -050090
Instrumental93871ff2018-10-15 07:37:28 -050091cp ../cadi/servlet-sample/target/aaf-cadi-servlet-sample-${VERSION}-sample.jar sample/bin
Instrumental32cdd552018-07-19 13:29:32 -050092# AAF Agent Image (for Clients)
Instrumental12414fe2019-01-22 10:27:32 -060093sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
94 -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
95 -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
Instrumental628b7102019-02-15 19:40:04 -060096 -e 's/${DUSER}/'${DUSER}'/g' \
Instrumental12414fe2019-01-22 10:27:32 -060097 docker/Dockerfile.client > sample/Dockerfile
Instrumental94053612018-10-08 11:27:18 -050098$DOCKER build -t ${ORG}/${PROJECT}/aaf_agent:${VERSION} sample
99$DOCKER tag ${ORG}/${PROJECT}/aaf_agent:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_agent:${VERSION}
100$DOCKER tag ${ORG}/${PROJECT}/aaf_agent:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_agent:latest
Instrumental32cdd552018-07-19 13:29:32 -0500101
102# Clean up
Instrumentale2fa0e62019-02-07 11:09:32 -0600103rm sample/Dockerfile sample/bin/aaf-*-${VERSION}-full.jar sample/bin/aaf-cadi-servlet-sample-${VERSION}-sample.jar
Instrumentalbc299c02018-09-25 06:42:31 -0500104rm -Rf sample/CA
Instrumental9ec28952018-07-12 11:14:10 -0500105cd -
Instrumental365638c2018-10-01 15:26:03 -0500106
Instrumental32cdd552018-07-19 13:29:32 -0500107########
Instrumental9ec28952018-07-12 11:14:10 -0500108# Second, build a core Docker Image
109echo Building aaf_$AAF_COMPONENT...
110# Apply currrent Properties to Docker file, and put in place.
Instrumental12414fe2019-01-22 10:27:32 -0600111sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
112 -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
113 -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
Instrumental628b7102019-02-15 19:40:04 -0600114 -e 's/${DUSER}/'${DUSER}'/g' \
Instrumental12414fe2019-01-22 10:27:32 -0600115 Dockerfile.core >../aaf_${VERSION}/Dockerfile
Instrumental9ec28952018-07-12 11:14:10 -0500116cd ..
Instrumental94053612018-10-08 11:27:18 -0500117$DOCKER build -t ${ORG}/${PROJECT}/aaf_core:${VERSION} aaf_${VERSION}
118$DOCKER tag ${ORG}/${PROJECT}/aaf_core:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_core:${VERSION}
119$DOCKER tag ${ORG}/${PROJECT}/aaf_core:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_core:latest
Instrumental9ec28952018-07-12 11:14:10 -0500120rm aaf_${VERSION}/Dockerfile
121cd -
Sai Gandham66118342018-04-04 15:33:05 -0500122
Instrumental93871ff2018-10-15 07:37:28 -0500123#######
124# Do all the Containers related to AAF Services
125#######
sandovalfrd6bda192019-03-21 14:21:09 -0600126if [ $AAF_COMPONENTS == "ALL" ]; then
Instrumental93871ff2018-10-15 07:37:28 -0500127 AAF_COMPONENTS=$(ls ../aaf_${VERSION}/bin | grep -v '\.')
Sai Gandham66118342018-04-04 15:33:05 -0500128fi
sandovalfrd6bda192019-03-21 14:21:09 -0600129echo "$0: AAF_COMPONENTS=$AAF_COMPONENTS"
Sai Gandham66118342018-04-04 15:33:05 -0500130
Instrumental12414fe2019-01-22 10:27:32 -0600131cp ../sample/bin/pod_wait.sh ../aaf_${VERSION}/bin
Sai Gandham66118342018-04-04 15:33:05 -0500132for AAF_COMPONENT in ${AAF_COMPONENTS}; do
Instrumental4ad47632018-07-13 15:49:26 -0500133 echo Building aaf_$AAF_COMPONENT...
Instrumental12414fe2019-01-22 10:27:32 -0600134 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
135 -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
136 -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
Instrumental628b7102019-02-15 19:40:04 -0600137 -e 's/${DUSER}/'${DUSER}'/g' \
Instrumental12414fe2019-01-22 10:27:32 -0600138 Dockerfile.ms >../aaf_${VERSION}/Dockerfile
Instrumental4ad47632018-07-13 15:49:26 -0500139 cd ..
Instrumental94053612018-10-08 11:27:18 -0500140 $DOCKER build -t ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} aaf_${VERSION}
141 $DOCKER tag ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION}
142 $DOCKER tag ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:latest
Instrumental4ad47632018-07-13 15:49:26 -0500143 rm aaf_${VERSION}/Dockerfile
144 cd -
Instrumental93871ff2018-10-15 07:37:28 -0500145
Sai Gandham66118342018-04-04 15:33:05 -0500146done
Instrumental12414fe2019-01-22 10:27:32 -0600147rm ../aaf_${VERSION}/bin/pod_wait.sh