You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.7 KiB

  1. #!/bin/bash
  2. ## Called by git-hooks or by hand, it should produce a master git-sub repository
  3. ## it should:
  4. ## - checkout the correct BRANCH of GIT_REPOS in DOCKER_UPDATE_PATH
  5. ## - launch a build of IMAGE with special option to copy the git repos checkouted
  6. ## - push the image to UPDATED_IMAGE_NAME
  7. #!-
  8. . /etc/shlib
  9. #!-
  10. DOCKER_UPDATE_PATH=${DOCKER_UPDATE_PATH:-/srv/docker-builder}
  11. include common
  12. include pretty
  13. usage="$exname COMPONENT CHARM MASTER_IMAGE_NAME BRANCH"
  14. if [ "$#" == 0 ]; then
  15. print_usage
  16. exit 0
  17. fi
  18. COMPONENT_NAME="$1"
  19. CHARM="$2"
  20. MASTER_IMAGE_NAME="$3"
  21. BRANCH="$4"
  22. if [ -z "$COMPONENT_NAME" ]; then
  23. print_error "You need to specify a component name as first argument."
  24. fi
  25. if [ -z "$CHARM" ]; then
  26. print_error "You need to specify a charm name as second argument."
  27. fi
  28. if [ -z "$MASTER_IMAGE_NAME" ]; then
  29. print_error "You need to specify a master image ame as first argument. (ie: docker.0k.io/odoo:master)"
  30. fi
  31. if [ -z "$BRANCH" ]; then
  32. print_error "You need to specify a branch as fourth argument. (ie: 8.0/0k/dev/master)"
  33. fi
  34. . /etc/charm/global.conf
  35. ## git-sub co should be so much better !
  36. set -ex
  37. mkdir -p "$DOCKER_UPDATE_PATH"
  38. cd "$DOCKER_UPDATE_PATH"
  39. rm -rf "$COMPONENT_NAME"
  40. time git sub clone $GIT_0K_CLONE_OPTIONS $GIT_0K_SUB_CLONE_OPTIONS -b "$BRANCH" \
  41. "$GIT_0K_BASE"/0k/"$COMPONENT_NAME"
  42. docker rmi "$CHARM" || true
  43. export DOCKER_RUN_OPTS="-v $DOCKER_UPDATE_PATH/$COMPONENT_NAME:$DOCKER_UPDATE_PATH/$COMPONENT_NAME"
  44. time ODOO_CP_FROM_DIR="$DOCKER_UPDATE_PATH/$COMPONENT_NAME" EXTRA_CHARM_VARS="ODOO_CP_FROM_DIR" docker-build-charm "$CHARM"
  45. docker tag "$CHARM" "$MASTER_IMAGE_NAME"
  46. docker push "$MASTER_IMAGE_NAME"