docker-image-build.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env bash
  2. #
  3. # build zammads docker & docker-compose images
  4. set -o errexit
  5. set -o pipefail
  6. REPO_ROOT="$(git rev-parse --show-toplevel)"
  7. GITHUB_REPO_USER="zammad"
  8. ZAMMAD_VERSION="$(git describe --tags | sed -e 's/-[a-z0-9]\{8,\}.*//g')"
  9. export ZAMMAD_VERSION
  10. if [ "${CIRCLE_BRANCH}" == 'develop' ]; then
  11. BUILD_SCRIPT="scripts/build_image.sh"
  12. DOCKER_REPOSITORY="zammad"
  13. export DOCKER_REPOSITORY
  14. GITHUB_REPOSITORY="zammad-docker"
  15. elif [ "${CIRCLE_BRANCH}" == 'stable' ]; then
  16. BUILD_SCRIPT="hooks/build"
  17. DOCKER_REPOSITORY="zammad-docker-compose"
  18. export DOCKER_REPOSITORY
  19. GITHUB_REPOSITORY="zammad-docker-compose"
  20. else
  21. echo "branch is ${CIRCLE_BRANCH}... no docker image build needed..."
  22. exit 0
  23. fi
  24. # dockerhub auth
  25. echo "${DOCKER_PASSWORD}" | docker login --username="${DOCKER_USERNAME}" --password-stdin
  26. # clone docker repo
  27. git clone https://github.com/"${GITHUB_REPO_USER}"/"${GITHUB_REPOSITORY}"
  28. # enter dockerfile dir
  29. cd "${REPO_ROOT}/${GITHUB_REPOSITORY}"
  30. # build & push docker image
  31. # shellcheck disable=SC1090
  32. source "${REPO_ROOT}/${GITHUB_REPOSITORY}/${BUILD_SCRIPT}"