Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 1 | #!/bin/bash |
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 | |
sandovalfr | d6bda19 | 2019-03-21 14:21:09 -0600 | [diff] [blame] | 31 | AAF_COMPONENTS=ALL |
| 32 | |
| 33 | # process input. originally, an optional positional parameter is used to designate a component. |
| 34 | # A flagged parameter has been added to optionally indicate docker pull registry. Ideally, options |
| 35 | # would be flagged but we're avoiding ripple effect of changing original usage |
| 36 | if [ $# -gt 0 ]; then |
| 37 | if [ "$1" == "-r" ]; then |
| 38 | DOCKER_PULL_REGISTRY=$2 |
| 39 | else |
| 40 | AAF_COMPONENTS=$1 |
| 41 | if [[ $# -gt 1 && $2 == "-r" ]]; then |
| 42 | # If docker.io is indicated, registry var is void as that is docker default |
| 43 | if [ $3 == "docker.io" ]; then |
| 44 | DOCKER_PULL_REGISTRY='' |
| 45 | else |
| 46 | DOCKER_PULL_REGISTRY=$3 |
| 47 | fi |
| 48 | fi |
| 49 | fi |
| 50 | fi |
| 51 | |
| 52 | echo "$0: AAF_COMPONENTS=$AAF_COMPONENTS DOCKER_PULL_REGISTRY=$DOCKER_PULL_REGISTRY" |
| 53 | |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 54 | DOCKER=${DOCKER:=docker} |
| 55 | |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 56 | echo "Building Containers for aaf components, version $VERSION" |
| 57 | |
Instrumental | 3019a28 | 2018-09-25 16:05:20 -0500 | [diff] [blame] | 58 | # AAF_cass now needs a version... |
Instrumental | 3505a52 | 2019-01-31 14:49:24 -0600 | [diff] [blame] | 59 | cd ../auth-cass/docker |
sandovalfr | d6bda19 | 2019-03-21 14:21:09 -0600 | [diff] [blame] | 60 | bash ./dbuild.sh $DOCKER_PULL_REGISTRY |
Instrumental | 3505a52 | 2019-01-31 14:49:24 -0600 | [diff] [blame] | 61 | cd - |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 62 | |
| 63 | # AAF Base version - set the core image, etc |
| 64 | sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \ |
Instrumental | 628b710 | 2019-02-15 19:40:04 -0600 | [diff] [blame] | 65 | -e 's/${DUSER}/'${DUSER}'/g' \ |
sandovalfr | d6bda19 | 2019-03-21 14:21:09 -0600 | [diff] [blame] | 66 | -e 's/${REGISTRY}/'${DOCKER_PULL_REGISTRY}'/g' \ |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 67 | Dockerfile.base > Dockerfile |
| 68 | $DOCKER build -t ${ORG}/${PROJECT}/aaf_base:${VERSION} . |
| 69 | $DOCKER tag ${ORG}/${PROJECT}/aaf_base:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_base:${VERSION} |
| 70 | $DOCKER tag ${ORG}/${PROJECT}/aaf_base:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_base:latest |
| 71 | rm Dockerfile |
Instrumental | 3019a28 | 2018-09-25 16:05:20 -0500 | [diff] [blame] | 72 | |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 73 | # Create the AAF Config (Security) Images |
Instrumental | 9ec2895 | 2018-07-12 11:14:10 -0500 | [diff] [blame] | 74 | cd .. |
Instrumental | 9fe1153 | 2018-10-23 17:40:47 -0500 | [diff] [blame] | 75 | cp auth-cmd/target/aaf-auth-cmd-$VERSION-full.jar sample/bin |
Instrumental | e2fa0e6 | 2019-02-07 11:09:32 -0600 | [diff] [blame] | 76 | cp auth-batch/target/aaf-auth-batch-$VERSION-full.jar sample/bin |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 77 | cp -Rf ../conf/CA sample |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 78 | |
| 79 | # AAF Config image (for AAF itself) |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 80 | sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \ |
| 81 | -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \ |
| 82 | -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \ |
Instrumental | 628b710 | 2019-02-15 19:40:04 -0600 | [diff] [blame] | 83 | -e 's/${DUSER}/'${DUSER}'/g' \ |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 84 | docker/Dockerfile.config > sample/Dockerfile |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 85 | $DOCKER build -t ${ORG}/${PROJECT}/aaf_config:${VERSION} sample |
| 86 | $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] | 87 | $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] | 88 | |
Instrumental | 93871ff | 2018-10-15 07:37:28 -0500 | [diff] [blame] | 89 | cp ../cadi/servlet-sample/target/aaf-cadi-servlet-sample-${VERSION}-sample.jar sample/bin |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 90 | # AAF Agent Image (for Clients) |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 91 | sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \ |
| 92 | -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \ |
| 93 | -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \ |
Instrumental | 628b710 | 2019-02-15 19:40:04 -0600 | [diff] [blame] | 94 | -e 's/${DUSER}/'${DUSER}'/g' \ |
Instrumental | bd7def7 | 2019-04-03 08:25:28 -0500 | [diff] [blame] | 95 | docker/Dockerfile.agent > sample/Dockerfile |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 96 | $DOCKER build -t ${ORG}/${PROJECT}/aaf_agent:${VERSION} sample |
| 97 | $DOCKER tag ${ORG}/${PROJECT}/aaf_agent:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_agent:${VERSION} |
| 98 | $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] | 99 | |
| 100 | # Clean up |
Instrumental | e2fa0e6 | 2019-02-07 11:09:32 -0600 | [diff] [blame] | 101 | rm sample/Dockerfile sample/bin/aaf-*-${VERSION}-full.jar sample/bin/aaf-cadi-servlet-sample-${VERSION}-sample.jar |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 102 | rm -Rf sample/CA |
Instrumental | 9ec2895 | 2018-07-12 11:14:10 -0500 | [diff] [blame] | 103 | cd - |
Instrumental | 365638c | 2018-10-01 15:26:03 -0500 | [diff] [blame] | 104 | |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 105 | ######## |
Instrumental | 9ec2895 | 2018-07-12 11:14:10 -0500 | [diff] [blame] | 106 | # Second, build a core Docker Image |
| 107 | echo Building aaf_$AAF_COMPONENT... |
| 108 | # Apply currrent Properties to Docker file, and put in place. |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 109 | sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \ |
| 110 | -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \ |
| 111 | -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \ |
Instrumental | 628b710 | 2019-02-15 19:40:04 -0600 | [diff] [blame] | 112 | -e 's/${DUSER}/'${DUSER}'/g' \ |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 113 | Dockerfile.core >../aaf_${VERSION}/Dockerfile |
Instrumental | 9ec2895 | 2018-07-12 11:14:10 -0500 | [diff] [blame] | 114 | cd .. |
Instrumental | bd7def7 | 2019-04-03 08:25:28 -0500 | [diff] [blame] | 115 | echo "#######" |
| 116 | pwd |
| 117 | echo "#######" |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 118 | $DOCKER build -t ${ORG}/${PROJECT}/aaf_core:${VERSION} aaf_${VERSION} |
| 119 | $DOCKER tag ${ORG}/${PROJECT}/aaf_core:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_core:${VERSION} |
| 120 | $DOCKER tag ${ORG}/${PROJECT}/aaf_core:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_core:latest |
Instrumental | 9ec2895 | 2018-07-12 11:14:10 -0500 | [diff] [blame] | 121 | rm aaf_${VERSION}/Dockerfile |
| 122 | cd - |
Sai Gandham | 6611834 | 2018-04-04 15:33:05 -0500 | [diff] [blame] | 123 | |
Instrumental | 93871ff | 2018-10-15 07:37:28 -0500 | [diff] [blame] | 124 | ####### |
| 125 | # Do all the Containers related to AAF Services |
| 126 | ####### |
sandovalfr | d6bda19 | 2019-03-21 14:21:09 -0600 | [diff] [blame] | 127 | if [ $AAF_COMPONENTS == "ALL" ]; then |
Instrumental | bd7def7 | 2019-04-03 08:25:28 -0500 | [diff] [blame] | 128 | AAF_COMPONENTS=$(cat components) |
Sai Gandham | 6611834 | 2018-04-04 15:33:05 -0500 | [diff] [blame] | 129 | fi |
| 130 | |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 131 | cp ../sample/bin/pod_wait.sh ../aaf_${VERSION}/bin |
Sai Gandham | 6611834 | 2018-04-04 15:33:05 -0500 | [diff] [blame] | 132 | for AAF_COMPONENT in ${AAF_COMPONENTS}; do |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 133 | echo Building aaf_$AAF_COMPONENT... |
Instrumental | bd7def7 | 2019-04-03 08:25:28 -0500 | [diff] [blame] | 134 | if [ "hello" = "${AAF_COMPONENT}" ]; then |
| 135 | echo Building Hello separately |
| 136 | DF="Dockerfile.hello" |
| 137 | cp -Rf ../sample/etc ../aaf_${VERSION}/etc |
| 138 | else |
| 139 | DF="Dockerfile.ms" |
| 140 | fi |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 141 | sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \ |
| 142 | -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \ |
| 143 | -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \ |
Instrumental | 628b710 | 2019-02-15 19:40:04 -0600 | [diff] [blame] | 144 | -e 's/${DUSER}/'${DUSER}'/g' \ |
Instrumental | bd7def7 | 2019-04-03 08:25:28 -0500 | [diff] [blame] | 145 | $DF >../aaf_${VERSION}/Dockerfile |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 146 | cd .. |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 147 | $DOCKER build -t ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} aaf_${VERSION} |
| 148 | $DOCKER tag ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} |
| 149 | $DOCKER tag ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:latest |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 150 | rm aaf_${VERSION}/Dockerfile |
Instrumental | bd7def7 | 2019-04-03 08:25:28 -0500 | [diff] [blame] | 151 | if [ -e aaf_${VERSION}/etc ]; then |
| 152 | rm -Rf aaf_${VERSION}/etc |
| 153 | fi |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 154 | cd - |
Sai Gandham | 6611834 | 2018-04-04 15:33:05 -0500 | [diff] [blame] | 155 | done |
Instrumental | bd7def7 | 2019-04-03 08:25:28 -0500 | [diff] [blame] | 156 | |
| 157 | # Final cleanup |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 158 | rm ../aaf_${VERSION}/bin/pod_wait.sh |