buildall.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. # Build script to create and publish Docker containers corresponding to a GitHub tag
  19. # This script is normally invoked via GitHub actions, whenever a new tag is pushed
  20. BASE_VER=7.10 # The docker hub label for the platform-build-base image. Changes rarely.
  21. BUILD_TAG=$(git describe --exact-match --tags) # The git tag for the images we are building
  22. BUILD_LABEL=${BUILD_TAG} # The docker hub label for all other components
  23. BUILD_USER=hpcc-systems # The github repo owner
  24. BUILD_TYPE= # Set to Debug for a debug build, leave blank for default (RelWithDebInfo)
  25. # These values are set in a GitHub workflow build
  26. [[ -n ${INPUT_BUILD_USER} ]] && BUILD_USER=${INPUT_BUILD_USER}
  27. [[ -n ${INPUT_BUILD_VER} ]] && BUILD_TAG=${INPUT_BUILD_VER}
  28. [[ -n ${GITHUB_REPOSITORY} ]] && BUILD_USER=${GITHUB_REPOSITORY%/*}
  29. if [[ -n ${INPUT_BUILDTYPE} ]] ; then
  30. BUILD_TYPE=$INPUT_BUILDTYPE
  31. BUILD_LABEL=${BUILD_TAG}-$INPUT_BUILDTYPE
  32. else
  33. BUILD_LABEL=${BUILD_TAG}
  34. BUILD_TYPE=RelWithDebInfo
  35. fi
  36. if [[ -n ${INPUT_USERNAME} ]] ; then
  37. echo ${INPUT_PASSWORD} | docker login -u ${INPUT_USERNAME} --password-stdin ${INPUT_REGISTRY}
  38. PUSH=1
  39. fi
  40. if [[ -n ${INPUT_BUILD_THREADS} ]] ; then
  41. BUILD_THREADS=$INPUT_BUILD_THREADS
  42. fi
  43. if [[ -z ${BUILD_TAG} ]] ; then
  44. echo Current tag could not be located
  45. echo Perhaps you meant to run incr.sh ?
  46. exit 2
  47. fi
  48. set -e
  49. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  50. pushd $DIR 2>&1 > /dev/null
  51. . ../cmake_modules/parse_cmake.sh
  52. parse_cmake
  53. if [[ "$HPCC_MATURITY" = "release" ]] && [[ "$INPUT_LATEST" = "1" ]] ; then
  54. LATEST=1
  55. fi
  56. build_image() {
  57. local name=$1
  58. local label=$2
  59. [[ -z ${label} ]] && label=$BUILD_LABEL
  60. if ! docker pull hpccsystems/${name}:${label} ; then
  61. docker image build -t hpccsystems/${name}:${label} \
  62. --build-arg BASE_VER=${BASE_VER} \
  63. --build-arg DOCKER_REPO=hpccsystems \
  64. --build-arg BUILD_TAG=${BUILD_TAG} \
  65. --build-arg BUILD_LABEL=${BUILD_LABEL} \
  66. --build-arg BUILD_USER=${BUILD_USER} \
  67. --build-arg BUILD_TYPE=${BUILD_TYPE} \
  68. --build-arg BUILD_THREADS=${BUILD_THREADS} \
  69. ${name}/
  70. if [ "$LATEST" = "1" ] ; then
  71. docker tag hpccsystems/${name}:${label} hpccsystems/${name}:latest
  72. if [ "$PUSH" = "1" ] ; then
  73. docker push hpccsystems/${name}:${label}
  74. docker push hpccsystems/${name}:latest
  75. fi
  76. else
  77. if [ "$PUSH" = "1" ] ; then
  78. docker push hpccsystems/${name}:${label}
  79. fi
  80. fi
  81. fi
  82. }
  83. build_image platform-build-base ${BASE_VER}
  84. build_image platform-build
  85. build_image platform-core
  86. build_image roxie
  87. build_image dali
  88. build_image esp
  89. build_image eclccserver
  90. build_image eclagent
  91. build_image hthor
  92. build_image toposerver
  93. build_image thormaster
  94. build_image thorslave
  95. if [[ -n ${INPUT_PASSWORD} ]] ; then
  96. echo "::set-output name=${BUILD_LABEL}"
  97. docker logout
  98. fi