rebuild.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. #
  3. # Rebuild and publish all docker images.
  4. # Use the --dry-run argument to prevent the actual build process from running.
  5. #
  6. # Note: This script should not be triggered manually. Only run it in CI.
  7. #
  8. # Required env variables:
  9. #
  10. # - `DOCKER_USER`
  11. # - `DOCKER_API_KEY`
  12. SUPPORTED_BRANCH_NAMES=("master")
  13. SUPPORTED_TAG_PATTERNS=("^v2.1.\([6789]\|1[0-9]\)$")
  14. IMAGE_NAME=threema/threema-web
  15. if [ $1 == "--dry-run" ]; then
  16. echo -e "Dry run\n"
  17. DOCKER='echo > docker'
  18. else
  19. DOCKER="docker"
  20. fi
  21. echo "Logging in:"
  22. $DOCKER login -u $DOCKER_USER -p $DOCKER_API_KEY
  23. echo -e "\nBuilding branches:"
  24. for branch in $SUPPORTED_BRANCH_NAMES; do
  25. echo -e "\n- $branch"
  26. $DOCKER build . --no-cache -t $IMAGE_NAME:$branch
  27. done
  28. echo -e "\nBuilding tags:"
  29. for pattern in $SUPPORTED_TAG_PATTERNS; do
  30. for tag in $(git tag | grep $pattern); do
  31. echo -e "\n- $tag"
  32. maintag=$tag
  33. minortag=$(echo $tag | sed 's/^\(v[0-9]*\.[0-9]*\)\..*$/\1/')
  34. majortag=$(echo $tag | sed 's/^\(v[0-9]*\)\..*$/\1/')
  35. $DOCKER build . --no-cache -t $IMAGE_NAME:$tag -t $IMAGE_NAME:$minortag -t threema/threema
  36. done
  37. done
  38. echo -e "\nPushing image with all tags"
  39. $DOCKER push $IMAGE_NAME