-# Remove existing images if exist
-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_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 $WORKSPACE/docker
-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
+cd $DOCKER_PATH || exit 1
+HOST_ARCH="$(uname -m)"
+#If there is a patch for other arch then x86, apply the patch and
+#replace Dockerfile file
+dockerfile_patch="Dockerfile.${HOST_ARCH}.patch"
+if [[ -f "${dockerfile_patch}" ]]; then
+ patch -f Dockerfile -p1 < "${dockerfile_patch}"