3 # ============LICENSE_START====================================================
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
12 # http://www.apache.org/licenses/LICENSE-2.0
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====================================================
21 # Docker Building Script. Reads all the components generated by install, on per-version basis
24 DOCKER_PULL_REGISTRY='nexus3.onap.org:10001\/'
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
31 if [ "$1" == "-r" ]; then
32 DOCKER_PULL_REGISTRY=$2
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=''
40 DOCKER_PULL_REGISTRY=$3
46 echo "$0: AAF_COMPONENTS=$AAF_COMPONENTS DOCKER_PULL_REGISTRY=$DOCKER_PULL_REGISTRY"
48 # Pull in Variables from d.props
49 if [ ! -e ./d.props ]; then
50 cp d.props.init d.props
55 DOCKER=${DOCKER:=docker}
57 echo "Building Containers for aaf components, version $VERSION"
59 # AAF_cass now needs a version...
60 cd ../auth-cass/docker
61 bash ./dbuild.sh $DOCKER_PULL_REGISTRY
64 # AAF Base version - set the core image, etc
65 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
66 -e 's/${DUSER}/'${DUSER}'/g' \
67 -e 's/${REGISTRY}/'${DOCKER_PULL_REGISTRY}'/g' \
68 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
74 # Create the AAF Config (Security) Images
76 cp auth-cmd/target/aaf-auth-cmd-$VERSION-full.jar sample/bin
77 cp auth-batch/target/aaf-auth-batch-$VERSION-full.jar sample/bin
78 cp -Rf ../conf/CA sample
81 # AAF Config image (for AAF itself)
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 -e 's/${DUSER}/'${DUSER}'/g' \
86 docker/Dockerfile.config > sample/Dockerfile
87 $DOCKER build -t ${ORG}/${PROJECT}/aaf_config:${VERSION} sample
88 $DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_config:${VERSION}
89 $DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_config:latest
91 cp ../cadi/servlet-sample/target/aaf-cadi-servlet-sample-${VERSION}-sample.jar sample/bin
92 # AAF Agent Image (for Clients)
93 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
94 -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
95 -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
96 -e 's/${DUSER}/'${DUSER}'/g' \
97 docker/Dockerfile.client > sample/Dockerfile
98 $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
103 rm sample/Dockerfile sample/bin/aaf-*-${VERSION}-full.jar sample/bin/aaf-cadi-servlet-sample-${VERSION}-sample.jar
108 # Second, build a core Docker Image
109 echo Building aaf_$AAF_COMPONENT...
110 # Apply currrent Properties to Docker file, and put in place.
111 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
112 -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
113 -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
114 -e 's/${DUSER}/'${DUSER}'/g' \
115 Dockerfile.core >../aaf_${VERSION}/Dockerfile
117 $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
120 rm aaf_${VERSION}/Dockerfile
124 # Do all the Containers related to AAF Services
126 if [ $AAF_COMPONENTS == "ALL" ]; then
127 AAF_COMPONENTS=$(ls ../aaf_${VERSION}/bin | grep -v '\.')
129 echo "$0: AAF_COMPONENTS=$AAF_COMPONENTS"
131 cp ../sample/bin/pod_wait.sh ../aaf_${VERSION}/bin
132 for AAF_COMPONENT in ${AAF_COMPONENTS}; do
133 echo Building aaf_$AAF_COMPONENT...
134 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
135 -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
136 -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
137 -e 's/${DUSER}/'${DUSER}'/g' \
138 Dockerfile.ms >../aaf_${VERSION}/Dockerfile
140 $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
143 rm aaf_${VERSION}/Dockerfile
147 rm ../aaf_${VERSION}/bin/pod_wait.sh