dockerhub_deploy.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. for ((i = 0; i < 3; i++)); do
  3. echo "Trying to log in to Docker Hub"
  4. echo $DOCKER_PASSWORD|docker login -u$DOCKER_USER --password-stdin docker.io && break
  5. FAILED_TO_LOGIN=true
  6. done
  7. if [[ "$FAILED_TO_LOGIN" == 'true' ]]; then
  8. echo "Can't log in to Docker Hub"
  9. exit 1
  10. fi
  11. if [ ! -n "$BUILD_TAGS" ]; then
  12. VERSION=$( cat src/sphinxversion.h.in | grep VERNUMBERS | cut -d" " -f3 | cut -d'"' -f2 )
  13. BUILD_TAGS="dev dev-${VERSION} dev-${VERSION}-$CI_COMMIT_SHORT_SHA"
  14. fi
  15. IFS=' ' read -r -a SPLITTED_BUILD_TAGS <<<"$BUILD_TAGS"
  16. git clone https://github.com/manticoresoftware/docker.git docker
  17. cd docker
  18. BUILD_FAILED=false
  19. if [[ ! $(docker ps | grep manticore_build) ]]; then
  20. echo "Buildx builder not found. Registering."
  21. docker buildx create --name manticore_build --platform linux/amd64,linux/arm64
  22. docker buildx use manticore_build
  23. # docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
  24. fi
  25. BUILD_ARGS=""
  26. for BUILD_TAG in "${SPLITTED_BUILD_TAGS[@]}"; do
  27. BUILD_ARGS="$BUILD_ARGS --tag manticoresearch/manticore:$BUILD_TAG"
  28. done
  29. for ((i = 0; i < 3; i++)); do
  30. echo "Started building manticoresearch/manticore"
  31. docker buildx build \
  32. --progress=plain \
  33. --build-arg DEV=1 \
  34. --push \
  35. --platform linux/arm64,linux/amd64 \
  36. $BUILD_ARGS \
  37. . && break
  38. if [ $i == 2 ]; then
  39. echo "Docker build failed"
  40. BUILD_FAILED=true
  41. fi
  42. done
  43. echo "Done"
  44. cd ..
  45. rm -rf docker
  46. if [ "$BUILD_FAILED" = true ] ; then
  47. exit 1
  48. fi