echo "--------------------------------------------------------"
echo
-
-if [[ -n $(ps -ef|grep 'docker build'|grep -v grep) ]]; then
- echo "There is already another build process in progress:"
- echo $(ps -ef|grep 'docker build'|grep -v grep)
- # Abort this job since it will collide and might mess up the current one.
- echo "Aborting..."
- exit 1
-fi
+count=30 # docker build jobs might take up to ~30 min
+while [[ -n `ps -ef|grep 'docker build'|grep -v grep` ]]; do
+ echo "Build in progress. Waiting..."
+ sleep 60
+ count=$(( $count - 1 ))
+ if [ $count -eq 0 ]; then
+ echo "Timeout. Aborting..."
+ exit 1
+ fi
+done
# Remove previous running containers if exist
if [[ -n "$(docker ps -a | grep $DOCKER_REPO_NAME)" ]]; then