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