incr.sh 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/bin/bash
  2. ##############################################################################
  3. #
  4. # HPCC SYSTEMS software Copyright (C) 2020 HPCC Systems®.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. ##############################################################################
  18. # Use this script to build local images for testing, while leveraging the work already done in the most recent tag
  19. # on the branch that your local branch was based on
  20. #
  21. # Pass in a get commit (that you previously built using this script) if you want to override the default calculation
  22. # of the base build
  23. HEAD=$(git rev-parse --short HEAD)
  24. PREV=$1
  25. # Look for an image that matches a commit, exclude images based on dirty working tree.
  26. [[ -z ${PREV} ]] && PREV=$(git log --format=format:%h-Debug $(git describe --abbrev=0 --tags)..HEAD | grep `docker images hpccsystems/platform-build --format {{.Tag}} | egrep -ve '-dirty$' | head -n 1`)
  27. # If not found above, look for latest tagged
  28. [[ -z ${PREV} ]] && PREV=$(git describe --abbrev=0 --tags)-Debug
  29. # If working tree is dirty, annotate build tag, so doesn't conflict with base commit
  30. [[ -n "$(git status -uno --porcelain)" ]] && DIRTY="-dirty"
  31. BUILD_TYPE=Debug
  32. BUILD_LABEL=${HEAD}-Debug${DIRTY}
  33. if [[ "$BUILD_LABEL" == "$PREV" ]] ; then
  34. echo Docker image hpccsystems/platform-core:${HEAD} already exists
  35. PREV=$(git log --format=format:%h-Debug $(git describe --abbrev=0 --tags)..HEAD | grep `docker images hpccsystems/platform-build --format {{.Tag}} | head -n 2 | tail -n 1`)
  36. [[ -z ${PREV} ]] && PREV=$(git describe --abbrev=0 --tags)-Debug
  37. fi
  38. set -e
  39. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  40. pushd $DIR 2>&1 > /dev/null
  41. echo Building local incremental images [BUILD_LABEL=${BUILD_LABEL}] based on ${PREV}
  42. if [[ -n "$FORCE" ]] ; then
  43. docker image build -t hpccsystems/platform-build:${BUILD_LABEL} --build-arg PREV_LABEL=${HEAD}-Debug --build-arg BASE_VER=7.8 --build-arg BUILD_TYPE=Debug platform-build/
  44. else
  45. PREV_COMMIT=$(echo "${PREV}" | sed -e "s/-Debug//")
  46. git diff --binary ${PREV_COMMIT} ':!./' > platform-build-incremental/hpcc.gitpatch
  47. # PATCH_MD5 is an ARG of the docker file, which ensures that if different from cached version, image will rebuild from that stage
  48. PATCH_MD5=$(md5sum platform-build-incremental/hpcc.gitpatch | awk '{print $1}')
  49. docker image build -t hpccsystems/platform-build:${BUILD_LABEL} --build-arg PREV_LABEL=${PREV} --build-arg PATCH_MD5=${PATCH_MD5} platform-build-incremental/
  50. rm platform-build-incremental/hpcc.gitpatch
  51. fi
  52. docker image build -t hpccsystems/platform-core:${BUILD_LABEL} --build-arg BUILD_LABEL=${BUILD_LABEL} platform-core-debug/
  53. docker image build -t hpccsystems/roxie:${BUILD_LABEL} --build-arg BUILD_LABEL=${BUILD_LABEL} roxie/
  54. docker image build -t hpccsystems/dali:${BUILD_LABEL} --build-arg BUILD_LABEL=${BUILD_LABEL} dali/
  55. docker image build -t hpccsystems/esp:${BUILD_LABEL} --build-arg BUILD_LABEL=${BUILD_LABEL} esp/
  56. docker image build -t hpccsystems/eclccserver:${BUILD_LABEL} --build-arg BUILD_LABEL=${BUILD_LABEL} eclccserver/
  57. docker image build -t hpccsystems/eclagent:${BUILD_LABEL} --build-arg BUILD_LABEL=${BUILD_LABEL} eclagent/
  58. docker image build -t hpccsystems/hthor:${BUILD_LABEL} --build-arg BUILD_LABEL=${BUILD_LABEL} hthor/
  59. docker image build -t hpccsystems/toposerver:${BUILD_LABEL} --build-arg BUILD_LABEL=${BUILD_LABEL} toposerver/
  60. docker image build -t hpccsystems/thormaster:${BUILD_LABEL} --build-arg BUILD_LABEL=${BUILD_LABEL} thormaster/
  61. docker image build -t hpccsystems/thorslave:${BUILD_LABEL} --build-arg BUILD_LABEL=${BUILD_LABEL} thorslave/
  62. echo Built hpccsystems/*:${BUILD_LABEL}