Christopher Lott (cl778h) | a9627f8 | 2017-07-26 11:49:07 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Builds Portal, Portal-SDK and DMaaP-BC webapps; |
| 3 | # then packages all into a docker. |
| 4 | # Prereq: all three projects have been cloned from git. |
| 5 | # Expects to be invoked with CWD=portal/deliveries |
| 6 | # Caches files in local directory for docker build. |
| 7 | |
| 8 | # Stop on error; show output |
| 9 | set -e -x |
| 10 | |
| 11 | # For debugging only bcox the FE build takes a long time |
| 12 | SKIPFE=N |
| 13 | if [ $# -gt 0 -a "$1" == "skipfe" ] ; then |
| 14 | echo "Skipping Portal-FE build step" |
| 15 | SKIPFE=Y |
| 16 | fi |
| 17 | |
| 18 | # Establish environment variables |
| 19 | echo "Set variables" |
| 20 | source $(dirname $0)/os_settings.sh |
| 21 | |
| 22 | # Work standalone AND in the ONAP Jenkins. |
| 23 | # Pick up Jenkins settings for this script. |
| 24 | # Use -B for batch operation to skip download progress output |
| 25 | if [ -n "$MVN" ]; then |
| 26 | export MVN="${MVN} -B -gs ${GLOBAL_SETTINGS_FILE} -s ${SETTINGS_FILE}" |
| 27 | else |
| 28 | MVN=mvn |
| 29 | fi |
| 30 | |
| 31 | # This expects to start in the deliveries folder; make sure |
| 32 | DOCKERFILE=Dockerfile.portalapps |
| 33 | if [ ! -f $DOCKERFILE ] ; then |
| 34 | echo "Failed to find expected file; must start in deliveries folder" |
| 35 | exit 1 |
| 36 | fi |
| 37 | |
| 38 | # Establish directories and variables |
| 39 | DELIV="$(pwd)" |
| 40 | # Relative path of temp directory |
| 41 | BUILD="build" |
| 42 | # Absolute path of temp directory |
| 43 | OUT=$DELIV/$BUILD |
| 44 | if [ $SKIPFE == "Y" ]; then |
| 45 | echo "Skipping clean/recreate of $OUT" |
| 46 | else |
| 47 | rm -fr $OUT |
| 48 | mkdir $OUT |
| 49 | fi |
| 50 | # parent directory |
| 51 | cd .. |
| 52 | BASE="$(pwd)" |
| 53 | |
| 54 | # Copy DDL/DML to required directories (old scripts use long path /PROJECT/...) |
| 55 | cd $DELIV |
| 56 | rm -fr PROJECT |
| 57 | # copy over DB scripts for the dockerfiles |
| 58 | # forgive the ugly trick with the .. at end. |
| 59 | mkdir -p ${SCRIPT_COMMON_DIR} && cp -r $BASE/ecomp-portal-DB-common ${SCRIPT_COMMON_DIR}/.. |
| 60 | mkdir -p ${SCRIPT_DIR} && cp -r $BASE/ecomp-portal-DB-os ${SCRIPT_DIR}/.. |
| 61 | mkdir -p ${SDK_COMMON_SCRIPT_DIR} && cp -r $BASE/sdk/ecomp-sdk/epsdk-app-common/db-scripts ${SDK_COMMON_SCRIPT_DIR}/.. |
| 62 | mkdir -p ${SDK_SCRIPT_DIR} && cp -r $BASE/sdk/ecomp-sdk/epsdk-app-os/db-scripts ${SDK_SCRIPT_DIR}/.. |
| 63 | # Build complete database script for DBC |
| 64 | DBCA_OPEN_SD=$BASE/dmaapbc/dcae_dmaapbc_webapp/dbca-os/db-scripts |
| 65 | DBCA_COMM_SD=$BASE/dmaapbc/dcae_dmaapbc_webapp/dbca-common/db-scripts |
| 66 | # Old scripts expect this path |
| 67 | mkdir -p $DBC_SCRIPT_DIR |
| 68 | cat $DBCA_OPEN_SD/dbca-create-mysql-1707-os.sql $DBCA_COMM_SD/dbca-ddl-mysql-1707-common.sql $DBCA_OPEN_SD/dbca-dml-mysql-1707-os.sql > $DBC_SCRIPT_DIR/dbca-complete-mysql-1707-os.sql |
| 69 | |
| 70 | cd $BASE/ecomp-portal-BE-common |
| 71 | ${MVN} clean install |
| 72 | |
| 73 | cd $BASE/ecomp-portal-BE-os |
| 74 | ${MVN} clean package |
| 75 | cp target/ecompportal-be-os.war $OUT |
| 76 | |
| 77 | cd $BASE/ecomp-portal-FE-os/ |
| 78 | if [ $SKIPFE == "Y" ]; then |
| 79 | echo "Skipping MVN in $(pwd)" |
| 80 | else |
| 81 | ${MVN} clean package |
| 82 | cp -r dist/public $OUT |
| 83 | fi |
| 84 | |
| 85 | cd $BASE/sdk/ecomp-sdk/epsdk-app-os |
| 86 | ${MVN} clean package |
| 87 | cp target/epsdk-app-os.war $OUT |
| 88 | |
| 89 | cd $BASE/dmaapbc/dcae_dmaapbc_webapp |
| 90 | ${MVN} clean package |
| 91 | cp dbca-os/target/dmaap-bc-app-os.war $OUT |
| 92 | |
| 93 | PROXY_ARGS="" |
| 94 | if [ $HTTP_PROXY ]; then |
| 95 | PROXY_ARGS+="--build-arg HTTP_PROXY=${HTTP_PROXY}" |
| 96 | fi |
| 97 | if [ $HTTPS_PROXY ]; then |
| 98 | PROXY_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}" |
| 99 | fi |
| 100 | |
| 101 | # build portal docker |
| 102 | cd $DELIV |
| 103 | PORTAL_DOCKER_CMD=" |
Christopher Lott (cl778h) | cc805e7 | 2017-07-26 18:04:56 -0400 | [diff] [blame^] | 104 | docker build -t ${EP_IMG_NAME} ${PROXY_ARGS} |
Christopher Lott (cl778h) | a9627f8 | 2017-07-26 11:49:07 -0400 | [diff] [blame] | 105 | --build-arg FE_DIR=$BUILD/public |
| 106 | --build-arg PORTAL_WAR=$BUILD/ecompportal-be-os.war |
| 107 | --build-arg SDK_WAR=$BUILD/epsdk-app-os.war |
| 108 | --build-arg DBC_WAR=$BUILD/dmaap-bc-app-os.war |
| 109 | -f $DOCKERFILE . |
| 110 | " |
| 111 | echo "Invoking portal docker build" |
| 112 | $PORTAL_DOCKER_CMD |
| 113 | |
| 114 | # Build widget-ms docker |
| 115 | cd $BASE/ecomp-portal-widget-ms |
| 116 | ${MVN} package docker:build |