build.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 Machine Learning HPCC Systems Docker images
  19. #
  20. usage()
  21. {
  22. echo "Usage: build.sh [options]"
  23. echo " -h Display help"
  24. echo " -l Tag the images as the latest"
  25. echo " -m ML feature: one of ml, gnn and gnn-gpu"
  26. echo " -t Tag of base image hpccsystems/platform-core"
  27. exit
  28. }
  29. LABEL=
  30. FEATURE=
  31. while getopts “hlm:t:” opt; do
  32. case $opt in
  33. l) TAGLATEST=1 ;;
  34. m) FEATURE=$OPTARG ;;
  35. t) LABEL=$OPTARG ;;
  36. h) usage ;;
  37. esac
  38. done
  39. shift $(( $OPTIND-1 ))
  40. [[ -z ${FEATURE} ]] && usage
  41. ml_features=(
  42. 'ml'
  43. 'gnn'
  44. 'gnn-gpu'
  45. )
  46. found="false"
  47. for ml_feature in ${ml_features[@]}
  48. do
  49. if [[ $ml_feature == $FEATURE ]]
  50. then
  51. found="true"
  52. break
  53. fi
  54. done
  55. if [[ "$found" == "false" ]]
  56. then
  57. echo "Unknown ML feature $FEATURE"
  58. fi
  59. [[ -z ${LABEL} ]] && LABEL=latest
  60. build_image()
  61. {
  62. name=$1
  63. docker image build -t hpccsystems/platform-${name}:${LABEL} \
  64. --build-arg DOCKER_REPO=hpccsystems \
  65. --build-arg BUILD_LABEL=${LABEL} \
  66. ${name}/
  67. if [ "$TAGLATEST" = "1" ] && [ "${LABEL}" != "latest" ]; then
  68. docker tag hpccsystems/platform-${name}:${LABEL} hpccsystems/platform-${name}
  69. fi
  70. }
  71. echo .
  72. echo "build_image $FEATURE"
  73. build_image $FEATURE