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 # Pull in Variables from d.props
25 if [ ! -e ./d.props ]; then
26 cp d.props.init d.props
31 # 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
35 if [ "$1" == "-r" ]; then
36 DOCKER_PULL_REGISTRY=$2
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=''
44 DOCKER_PULL_REGISTRY=$3
50 echo "$0: AAF_COMPONENTS=$AAF_COMPONENTS DOCKER_PULL_REGISTRY=$DOCKER_PULL_REGISTRY"
52 DOCKER=${DOCKER:=docker}
54 echo "Building Containers for aaf components, version $VERSION"
56 # AAF_cass now needs a version...
57 cd ../auth-cass/docker
58 bash ./dbuild.sh $DOCKER_PULL_REGISTRY
61 # AAF Base version - set the core image, etc
62 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
63 -e 's/${DUSER}/'${DUSER}'/g' \
64 -e 's/${REGISTRY}/'${DOCKER_PULL_REGISTRY}'/g' \
65 Dockerfile.base > Dockerfile
66 $DOCKER build -t ${ORG}/${PROJECT}/aaf_base:${VERSION} .
67 $DOCKER tag ${ORG}/${PROJECT}/aaf_base:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_base:${VERSION}
68 $DOCKER tag ${ORG}/${PROJECT}/aaf_base:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_base:latest
71 # Create the AAF Config (Security) Images
73 cp auth-cmd/target/aaf-auth-cmd-$VERSION-full.jar sample/bin
74 cp auth-batch/target/aaf-auth-batch-$VERSION-full.jar sample/bin
75 cp -Rf ../conf/CA sample
77 # AAF Config image (for AAF itself)
78 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
79 -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
80 -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
81 -e 's/${DUSER}/'${DUSER}'/g' \
82 docker/Dockerfile.config > sample/Dockerfile
83 $DOCKER build -t ${ORG}/${PROJECT}/aaf_config:${VERSION} sample
84 $DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_config:${VERSION}
85 $DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_config:latest
87 cp ../cadi/servlet-sample/target/aaf-cadi-servlet-sample-${VERSION}-sample.jar sample/bin
88 # AAF Agent Image (for Clients)
89 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
90 -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
91 -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
92 -e 's/${DUSER}/'${DUSER}'/g' \
93 docker/Dockerfile.agent > sample/Dockerfile
94 $DOCKER build -t ${ORG}/${PROJECT}/aaf_agent:${VERSION} sample
95 $DOCKER tag ${ORG}/${PROJECT}/aaf_agent:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_agent:${VERSION}
96 $DOCKER tag ${ORG}/${PROJECT}/aaf_agent:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_agent:latest
99 rm sample/Dockerfile sample/bin/aaf-*-${VERSION}-full.jar sample/bin/aaf-cadi-servlet-sample-${VERSION}-sample.jar
104 # Second, build a core Docker Image
105 echo Building aaf_$AAF_COMPONENT...
106 # Apply currrent Properties to Docker file, and put in place.
107 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
108 -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
109 -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
110 -e 's/${DUSER}/'${DUSER}'/g' \
111 Dockerfile.core >../aaf_${VERSION}/Dockerfile
116 $DOCKER build -t ${ORG}/${PROJECT}/aaf_core:${VERSION} aaf_${VERSION}
117 $DOCKER tag ${ORG}/${PROJECT}/aaf_core:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_core:${VERSION}
118 $DOCKER tag ${ORG}/${PROJECT}/aaf_core:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_core:latest
119 rm aaf_${VERSION}/Dockerfile
123 # Do all the Containers related to AAF Services
125 AAF_COMPONENTS=$(cat components)
127 cp ../sample/bin/pod_wait.sh ../aaf_${VERSION}/bin
128 for AAF_COMPONENT in ${AAF_COMPONENTS}; do
129 echo Building aaf_$AAF_COMPONENT...
130 if [ "hello" = "${AAF_COMPONENT}" ]; then
131 echo Building Hello separately
132 DF="Dockerfile.hello"
133 cp -Rf ../sample/etc ../aaf_${VERSION}/etc
137 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
138 -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
139 -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
140 -e 's/${DUSER}/'${DUSER}'/g' \
141 $DF >../aaf_${VERSION}/Dockerfile
143 $DOCKER build -t ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} aaf_${VERSION}
144 $DOCKER tag ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION}
145 $DOCKER tag ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:latest
146 rm aaf_${VERSION}/Dockerfile
147 if [ -e aaf_${VERSION}/etc ]; then
148 rm -Rf aaf_${VERSION}/etc
154 rm ../aaf_${VERSION}/bin/pod_wait.sh