blob: 9f2d0a1d8f053869656d63871418ab6b2919a243 [file] [log] [blame]
Victor Moralesdd074802017-07-26 16:06:35 -05001#!/bin/bash
2
Victor Moralesdd074802017-07-26 16:06:35 -05003# build_docker_image() - Build Docker container image from source code
4function build_docker_image {
5 local src_folder=$1
6 local profile=$2
7 install_maven
8 install_docker
9 pushd $src_folder
10
11 # Cleanup external repo
12 sed -i 's|${docker.push.registry}/||g' pom.xml
13 local mvn_docker="mvn clean package docker:build"
14 if [ $profile ]; then
15 mvn_docker+=" -P $profile"
16 fi
17 if [ $http_proxy ]; then
18 if ! grep -ql "docker.buildArg.http_proxy" pom.xml ; then
19 mvn_docker+=" -Ddocker.buildArg.http_proxy=$http_proxy"
20 fi
21 if ! grep -ql "docker.buildArg.HTTP_PROXY" pom.xml ; then
22 mvn_docker+=" -Ddocker.buildArg.HTTP_PROXY=$http_proxy"
23 fi
24 fi
25 if [ $https_proxy ]; then
26 if ! grep -ql "docker.buildArg.https_proxy" pom.xml ; then
27 mvn_docker+=" -Ddocker.buildArg.https_proxy=$https_proxy"
28 fi
29 if ! grep -ql "docker.buildArg.HTTPS_PROXY" pom.xml ; then
30 mvn_docker+=" -Ddocker.buildArg.HTTPS_PROXY=$https_proxy"
31 fi
32 fi
33 eval $mvn_docker
34 popd
35}