+ echo "ERROR: No AAF Built. use Maven"
+ exit
+fi
+if [ ! "$VERSION" = "$JAR_VERSION" ]; then
+ START_DIR=$(pwd)
+ # Convert SNAPSHOT issues
+ cp -Rf ../aaf_$VERSION ../aaf_DBUILD
+ cd ../aaf_DBUILD/lib
+ # If Built Jars are "SNAPSHOT", convert to NON SNAPSHOT
+ for J in $(ls *-SNAPSHOT*); do mv $J ${J/-SNAPSHOT/}; done
+ cd ../bin
+ rm *.bat
+ for S in $(ls); do
+ sed -e "/$VERSION/s/$VERSION/$JAR_VERSION/g" $S > tmp
+ mv tmp $S
+ done
+ cd ${START_DIR}
+fi
+cp ../sample/bin/pod_wait.sh ../aaf_DBUILD/bin
+
+if [[ -z "$1" || "$1" = "core" ]]; then
+ ########
+ # Fourth, build a core Docker Image to be used for all AAF Components
+ # Apply currrent Properties to Docker file, and put in place.
+ sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
+ -e 's/${JAR_VERSION}/'${JAR_VERSION}'/g' \
+ -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
+ -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
+ -e 's/${DUSER}/'${DUSER}'/g' \
+ Dockerfile.core >../aaf_DBUILD/Dockerfile
+ if [ -n "$DUSER" ]; then
+ echo "USER $DUSER" >> ../aaf_DBUILD/Dockerfile
+ fi
+ cd ..
+
+ $DOCKER build -t ${ORG}/${PROJECT}/aaf_core:${VERSION} aaf_DBUILD
+ $DOCKER tag ${ORG}/${PROJECT}/aaf_core:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_core:${VERSION}
+ $DOCKER tag ${ORG}/${PROJECT}/aaf_core:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_core:latest
+ rm aaf_DBUILD/Dockerfile
+
+ cd -
+fi
+
+if [[ -z "$1" || "$1" = "hello" ]]; then
+ ########
+ # Fifth, do Hello
+ # Apply currrent Properties to Docker file, and put in place.
+ echo "### Building Hello"
+ cp ../sample/bin/client.sh ../aaf_DBUILD/bin
+ cp ../sample/hello/init.sh ../aaf_DBUILD/bin/hello_init.sh
+ SCP ../../cadi/aaf/target/aaf-cadi-aaf-${VERSION}-full.jar ../aaf_DBUILD/bin
+
+ sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
+ -e 's/${JAR_VERSION}/'${JAR_VERSION}'/g' \
+ -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
+ -e 's/${DUSER}/'${DUSER}'/g' \
+ Dockerfile.hello >../aaf_DBUILD/Dockerfile
+ #if [ -n "$DUSER" ]; then
+ # echo "USER $DUSER" >> ../aaf_DBUILD/Dockerfile
+ #fi
+
+ cd ..
+ cp -Rf sample/etc aaf_DBUILD
+ cp -Rf sample/logs aaf_DBUILD
+ cp -Rf sample/cert aaf_DBUILD
+
+ for C in cass certman cmd deforg fs gui locate oauth service; do
+ rm aaf_DBUILD/lib/aaf-auth-$C-*
+ done
+
+ $DOCKER build -t ${ORG}/${PROJECT}/aaf_hello:${VERSION} aaf_DBUILD
+ if [ -n ${DOCKER_REPOSITORY} ]; then
+ $DOCKER tag ${ORG}/${PROJECT}/aaf_hello:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_hello:${VERSION}
+ $DOCKER tag ${ORG}/${PROJECT}/aaf_hello:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_hello:latest
+ fi
+ cd -
+fi
+# Final cleanup
+rm -Rf ../aaf_DBUILD
+