Missing Licenses
[aaf/authz.git] / auth / docker / dbuild.sh
1 #!/bin/bash
2 #########
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====================================================
20 #
21 # Docker Building Script.  Reads all the components generated by install, on per-version basis
22 #
23 # Pull in Variables from d.props
24 if [ ! -e ./d.props ]; then
25     cp d.props.init d.props
26 fi
27
28 . ./d.props
29
30 DOCKER=${DOCKER:=docker}
31
32 echo "Building Containers for aaf components, version $VERSION"
33
34 # AAF_cass now needs a version...
35 cd ../auth-cass/docker
36 bash ./dbuild.sh
37 cd -
38
39 # Create the AAF Config (Security) Images
40 cd ..
41 cp auth-cmd/target/aaf-auth-cmd-$VERSION-full.jar sample/bin
42 cp -Rf ../conf/CA sample
43
44 # AAF Config image (for AAF itself)
45 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' docker/Dockerfile.config > sample/Dockerfile
46 $DOCKER build -t ${ORG}/${PROJECT}/aaf_config:${VERSION} sample
47 $DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_config:${VERSION}
48 $DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/latest
49
50 cp ../cadi/servlet-sample/target/aaf-cadi-servlet-sample-${VERSION}-sample.jar sample/bin
51 # AAF Agent Image (for Clients)
52 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' docker/Dockerfile.client > sample/Dockerfile
53 $DOCKER build -t ${ORG}/${PROJECT}/aaf_agent:${VERSION} sample
54 $DOCKER tag ${ORG}/${PROJECT}/aaf_agent:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_agent:${VERSION}
55 $DOCKER tag ${ORG}/${PROJECT}/aaf_agent:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_agent:latest
56
57 # Clean up 
58 rm sample/Dockerfile sample/bin/aaf-auth-cmd-${VERSION}-full.jar sample/bin/aaf-cadi-servlet-sample-${VERSION}-sample.jar 
59 rm -Rf sample/CA
60 cd -
61
62 ########
63 # Second, build a core Docker Image
64 echo Building aaf_$AAF_COMPONENT...
65 # Apply currrent Properties to Docker file, and put in place.
66 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' Dockerfile.core >../aaf_${VERSION}/Dockerfile
67 cd ..
68 $DOCKER build -t ${ORG}/${PROJECT}/aaf_core:${VERSION} aaf_${VERSION}
69 $DOCKER tag ${ORG}/${PROJECT}/aaf_core:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_core:${VERSION}
70 $DOCKER tag ${ORG}/${PROJECT}/aaf_core:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_core:latest
71 rm aaf_${VERSION}/Dockerfile
72 cd -
73
74 #######
75 # Do all the Containers related to AAF Services
76 #######
77 if ["$1" == ""]; then
78     AAF_COMPONENTS=$(ls ../aaf_${VERSION}/bin | grep -v '\.')
79 else
80     AAF_COMPONENTS=$1
81 fi
82
83 mkdir -p ../aaf_${VERSION}/pod
84 cp ../sample/bin/pod_wait.sh  ../aaf_${VERSION}/pod
85 for AAF_COMPONENT in ${AAF_COMPONENTS}; do
86     echo Building aaf_$AAF_COMPONENT...
87     sed -e 's/${AAF_VERSION}/'${VERSION}'/g' -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' Dockerfile.ms >../aaf_${VERSION}/Dockerfile
88     cd ..
89     $DOCKER build -t ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} aaf_${VERSION}
90     $DOCKER tag ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION}
91     $DOCKER tag ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:latest
92     rm aaf_${VERSION}/Dockerfile
93     cd -
94
95 done
96 rm ../aaf_${VERSION}/pod/*
97 rmdir ../aaf_${VERSION}/pod