build.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/bash
  2. set -ex
  3. WORK_DIR=$(dirname $(readlink -f $0))
  4. HUE_SRC=$(realpath $WORK_DIR/../..)
  5. BUILD_DIR=$(realpath $HUE_SRC/../containerbuild$GBN)
  6. HUE_DIR=$WORK_DIR/hue
  7. APACHE_DIR=$WORK_DIR/huelb
  8. REGISTRY=${REGISTRY:-"docker.io/hortonworks"}
  9. compile_hue() {
  10. mkdir -p $BUILD_DIR
  11. cd $HUE_SRC
  12. PREFIX=$BUILD_DIR make install
  13. cd $BUILD_DIR/hue
  14. APPS=$(find apps -maxdepth 2 -name "src" -type d|cut -d"/" -f2|sort| sed 's/[^ ]* */apps\/&/g')
  15. ./build/env/bin/python tools/app_reg/app_reg.py --install $APPS --relative-paths
  16. bash tools/relocatable.sh
  17. }
  18. find_git_state() {
  19. cd $HUE_SRC
  20. export GBRANCH=$(git ls-remote --get-url)"/commits/"$(git rev-parse --abbrev-ref HEAD)
  21. export GSHA=$(git ls-remote --get-url)"/commit/"$(git rev-list --no-walk HEAD)
  22. export VERSION=$(grep "VERSION=" VERSION | cut -d"=" -f2 | cut -d'"' -f2)
  23. }
  24. generate_random_string() {
  25. cd $HUE_DIR
  26. thisuser=$(uuidgen | cut -d"-" -f5)
  27. thispass=$(uuidgen | cut -d"-" -f5)
  28. sed -i -e "s|username=.*|username=${thisuser}|g" supervisor-files/etc/supervisord.conf
  29. sed -i -e "s|password=.*|password=${thispass}|g" supervisor-files/etc/supervisord.conf
  30. }
  31. docker_hue_build() {
  32. cd $HUE_DIR
  33. generate_random_string
  34. cp -a $BUILD_DIR/hue $HUE_DIR
  35. rm -f $HUE_DIR/hue/desktop/conf/*
  36. export HUEUSER="hive"
  37. docker build -f $HUE_DIR/Dockerfile -t ${REGISTRY}/hue:$GBN \
  38. --build-arg GBN=$GBN \
  39. --build-arg GSHA="$GSHA" \
  40. --build-arg GBRANCH=$GBRANCH \
  41. --build-arg VERSION=$VERSION \
  42. --build-arg HUEUSER="hive" \
  43. .
  44. }
  45. docker_huelb_build() {
  46. cd $APACHE_DIR
  47. cp -a $BUILD_DIR/hue/build/static $APACHE_DIR
  48. docker build -f $APACHE_DIR/Dockerfile -t ${REGISTRY}/huelb:$GBN \
  49. --build-arg GBN=$GBN \
  50. --build-arg GSHA="$GSHA" \
  51. --build-arg GBRANCH=$GBRANCH \
  52. --build-arg VERSION=$VERSION \
  53. .
  54. }
  55. compile_hue
  56. find_git_state
  57. docker_hue_build
  58. docker_huelb_build