Public and Private Locate entries
[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 # AAF Base version - set the core image, etc
40 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
41     Dockerfile.base > Dockerfile
42 $DOCKER build -t ${ORG}/${PROJECT}/aaf_base:${VERSION} .
43 $DOCKER tag ${ORG}/${PROJECT}/aaf_base:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_base:${VERSION}
44 $DOCKER tag ${ORG}/${PROJECT}/aaf_base:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_base:latest
45 rm Dockerfile
46
47 # Create the AAF Config (Security) Images
48 cd ..
49 cp auth-cmd/target/aaf-auth-cmd-$VERSION-full.jar sample/bin
50 cp -Rf ../conf/CA sample
51
52
53 # AAF Config image (for AAF itself)
54 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
55     -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
56     -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
57     docker/Dockerfile.config > sample/Dockerfile
58 $DOCKER build -t ${ORG}/${PROJECT}/aaf_config:${VERSION} sample
59 $DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_config:${VERSION}
60 $DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/latest
61
62 cp ../cadi/servlet-sample/target/aaf-cadi-servlet-sample-${VERSION}-sample.jar sample/bin
63 # AAF Agent Image (for Clients)
64 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
65     -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
66     -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
67     docker/Dockerfile.client > sample/Dockerfile
68 $DOCKER build -t ${ORG}/${PROJECT}/aaf_agent:${VERSION} sample
69 $DOCKER tag ${ORG}/${PROJECT}/aaf_agent:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_agent:${VERSION}
70 $DOCKER tag ${ORG}/${PROJECT}/aaf_agent:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_agent:latest
71
72 # Clean up 
73 rm sample/Dockerfile sample/bin/aaf-auth-cmd-${VERSION}-full.jar sample/bin/aaf-cadi-servlet-sample-${VERSION}-sample.jar 
74 rm -Rf sample/CA
75 cd -
76
77 ########
78 # Second, build a core Docker Image
79 echo Building aaf_$AAF_COMPONENT...
80 # Apply currrent Properties to Docker file, and put in place.
81 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
82     -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
83     -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
84     Dockerfile.core >../aaf_${VERSION}/Dockerfile
85 cd ..
86 $DOCKER build -t ${ORG}/${PROJECT}/aaf_core:${VERSION} aaf_${VERSION}
87 $DOCKER tag ${ORG}/${PROJECT}/aaf_core:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_core:${VERSION}
88 $DOCKER tag ${ORG}/${PROJECT}/aaf_core:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_core:latest
89 rm aaf_${VERSION}/Dockerfile
90 cd -
91
92 #######
93 # Do all the Containers related to AAF Services
94 #######
95 if ["$1" == ""]; then
96     AAF_COMPONENTS=$(ls ../aaf_${VERSION}/bin | grep -v '\.')
97 else
98     AAF_COMPONENTS=$1
99 fi
100
101 cp ../sample/bin/pod_wait.sh  ../aaf_${VERSION}/bin
102 for AAF_COMPONENT in ${AAF_COMPONENTS}; do
103     echo Building aaf_$AAF_COMPONENT...
104     sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
105         -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
106         -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
107         Dockerfile.ms >../aaf_${VERSION}/Dockerfile
108     cd ..
109     $DOCKER build -t ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} aaf_${VERSION}
110     $DOCKER tag ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION}
111     $DOCKER tag ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:latest
112     rm aaf_${VERSION}/Dockerfile
113     cd -
114
115 done
116 rm ../aaf_${VERSION}/bin/pod_wait.sh