blob: a45e55ccd0675202953f8a80bed0afb856c44597 [file] [log] [blame]
Christopher Lott (cl778h)a9627f82017-07-26 11:49:07 -04001#!/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
9set -e -x
10
11# For debugging only bcox the FE build takes a long time
12SKIPFE=N
13if [ $# -gt 0 -a "$1" == "skipfe" ] ; then
14 echo "Skipping Portal-FE build step"
15 SKIPFE=Y
16fi
17
18# Establish environment variables
19echo "Set variables"
20source $(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
25if [ -n "$MVN" ]; then
26 export MVN="${MVN} -B -gs ${GLOBAL_SETTINGS_FILE} -s ${SETTINGS_FILE}"
27else
28 MVN=mvn
29fi
30
31# This expects to start in the deliveries folder; make sure
32DOCKERFILE=Dockerfile.portalapps
33if [ ! -f $DOCKERFILE ] ; then
34 echo "Failed to find expected file; must start in deliveries folder"
35 exit 1
36fi
37
38# Establish directories and variables
39DELIV="$(pwd)"
40# Relative path of temp directory
41BUILD="build"
42# Absolute path of temp directory
43OUT=$DELIV/$BUILD
44if [ $SKIPFE == "Y" ]; then
45 echo "Skipping clean/recreate of $OUT"
46else
47 rm -fr $OUT
48 mkdir $OUT
49fi
50# parent directory
51cd ..
52BASE="$(pwd)"
53
54# Copy DDL/DML to required directories (old scripts use long path /PROJECT/...)
55cd $DELIV
56rm -fr PROJECT
57# copy over DB scripts for the dockerfiles
58# forgive the ugly trick with the .. at end.
59mkdir -p ${SCRIPT_COMMON_DIR} && cp -r $BASE/ecomp-portal-DB-common ${SCRIPT_COMMON_DIR}/..
60mkdir -p ${SCRIPT_DIR} && cp -r $BASE/ecomp-portal-DB-os ${SCRIPT_DIR}/..
61mkdir -p ${SDK_COMMON_SCRIPT_DIR} && cp -r $BASE/sdk/ecomp-sdk/epsdk-app-common/db-scripts ${SDK_COMMON_SCRIPT_DIR}/..
62mkdir -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
64DBCA_OPEN_SD=$BASE/dmaapbc/dcae_dmaapbc_webapp/dbca-os/db-scripts
65DBCA_COMM_SD=$BASE/dmaapbc/dcae_dmaapbc_webapp/dbca-common/db-scripts
66# Old scripts expect this path
67mkdir -p $DBC_SCRIPT_DIR
68cat $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
70cd $BASE/ecomp-portal-BE-common
71${MVN} clean install
72
73cd $BASE/ecomp-portal-BE-os
74${MVN} clean package
75cp target/ecompportal-be-os.war $OUT
76
77cd $BASE/ecomp-portal-FE-os/
78if [ $SKIPFE == "Y" ]; then
79 echo "Skipping MVN in $(pwd)"
80else
81 ${MVN} clean package
82 cp -r dist/public $OUT
83fi
84
85cd $BASE/sdk/ecomp-sdk/epsdk-app-os
86${MVN} clean package
87cp target/epsdk-app-os.war $OUT
88
89cd $BASE/dmaapbc/dcae_dmaapbc_webapp
90${MVN} clean package
91cp dbca-os/target/dmaap-bc-app-os.war $OUT
92
93PROXY_ARGS=""
94if [ $HTTP_PROXY ]; then
95 PROXY_ARGS+="--build-arg HTTP_PROXY=${HTTP_PROXY}"
96fi
97if [ $HTTPS_PROXY ]; then
98 PROXY_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
99fi
100
101# build portal docker
102cd $DELIV
103PORTAL_DOCKER_CMD="
Christopher Lott (cl778h)cc805e72017-07-26 18:04:56 -0400104 docker build -t ${EP_IMG_NAME} ${PROXY_ARGS}
Christopher Lott (cl778h)a9627f82017-07-26 11:49:07 -0400105 --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"
111echo "Invoking portal docker build"
112$PORTAL_DOCKER_CMD
113
114# Build widget-ms docker
115cd $BASE/ecomp-portal-widget-ms
116${MVN} package docker:build