|
34 | 34 | # pull-or-rebuild-image.sh - rebuilds the Docker image used in the |
35 | 35 | # current Travis build if necessary. |
36 | 36 | # |
37 | | -# The script rebuilds the Docker image if the Dockerfile for the current |
38 | | -# OS version (Dockerfile.${OS}-${OS_VER}) or any .sh script from the directory |
39 | | -# with Dockerfiles were modified and committed. |
| 37 | +# The script rebuilds the Docker image if: |
| 38 | +# 1. the Dockerfile for the current OS version (Dockerfile.${OS}-${OS_VER}) |
| 39 | +# or any .sh script in the Dockerfiles directory were modified and committed, or |
| 40 | +# 2. "rebuild" param was passed as a first argument to this script. |
40 | 41 | # |
41 | 42 | # If the Travis build is not of the "pull_request" type (i.e. in case of |
42 | 43 | # merge after pull_request) and it succeed, the Docker image should be pushed |
43 | 44 | # to the Docker Hub repository. An empty file is created to signal that to |
44 | 45 | # further scripts. |
45 | 46 | # |
46 | 47 | # If the Docker image does not have to be rebuilt, it will be pulled from |
47 | | -# Docker Hub. |
| 48 | +# the Docker Hub. |
48 | 49 | # |
49 | 50 |
|
50 | 51 | set -e |
@@ -75,6 +76,18 @@ if [[ -z "$HOST_WORKDIR" ]]; then |
75 | 76 | exit 1 |
76 | 77 | fi |
77 | 78 |
|
| 79 | +# Path to directory with Dockerfiles and image building scripts |
| 80 | +images_dir_name=images |
| 81 | +base_dir=utils/docker/$images_dir_name |
| 82 | + |
| 83 | +# If "rebuild" param is passed to the script, force rebuild |
| 84 | +if [[ "${1}" == "rebuild" ]]; then |
| 85 | + pushd ${images_dir_name} |
| 86 | + ./build-image.sh ${DOCKERHUB_REPO} ${OS}-${OS_VER} |
| 87 | + popd |
| 88 | + exit 0 |
| 89 | +fi |
| 90 | + |
78 | 91 | # TRAVIS_COMMIT_RANGE is usually invalid for force pushes - ignore such values |
79 | 92 | # when used with non-upstream repository |
80 | 93 | if [ -n "$TRAVIS_COMMIT_RANGE" -a $TRAVIS_REPO_SLUG != "${GITHUB_REPO}" ]; then |
@@ -102,10 +115,6 @@ files=$(for commit in $commits; do git diff-tree --no-commit-id --name-only \ |
102 | 115 | echo "Files modified within the commit range:" |
103 | 116 | for file in $files; do echo $file; done |
104 | 117 |
|
105 | | -# Path to directory with Dockerfiles and image building scripts |
106 | | -images_dir_name=images |
107 | | -base_dir=utils/docker/$images_dir_name |
108 | | - |
109 | 118 | # Check if committed file modifications require the Docker image to be rebuilt |
110 | 119 | for file in $files; do |
111 | 120 | # Check if modified files are relevant to the current build |
|
0 commit comments