2 # Builds Portal and Portal-SDK webapps; packages all into a docker.
3 # Prereq: all projects have been cloned from git.
4 # Expects to be invoked with CWD=portal/deliveries
5 # Caches files in local directory for docker build.
7 # Stop on error; show output
10 # This reuses the docker-compose environment file
11 echo "Set image tag name variables"
12 source $(dirname $0)/.env
14 # Check for Jenkins build number
15 if [ -n "$BUILD_NUMBER" ]; then
16 echo "Using Jenkins build number $BUILD_NUMBER"
18 # This indicates a non-Jenkins build
19 export BUILD_NUMBER="999"
22 # Must work when called by ONAP Jenkins AND local builds.
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} -Dbuild.number=$BUILD_NUMBER"
28 # Force refresh of snapshots
29 MVN="mvn -B -U -Dbuild.number=$BUILD_NUMBER"
32 # This expects to start in the deliveries folder; make sure
33 PORTAL_DOCKERFILE=Dockerfile.portal
34 if [ ! -f $PORTAL_DOCKERFILE ] ; then
35 echo "Failed to find file ${PORTAL_DOCKERFILE}; must start in deliveries folder; exiting"
38 SDK_DOCKERFILE=Dockerfile.sdk
40 # Store directory names as variables
41 # This is the deliveries area.
43 # parent directory, for finding source projects
48 # Relative path of temp directory
50 # Absolute path of temp directory
51 BUILD_ABS=$DELIVDIR/$BUILD_REL
53 # Build Java projects.
54 # (use env var toskip when debugging Docker build problems)
55 if [ "$SKIP_JAVA_BUILD" = "please" ]; then
57 echo "SKIPPING JAVA BUILD!"
60 echo "Starting Java build."
62 # Clean out and recreate
66 echo "Build jar and war files"
70 echo "Build Portal-SDK app"
71 cd $BASEDIR/sdk/ecomp-sdk/epsdk-app-os
74 echo "Java build complete."
77 echo "Copy Portal app BE"
78 cp $BASEDIR/ecomp-portal-BE-os/target/portal-be-os.war $BUILD_ABS
80 echo "Copy Portal app FE"
81 cp -r $BASEDIR/ecomp-portal-FE-os/dist/public $BUILD_ABS
83 echo "Copy Portal widget-ms"
84 cp $BASEDIR/ecomp-portal-widget-ms/widget-ms/target/widget-ms.jar $BUILD_ABS
86 echo "Copy Portal-SDK app build results"
87 cp $BASEDIR/sdk/ecomp-sdk/epsdk-app-os/target/epsdk-app-os.war $BUILD_ABS
92 if [ $HTTP_PROXY ]; then
93 PROXY_ARGS+="--build-arg HTTP_PROXY=${HTTP_PROXY}"
95 if [ $HTTPS_PROXY ]; then
96 PROXY_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
99 # must work in delivery directory
102 # Copy DDL/DML to required directories
103 # RELATIVE PATHS to local directories with database scripts
104 # bcos Docker looks within this build area only
105 DB_SCRIPT_DIR=$BUILD_REL/db-scripts
106 mkdir -p ${DELIVDIR}/${DB_SCRIPT_DIR}
108 cp $BASEDIR/ecomp-portal-DB-common/*.sql ${DB_SCRIPT_DIR}
109 cp $BASEDIR/ecomp-portal-DB-os/*.sql ${DB_SCRIPT_DIR}
111 cp $BASEDIR/sdk/ecomp-sdk/epsdk-app-common/db-scripts/*.sql ${DB_SCRIPT_DIR}
112 cp $BASEDIR/sdk/ecomp-sdk/epsdk-app-os/db-scripts/*.sql ${DB_SCRIPT_DIR}
114 echo "Build mariadb docker image"
116 docker build -t ${DB_IMG_NAME}:${PORTAL_TAG} ${PROXY_ARGS}
117 --build-arg DB_SCRIPT_DIR=${DB_SCRIPT_DIR}
118 -f Dockerfile.mariadb .
122 # Copy cassandra scripts to required directories
124 cp $BASEDIR/ecomp-portal-DB-common/*.cql ${DELIVDIR}
126 cp $BASEDIR/sdk/ecomp-sdk/epsdk-app-common/db-scripts/*.cql ${DELIVDIR}
128 # Build Docker Images
130 echo "Build portal docker image"
132 docker build -t ${EP_IMG_NAME}:${PORTAL_TAG} ${PROXY_ARGS}
133 --build-arg FE_DIR=$BUILD_REL/public
134 --build-arg PORTAL_WAR=$BUILD_REL/portal-be-os.war
135 --build-arg SERVERXML=${DELIVDIR}/server.xml
136 -f $PORTAL_DOCKERFILE .
140 echo "Build sdk demo app docker image"
142 docker build -t ${SDK_IMG_NAME}:${PORTAL_TAG} ${PROXY_ARGS}
143 --build-arg SDK_WAR=$BUILD_REL/epsdk-app-os.war
148 echo "Build widget-ms docker image"
150 docker build -t ${WMS_IMG_NAME}:${PORTAL_TAG} ${PROXY_ARGS}
151 --build-arg WMS_JAR=$BUILD_REL/widget-ms.jar
152 -f Dockerfile.widgetms .
156 # For ease of debugging, leave the build dir