Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 3 | # build_docker_image() - Build Docker container image from source code |
| 4 | function 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 | } |