build 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/bash
  2. # build
  3. #
  4. # This is a hook in the docker-chevereto repo by Tan Nguyen
  5. # This is intended to be run locally, or via the automatic builder by Docker hub
  6. # The script should be execute from the root of the project
  7. # The list of versions of the image (ie. tag) which we wish to build is available in the file versions in the root of the project
  8. echo "------ HOOK START - BUILD -------"
  9. DOCKER_HUB_NAME=nmtan/chevereto
  10. VERSION_LIST_FILE=versions
  11. BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
  12. function build_image(){
  13. if [ $# -lt 1 ]; then
  14. # missing the damn tag
  15. return 0;
  16. fi
  17. tag_name="${1}"
  18. image_full_name="${DOCKER_HUB_NAME}:${tag_name}"
  19. case "${tag_name}" in
  20. latest)
  21. # Latest version - we do not need the version argument - latest version is defined in Dockerfile itself
  22. docker build --rm --build-arg BUILD_DATE="${BUILD_DATE}" \
  23. --build-arg CHEVERETO_VERSION="master" \
  24. -t "${image_full_name}" .
  25. ;;
  26. installer)
  27. # Latest version - we do not need the version argument - latest version is defined in Dockerfile itself
  28. docker build --rm --build-arg BUILD_DATE="${BUILD_DATE}" \
  29. -f Dockerfile-installer \
  30. -t "${image_full_name}" .
  31. ;;
  32. 1.3.*)
  33. # These versions support php 7.3
  34. docker build --rm --build-arg BUILD_DATE="${BUILD_DATE}" \
  35. --build-arg CHEVERETO_VERSION="${1}" \
  36. -t "${image_full_name}" .
  37. ;;
  38. 1.2.*)
  39. # These versions support php 7.3
  40. docker build --rm --build-arg BUILD_DATE="${BUILD_DATE}" \
  41. --build-arg PHP_VERSION="7.3-apache" \
  42. --build-arg CHEVERETO_VERSION="${1}" \
  43. -t "${image_full_name}" .
  44. ;;
  45. 1.1.*)
  46. # These versions support php 7.2
  47. docker build --rm --build-arg BUILD_DATE="${BUILD_DATE}" \
  48. --build-arg CHEVERETO_VERSION="${1}" \
  49. --build-arg PHP_VERSION="7.2-apache" \
  50. -t "${image_full_name}" .
  51. ;;
  52. 1.0.1[0-3]|1.0.[6-9])
  53. # These versions support PHP 7.1
  54. docker build --rm --build-arg BUILD_DATE="${BUILD_DATE}" \
  55. --build-arg CHEVERETO_VERSION="${1}" \
  56. --build-arg PHP_VERSION="7.1.23-apache" \
  57. -t "${image_full_name}" .
  58. ;;
  59. *)
  60. # These versions support PHP below 7.1
  61. docker build --rm --build-arg BUILD_DATE="${BUILD_DATE}" \
  62. --build-arg CHEVERETO_VERSION="${1}" \
  63. --build-arg PHP_VERSION="7.0.32-apache" \
  64. -t "${image_full_name}" .
  65. ;;
  66. esac
  67. docker push "${image_full_name}"
  68. }
  69. while read -r tag; do
  70. echo "Building the image ${DOCKER_HUB_NAME}:${tag}"
  71. build_image "${tag}"
  72. done < ${VERSION_LIST_FILE}
  73. echo "------ HOOK END - BUILD -------"