blob: f464997665a394f5b59fbd3da7fc392c489bb566 [file] [log] [blame]
Victor Moralesdd074802017-07-26 16:06:35 -05001#!/bin/bash
2
3# compile_src() - Function that compiles the java source code thru maven
4function compile_src {
5 local src_folder=$1
6 pushd $src_folder
7 if [ -f pom.xml ]; then
8 install_maven
9 mvn clean install -U -DskipTests=true -Dmaven.test.skip=true -Dmaven.javadoc.skip=true -Dadditionalparam=-Xdoclint:none
10 fi
11 popd
12}
13
14# build_docker_image() - Build Docker container image from source code
15function build_docker_image {
16 local src_folder=$1
17 local profile=$2
18 install_maven
19 install_docker
20 pushd $src_folder
21
22 # Cleanup external repo
23 sed -i 's|${docker.push.registry}/||g' pom.xml
24 local mvn_docker="mvn clean package docker:build"
25 if [ $profile ]; then
26 mvn_docker+=" -P $profile"
27 fi
28 if [ $http_proxy ]; then
29 if ! grep -ql "docker.buildArg.http_proxy" pom.xml ; then
30 mvn_docker+=" -Ddocker.buildArg.http_proxy=$http_proxy"
31 fi
32 if ! grep -ql "docker.buildArg.HTTP_PROXY" pom.xml ; then
33 mvn_docker+=" -Ddocker.buildArg.HTTP_PROXY=$http_proxy"
34 fi
35 fi
36 if [ $https_proxy ]; then
37 if ! grep -ql "docker.buildArg.https_proxy" pom.xml ; then
38 mvn_docker+=" -Ddocker.buildArg.https_proxy=$https_proxy"
39 fi
40 if ! grep -ql "docker.buildArg.HTTPS_PROXY" pom.xml ; then
41 mvn_docker+=" -Ddocker.buildArg.HTTPS_PROXY=$https_proxy"
42 fi
43 fi
44 eval $mvn_docker
45 popd
46}