blob: a2a17e639553d45e7ee1599ea5dfce4b802deefe [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
Instrumentalaae5c072019-03-29 15:42:37 -050024# Pull in Variables from d.props
25if [ ! -e ./d.props ]; then
26 cp d.props.init d.props
27fi
28
29. ./d.props
30
sandovalfrd6bda192019-03-21 14:21:09 -060031# process input. originally, an optional positional parameter is used to designate a component.
32# A flagged parameter has been added to optionally indicate docker pull registry. Ideally, options
33# would be flagged but we're avoiding ripple effect of changing original usage
34if [ $# -gt 0 ]; then
35 if [ "$1" == "-r" ]; then
36 DOCKER_PULL_REGISTRY=$2
37 else
38 AAF_COMPONENTS=$1
39 if [[ $# -gt 1 && $2 == "-r" ]]; then
40 # If docker.io is indicated, registry var is void as that is docker default
41 if [ $3 == "docker.io" ]; then
42 DOCKER_PULL_REGISTRY=''
43 else
44 DOCKER_PULL_REGISTRY=$3
45 fi
46 fi
47 fi
48fi
49
Instrumentale9ae0482019-08-02 14:46:27 -050050grep -v '#' d.props | grep '=' | grep -v -e "=$"
sandovalfrd6bda192019-03-21 14:21:09 -060051
Instrumental94053612018-10-08 11:27:18 -050052DOCKER=${DOCKER:=docker}
53
Instrumentalbc299c02018-09-25 06:42:31 -050054echo "Building Containers for aaf components, version $VERSION"
Instrumental3019a282018-09-25 16:05:20 -050055# AAF_cass now needs a version...
Instrumental3505a522019-01-31 14:49:24 -060056cd ../auth-cass/docker
Instrumentale9ae0482019-08-02 14:46:27 -050057pwd
sandovalfrd6bda192019-03-21 14:21:09 -060058bash ./dbuild.sh $DOCKER_PULL_REGISTRY
Instrumental3505a522019-01-31 14:49:24 -060059cd -
Instrumental12414fe2019-01-22 10:27:32 -060060
Instrumental0e302ed2019-07-16 04:02:30 -050061########
62# First, build a AAF Base version - set the core image, etc
Instrumental12414fe2019-01-22 10:27:32 -060063sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
Instrumental628b7102019-02-15 19:40:04 -060064 -e 's/${DUSER}/'${DUSER}'/g' \
sandovalfrd6bda192019-03-21 14:21:09 -060065 -e 's/${REGISTRY}/'${DOCKER_PULL_REGISTRY}'/g' \
Instrumental12414fe2019-01-22 10:27:32 -060066 Dockerfile.base > Dockerfile
67$DOCKER build -t ${ORG}/${PROJECT}/aaf_base:${VERSION} .
68$DOCKER tag ${ORG}/${PROJECT}/aaf_base:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_base:${VERSION}
69$DOCKER tag ${ORG}/${PROJECT}/aaf_base:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_base:latest
70rm Dockerfile
Instrumental3019a282018-09-25 16:05:20 -050071
Instrumental85b4e412019-08-05 19:33:17 -050072# Tack the "SNAPSHOT" out of name
73function SCP() {
74 SANS=${1/-SNAPSHOT/}
75 if [ -e $SANS ]; then
76 cp $SANS $2
77 else
78 ln $1 $SANS
79 cp $SANS $2
80 rm $SANS
81 fi
82}
83
Instrumental0e302ed2019-07-16 04:02:30 -050084########
85# Second, Create the AAF Config (Security) Images
Instrumental9ec28952018-07-12 11:14:10 -050086cd ..
Instrumentalb3a68142019-07-24 14:42:22 -050087# Note: only 2 jars each in Agent/Config
Instrumental85b4e412019-08-05 19:33:17 -050088SCP auth-cmd/target/aaf-auth-cmd-$VERSION-full.jar sample/bin
89SCP auth-batch/target/aaf-auth-batch-$VERSION-full.jar sample/bin
90SCP ../cadi/aaf/target/aaf-cadi-aaf-${VERSION}-full.jar sample/bin
91SCP ../cadi/servlet-sample/target/aaf-cadi-servlet-sample-${VERSION}-sample.jar sample/bin
Instrumentalbc299c02018-09-25 06:42:31 -050092cp -Rf ../conf/CA sample
Instrumental32cdd552018-07-19 13:29:32 -050093
94# AAF Config image (for AAF itself)
Instrumental12414fe2019-01-22 10:27:32 -060095sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
96 -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
97 -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
Instrumental628b7102019-02-15 19:40:04 -060098 -e 's/${DUSER}/'${DUSER}'/g' \
Instrumental12414fe2019-01-22 10:27:32 -060099 docker/Dockerfile.config > sample/Dockerfile
Instrumental94053612018-10-08 11:27:18 -0500100$DOCKER build -t ${ORG}/${PROJECT}/aaf_config:${VERSION} sample
101$DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_config:${VERSION}
Instrumental3505a522019-01-31 14:49:24 -0600102$DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_config:latest
Instrumental32cdd552018-07-19 13:29:32 -0500103
Instrumentalb3a68142019-07-24 14:42:22 -0500104
Instrumental32cdd552018-07-19 13:29:32 -0500105# AAF Agent Image (for Clients)
Instrumental12414fe2019-01-22 10:27:32 -0600106sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
107 -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
108 -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
Instrumental628b7102019-02-15 19:40:04 -0600109 -e 's/${DUSER}/'${DUSER}'/g' \
Instrumentalbd7def72019-04-03 08:25:28 -0500110 docker/Dockerfile.agent > sample/Dockerfile
Instrumental94053612018-10-08 11:27:18 -0500111$DOCKER build -t ${ORG}/${PROJECT}/aaf_agent:${VERSION} sample
112$DOCKER tag ${ORG}/${PROJECT}/aaf_agent:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_agent:${VERSION}
113$DOCKER tag ${ORG}/${PROJECT}/aaf_agent:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_agent:latest
Instrumental32cdd552018-07-19 13:29:32 -0500114
115# Clean up
Instrumental85b4e412019-08-05 19:33:17 -0500116rm sample/Dockerfile sample/bin/aaf-*-*.jar
Instrumentalbc299c02018-09-25 06:42:31 -0500117rm -Rf sample/CA
Instrumental9ec28952018-07-12 11:14:10 -0500118cd -
Instrumental365638c2018-10-01 15:26:03 -0500119
Instrumental32cdd552018-07-19 13:29:32 -0500120########
Instrumental0e302ed2019-07-16 04:02:30 -0500121# Third, build a core Docker Image to be used for all AAF Components
Instrumental9ec28952018-07-12 11:14:10 -0500122echo Building aaf_$AAF_COMPONENT...
Instrumental0e302ed2019-07-16 04:02:30 -0500123cp ../sample/bin/pod_wait.sh ../aaf_${VERSION}/bin
Instrumental9ec28952018-07-12 11:14:10 -0500124# Apply currrent Properties to Docker file, and put in place.
Instrumental12414fe2019-01-22 10:27:32 -0600125sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
126 -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
127 -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
Instrumental628b7102019-02-15 19:40:04 -0600128 -e 's/${DUSER}/'${DUSER}'/g' \
Instrumental12414fe2019-01-22 10:27:32 -0600129 Dockerfile.core >../aaf_${VERSION}/Dockerfile
Instrumental9ec28952018-07-12 11:14:10 -0500130cd ..
Instrumentalbd7def72019-04-03 08:25:28 -0500131echo "#######"
132pwd
133echo "#######"
Instrumental94053612018-10-08 11:27:18 -0500134$DOCKER build -t ${ORG}/${PROJECT}/aaf_core:${VERSION} aaf_${VERSION}
135$DOCKER tag ${ORG}/${PROJECT}/aaf_core:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_core:${VERSION}
136$DOCKER tag ${ORG}/${PROJECT}/aaf_core:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_core:latest
Instrumental9ec28952018-07-12 11:14:10 -0500137rm aaf_${VERSION}/Dockerfile
Sai Gandham66118342018-04-04 15:33:05 -0500138
Instrumental5b77b642019-07-17 11:50:16 -0500139########
140# Fourth, do Hello
141# Apply currrent Properties to Docker file, and put in place.
142cd -
143sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
144 -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
145 -e 's/${DUSER}/'${DUSER}'/g' \
146 Dockerfile.hello >../aaf_${VERSION}/Dockerfile
147cd ..
148echo "#######"
149pwd
150echo "#######"
151cp -Rf sample/etc aaf_${VERSION}
Instrumentalb3a68142019-07-24 14:42:22 -0500152cp -Rf sample/logs aaf_${VERSION}
Instrumental5b77b642019-07-17 11:50:16 -0500153$DOCKER build -t ${ORG}/${PROJECT}/aaf_hello:${VERSION} aaf_${VERSION}
154$DOCKER tag ${ORG}/${PROJECT}/aaf_hello:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_hello:${VERSION}
155$DOCKER tag ${ORG}/${PROJECT}/aaf_hello:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_hello:latest
156rm -Rf aaf_${VERSION}/Dockerfile aaf_${VERSION}/etc
Instrumentalbd7def72019-04-03 08:25:28 -0500157
158# Final cleanup
Instrumental0e302ed2019-07-16 04:02:30 -0500159rm aaf_${VERSION}/bin/pod_wait.sh
160
161cd -