Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 1 | |
Instrumental | 7a1817b | 2018-11-05 11:11:15 -0600 | [diff] [blame] | 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==================================================== |
Sai Gandham | 6611834 | 2018-04-04 15:33:05 -0500 | [diff] [blame] | 20 | # |
| 21 | # Docker Building Script. Reads all the components generated by install, on per-version basis |
| 22 | # |
sandovalfr | d6bda19 | 2019-03-21 14:21:09 -0600 | [diff] [blame] | 23 | |
Instrumental | aae5c07 | 2019-03-29 15:42:37 -0500 | [diff] [blame] | 24 | # Pull in Variables from d.props |
| 25 | if [ ! -e ./d.props ]; then |
| 26 | cp d.props.init d.props |
| 27 | fi |
| 28 | |
| 29 | . ./d.props |
| 30 | |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 31 | # Remove "SNAPSHOT" from AAF Jars in Containers |
| 32 | JAR_VERSION=${VERSION/-SNAPSHOT/} |
| 33 | |
sandovalfr | d6bda19 | 2019-03-21 14:21:09 -0600 | [diff] [blame] | 34 | # process input. originally, an optional positional parameter is used to designate a component. |
| 35 | # A flagged parameter has been added to optionally indicate docker pull registry. Ideally, options |
| 36 | # would be flagged but we're avoiding ripple effect of changing original usage |
| 37 | if [ $# -gt 0 ]; then |
| 38 | if [ "$1" == "-r" ]; then |
| 39 | DOCKER_PULL_REGISTRY=$2 |
| 40 | else |
| 41 | AAF_COMPONENTS=$1 |
| 42 | if [[ $# -gt 1 && $2 == "-r" ]]; then |
| 43 | # If docker.io is indicated, registry var is void as that is docker default |
| 44 | if [ $3 == "docker.io" ]; then |
| 45 | DOCKER_PULL_REGISTRY='' |
| 46 | else |
| 47 | DOCKER_PULL_REGISTRY=$3 |
| 48 | fi |
| 49 | fi |
| 50 | fi |
| 51 | fi |
| 52 | |
Instrumental | e9ae048 | 2019-08-02 14:46:27 -0500 | [diff] [blame] | 53 | grep -v '#' d.props | grep '=' | grep -v -e "=$" |
sandovalfr | d6bda19 | 2019-03-21 14:21:09 -0600 | [diff] [blame] | 54 | |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 55 | DOCKER=${DOCKER:=docker} |
| 56 | |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 57 | echo "Building Containers for aaf components, version $VERSION" |
Instrumental | 3019a28 | 2018-09-25 16:05:20 -0500 | [diff] [blame] | 58 | # AAF_cass now needs a version... |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 59 | echo "### Build Cass" |
Instrumental | 3505a52 | 2019-01-31 14:49:24 -0600 | [diff] [blame] | 60 | cd ../auth-cass/docker |
Instrumental | e9ae048 | 2019-08-02 14:46:27 -0500 | [diff] [blame] | 61 | pwd |
sandovalfr | d6bda19 | 2019-03-21 14:21:09 -0600 | [diff] [blame] | 62 | bash ./dbuild.sh $DOCKER_PULL_REGISTRY |
Instrumental | 3505a52 | 2019-01-31 14:49:24 -0600 | [diff] [blame] | 63 | cd - |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 64 | |
Instrumental | 0e302ed | 2019-07-16 04:02:30 -0500 | [diff] [blame] | 65 | ######## |
| 66 | # First, build a AAF Base version - set the core image, etc |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 67 | echo "### Build Base" |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 68 | sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \ |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 69 | -e 's/${JAR_VERSION}/'${JAR_VERSION}'/g' \ |
Instrumental | 628b710 | 2019-02-15 19:40:04 -0600 | [diff] [blame] | 70 | -e 's/${DUSER}/'${DUSER}'/g' \ |
sandovalfr | d6bda19 | 2019-03-21 14:21:09 -0600 | [diff] [blame] | 71 | -e 's/${REGISTRY}/'${DOCKER_PULL_REGISTRY}'/g' \ |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 72 | Dockerfile.base > Dockerfile |
| 73 | $DOCKER build -t ${ORG}/${PROJECT}/aaf_base:${VERSION} . |
| 74 | $DOCKER tag ${ORG}/${PROJECT}/aaf_base:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_base:${VERSION} |
| 75 | $DOCKER tag ${ORG}/${PROJECT}/aaf_base:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_base:latest |
| 76 | rm Dockerfile |
Instrumental | 3019a28 | 2018-09-25 16:05:20 -0500 | [diff] [blame] | 77 | |
Instrumental | 85b4e41 | 2019-08-05 19:33:17 -0500 | [diff] [blame] | 78 | function SCP() { |
| 79 | SANS=${1/-SNAPSHOT/} |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 80 | echo $1 = $SANS |
Instrumental | 85b4e41 | 2019-08-05 19:33:17 -0500 | [diff] [blame] | 81 | if [ -e $SANS ]; then |
| 82 | cp $SANS $2 |
| 83 | else |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 84 | |
Instrumental | 85b4e41 | 2019-08-05 19:33:17 -0500 | [diff] [blame] | 85 | ln $1 $SANS |
| 86 | cp $SANS $2 |
| 87 | rm $SANS |
| 88 | fi |
| 89 | } |
| 90 | |
Instrumental | 0e302ed | 2019-07-16 04:02:30 -0500 | [diff] [blame] | 91 | ######## |
| 92 | # Second, Create the AAF Config (Security) Images |
Instrumental | 9ec2895 | 2018-07-12 11:14:10 -0500 | [diff] [blame] | 93 | cd .. |
Instrumental | b3a6814 | 2019-07-24 14:42:22 -0500 | [diff] [blame] | 94 | # Note: only 2 jars each in Agent/Config |
Instrumental | 85b4e41 | 2019-08-05 19:33:17 -0500 | [diff] [blame] | 95 | SCP auth-cmd/target/aaf-auth-cmd-$VERSION-full.jar sample/bin |
| 96 | SCP auth-batch/target/aaf-auth-batch-$VERSION-full.jar sample/bin |
| 97 | SCP ../cadi/aaf/target/aaf-cadi-aaf-${VERSION}-full.jar sample/bin |
| 98 | SCP ../cadi/servlet-sample/target/aaf-cadi-servlet-sample-${VERSION}-sample.jar sample/bin |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 99 | cp -Rf ../conf/CA sample |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 100 | |
| 101 | # AAF Config image (for AAF itself) |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 102 | echo "### Build Config" |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 103 | sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \ |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 104 | -e 's/${JAR_VERSION}/'${JAR_VERSION}'/g' \ |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 105 | -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \ |
| 106 | -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \ |
Instrumental | 628b710 | 2019-02-15 19:40:04 -0600 | [diff] [blame] | 107 | -e 's/${DUSER}/'${DUSER}'/g' \ |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 108 | docker/Dockerfile.config > sample/Dockerfile |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 109 | $DOCKER build -t ${ORG}/${PROJECT}/aaf_config:${VERSION} sample |
| 110 | $DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_config:${VERSION} |
Instrumental | 3505a52 | 2019-01-31 14:49:24 -0600 | [diff] [blame] | 111 | $DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_config:latest |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 112 | |
Instrumental | b3a6814 | 2019-07-24 14:42:22 -0500 | [diff] [blame] | 113 | |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 114 | # AAF Agent Image (for Clients) |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 115 | echo "### Build Agent" |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 116 | sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \ |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 117 | -e 's/${JAR_VERSION}/'${JAR_VERSION}'/g' \ |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 118 | -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \ |
| 119 | -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \ |
Instrumental | 628b710 | 2019-02-15 19:40:04 -0600 | [diff] [blame] | 120 | -e 's/${DUSER}/'${DUSER}'/g' \ |
Instrumental | bd7def7 | 2019-04-03 08:25:28 -0500 | [diff] [blame] | 121 | docker/Dockerfile.agent > sample/Dockerfile |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 122 | $DOCKER build -t ${ORG}/${PROJECT}/aaf_agent:${VERSION} sample |
| 123 | $DOCKER tag ${ORG}/${PROJECT}/aaf_agent:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_agent:${VERSION} |
| 124 | $DOCKER tag ${ORG}/${PROJECT}/aaf_agent:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_agent:latest |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 125 | |
| 126 | # Clean up |
Instrumental | 85b4e41 | 2019-08-05 19:33:17 -0500 | [diff] [blame] | 127 | rm sample/Dockerfile sample/bin/aaf-*-*.jar |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 128 | rm -Rf sample/CA |
Instrumental | 9ec2895 | 2018-07-12 11:14:10 -0500 | [diff] [blame] | 129 | cd - |
Instrumental | 365638c | 2018-10-01 15:26:03 -0500 | [diff] [blame] | 130 | |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 131 | |
| 132 | ######## |
| 133 | # Third Copy AAF Executables to a BUILD Directory, for easy Cleanup |
| 134 | echo "### Copy to aaf_DBUILD" |
| 135 | if [ -e "../aaf_$VERSION" ]; then |
| 136 | cp -Rf ../aaf_$VERSION ../aaf_DBUILD |
| 137 | elif [ -e "../aaf_$JAR_VERSION" ]; then |
| 138 | cp -Rf ../aaf_$JAR_VERSION ../aaf_DBUILD |
| 139 | else |
| 140 | echo "ERROR: No AAF Built. use Maven" |
| 141 | exit |
| 142 | fi |
| 143 | if [ ! "$VERSION" = "$JAR_VERSION" ]; then |
| 144 | START_DIR=$(pwd) |
| 145 | # Convert SNAPSHOT issues |
| 146 | cp -Rf ../aaf_$VERSION ../aaf_DBUILD |
| 147 | cd ../aaf_DBUILD/lib |
| 148 | # If Built Jars are "SNAPSHOT", convert to NON SNAPSHOT |
| 149 | for J in $(ls *-SNAPSHOT*); do mv $J ${J/-SNAPSHOT/}; done |
| 150 | cd ../bin |
| 151 | rm *.bat |
| 152 | for S in $(ls); do |
| 153 | sed -e "/$VERSION/s/$VERSION/$JAR_VERSION/g" $S > tmp |
| 154 | mv tmp $S |
| 155 | done |
| 156 | cd ${START_DIR} |
| 157 | fi |
| 158 | |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 159 | ######## |
Instrumental | 0e302ed | 2019-07-16 04:02:30 -0500 | [diff] [blame] | 160 | # Third, build a core Docker Image to be used for all AAF Components |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 161 | cp ../sample/bin/pod_wait.sh ../aaf_DBUILD/bin |
Instrumental | 9ec2895 | 2018-07-12 11:14:10 -0500 | [diff] [blame] | 162 | # Apply currrent Properties to Docker file, and put in place. |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 163 | sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \ |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 164 | -e 's/${JAR_VERSION}/'${JAR_VERSION}'/g' \ |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 165 | -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \ |
| 166 | -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \ |
Instrumental | 628b710 | 2019-02-15 19:40:04 -0600 | [diff] [blame] | 167 | -e 's/${DUSER}/'${DUSER}'/g' \ |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 168 | Dockerfile.core >../aaf_DBUILD/Dockerfile |
Instrumental | 9ec2895 | 2018-07-12 11:14:10 -0500 | [diff] [blame] | 169 | cd .. |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 170 | |
| 171 | echo "### Building Core" |
| 172 | # Don't need "Hello" App in core |
| 173 | mv aaf_DBUILD/lib/aaf-auth-hello-${JAR_VERSION}* /tmp |
| 174 | |
| 175 | $DOCKER build -t ${ORG}/${PROJECT}/aaf_core:${VERSION} aaf_DBUILD |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 176 | $DOCKER tag ${ORG}/${PROJECT}/aaf_core:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_core:${VERSION} |
| 177 | $DOCKER tag ${ORG}/${PROJECT}/aaf_core:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_core:latest |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 178 | rm aaf_DBUILD/Dockerfile |
| 179 | mv /tmp/aaf-auth-hello-${JAR_VERSION}* aaf_DBUILD/lib |
Sai Gandham | 6611834 | 2018-04-04 15:33:05 -0500 | [diff] [blame] | 180 | |
Instrumental | 5b77b64 | 2019-07-17 11:50:16 -0500 | [diff] [blame] | 181 | ######## |
| 182 | # Fourth, do Hello |
| 183 | # Apply currrent Properties to Docker file, and put in place. |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 184 | echo "### Building Hello" |
Instrumental | 5b77b64 | 2019-07-17 11:50:16 -0500 | [diff] [blame] | 185 | cd - |
| 186 | sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \ |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 187 | -e 's/${JAR_VERSION}/'${JAR_VERSION}'/g' \ |
Instrumental | 5b77b64 | 2019-07-17 11:50:16 -0500 | [diff] [blame] | 188 | -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \ |
| 189 | -e 's/${DUSER}/'${DUSER}'/g' \ |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 190 | Dockerfile.hello >../aaf_DBUILD/Dockerfile |
Instrumental | 5b77b64 | 2019-07-17 11:50:16 -0500 | [diff] [blame] | 191 | cd .. |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 192 | |
| 193 | cp -Rf sample/etc aaf_DBUILD |
| 194 | cp -Rf sample/logs aaf_DBUILD |
| 195 | |
| 196 | for C in cass certman cmd deforg fs gui locate oauth service; do |
| 197 | rm aaf_DBUILD/lib/aaf-auth-$C-* |
| 198 | done |
| 199 | |
| 200 | $DOCKER build -t ${ORG}/${PROJECT}/aaf_hello:${VERSION} aaf_DBUILD |
Instrumental | 5b77b64 | 2019-07-17 11:50:16 -0500 | [diff] [blame] | 201 | $DOCKER tag ${ORG}/${PROJECT}/aaf_hello:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_hello:${VERSION} |
| 202 | $DOCKER tag ${ORG}/${PROJECT}/aaf_hello:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_hello:latest |
Instrumental | bd7def7 | 2019-04-03 08:25:28 -0500 | [diff] [blame] | 203 | |
| 204 | # Final cleanup |
Instrumental | e37619c | 2019-08-06 07:54:50 -0500 | [diff] [blame] | 205 | rm -Rf aaf_DBUILD |
Instrumental | 0e302ed | 2019-07-16 04:02:30 -0500 | [diff] [blame] | 206 | |
| 207 | cd - |