X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=jjb%2Freleng%2Fopnfv-docker.sh;h=9bd711bc67e3dcd69afa73d32fcd723ca6b0b330;hb=b18f528cd8b058d2c575e48c8882771fa63a9dcf;hp=e26727abff3997c0a80be5135dddd43ec3a58d4d;hpb=3303f3d2aa25726b8a6826df7b4dfc697a11d50a;p=releng.git diff --git a/jjb/releng/opnfv-docker.sh b/jjb/releng/opnfv-docker.sh index e26727abf..9bd711bc6 100644 --- a/jjb/releng/opnfv-docker.sh +++ b/jjb/releng/opnfv-docker.sh @@ -12,6 +12,7 @@ set -o nounset set -o pipefail + echo "Starting opnfv-docker for $DOCKER_REPO_NAME ..." echo "--------------------------------------------------------" echo @@ -42,32 +43,39 @@ fi if [[ -n "$(docker images | grep $DOCKER_REPO_NAME)" ]]; then echo "Docker images to remove:" docker images | head -1 && docker images | grep $DOCKER_REPO_NAME - image_tags=($(docker images | grep $DOCKER_REPO_NAME | awk '{print $2}')) - for tag in "${image_tags[@]}"; do - if [[ -n "$(docker images|grep $DOCKER_REPO_NAME|grep $tag)" ]]; then - echo "Removing docker image $DOCKER_REPO_NAME:$tag..." - docker rmi -f $DOCKER_REPO_NAME:$tag + image_ids=($(docker images | grep $DOCKER_REPO_NAME | awk '{print $3}')) + for id in "${image_ids[@]}"; do + if [[ -n "$(docker images|grep $DOCKER_REPO_NAME|grep $id)" ]]; then + echo "Removing docker image $DOCKER_REPO_NAME:$id..." + docker rmi -f $id fi done fi - -# cd to directory where Dockerfile is located cd $WORKSPACE/docker -if [ ! -f ./Dockerfile ]; then - echo "ERROR: Dockerfile not found." - exit 1 +HOST_ARCH=$(uname -m) +if [ ! -f "${DOCKERFILE}" ]; then + # If this is expected to be a Dockerfile for other arch than x86 + # and it does not exist, but there is a patch for the said arch, + # then apply the patch and create the Dockerfile.${HOST_ARCH} file + if [[ "${DOCKERFILE}" == *"${HOST_ARCH}" && \ + -f "Dockerfile.${HOST_ARCH}.patch" ]]; then + patch -o Dockerfile."${HOST_ARCH}" Dockerfile \ + Dockerfile."${HOST_ARCH}".patch + else + echo "ERROR: No Dockerfile or ${HOST_ARCH} patch found." + exit 1 + fi fi # Get tag version -branch="${GIT_BRANCH##origin/}" -echo "Current branch: $branch" +echo "Current branch: $BRANCH" -if [[ "$branch" == "master" ]]; then +if [[ "$BRANCH" == "master" ]]; then DOCKER_TAG="latest" else - if [[ "$RELEASE_VERSION" != "" ]]; then - release=$(echo $branch|sed 's/.*\///') + if [[ -n "${RELEASE_VERSION-}" ]]; then + release=${BRANCH##*/} DOCKER_TAG=${release}.${RELEASE_VERSION} # e.g. colorado.1.0, colorado.2.0, colorado.3.0 else @@ -79,7 +87,12 @@ fi echo "Building docker image: $DOCKER_REPO_NAME:$DOCKER_TAG" echo "--------------------------------------------------------" echo -cmd="docker build --no-cache -t $DOCKER_REPO_NAME:$DOCKER_TAG --build-arg BRANCH=$branch ." +if [[ $DOCKER_REPO_NAME == *"dovetail"* ]]; then + cmd="docker build --no-cache -t $DOCKER_REPO_NAME:$DOCKER_TAG -f $DOCKERFILE ." +else + cmd="docker build --no-cache -t $DOCKER_REPO_NAME:$DOCKER_TAG --build-arg BRANCH=$BRANCH + -f $DOCKERFILE ." +fi echo ${cmd} ${cmd}