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
62 # First, build a AAF Base version - set the core image, etc
63 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
64 -e 's/${DUSER}/'${DUSER}'/g' \
65 -e 's/${REGISTRY}/'${DOCKER_PULL_REGISTRY}'/g' \
66 Dockerfile.base > Dockerfile
67 $DOCKER build -t ${ORG}/${PROJECT}/aaf_base:${VERSION} .
68 $DOCKER tag ${ORG}/${PROJECT}/aaf_base:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_base:${VERSION}
69 $DOCKER tag ${ORG}/${PROJECT}/aaf_base:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_base:latest
73 # Second, Create the AAF Config (Security) Images
75 # Note: only 2 jars each in Agent/Config
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 ../cadi/aaf/target/aaf-cadi-aaf-${VERSION}-full.jar sample/bin
79 cp ../cadi/servlet-sample/target/aaf-cadi-servlet-sample-${VERSION}-sample.jar sample/bin
80 cp -Rf ../conf/CA sample
82 # AAF Config image (for AAF itself)
83 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
84 -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
85 -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
86 -e 's/${DUSER}/'${DUSER}'/g' \
87 docker/Dockerfile.config > sample/Dockerfile
88 $DOCKER build -t ${ORG}/${PROJECT}/aaf_config:${VERSION} sample
89 $DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_config:${VERSION}
90 $DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_config:latest
93 # AAF Agent Image (for Clients)
94 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
95 -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
96 -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
97 -e 's/${DUSER}/'${DUSER}'/g' \
98 docker/Dockerfile.agent > sample/Dockerfile
99 $DOCKER build -t ${ORG}/${PROJECT}/aaf_agent:${VERSION} sample
100 $DOCKER tag ${ORG}/${PROJECT}/aaf_agent:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_agent:${VERSION}
101 $DOCKER tag ${ORG}/${PROJECT}/aaf_agent:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_agent:latest
104 rm sample/Dockerfile sample/bin/aaf-*-${VERSION}*.jar
109 # Third, build a core Docker Image to be used for all AAF Components
110 echo Building aaf_$AAF_COMPONENT...
111 cp ../sample/bin/pod_wait.sh ../aaf_${VERSION}/bin
112 # Apply currrent Properties to Docker file, and put in place.
113 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
114 -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
115 -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
116 -e 's/${DUSER}/'${DUSER}'/g' \
117 Dockerfile.core >../aaf_${VERSION}/Dockerfile
122 $DOCKER build -t ${ORG}/${PROJECT}/aaf_core:${VERSION} aaf_${VERSION}
123 $DOCKER tag ${ORG}/${PROJECT}/aaf_core:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_core:${VERSION}
124 $DOCKER tag ${ORG}/${PROJECT}/aaf_core:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_core:latest
125 rm aaf_${VERSION}/Dockerfile
129 # Apply currrent Properties to Docker file, and put in place.
131 sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
132 -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
133 -e 's/${DUSER}/'${DUSER}'/g' \
134 Dockerfile.hello >../aaf_${VERSION}/Dockerfile
139 cp -Rf sample/etc aaf_${VERSION}
140 cp -Rf sample/logs aaf_${VERSION}
141 $DOCKER build -t ${ORG}/${PROJECT}/aaf_hello:${VERSION} aaf_${VERSION}
142 $DOCKER tag ${ORG}/${PROJECT}/aaf_hello:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_hello:${VERSION}
143 $DOCKER tag ${ORG}/${PROJECT}/aaf_hello:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_hello:latest
144 rm -Rf aaf_${VERSION}/Dockerfile aaf_${VERSION}/etc
147 rm aaf_${VERSION}/bin/pod_wait.sh