1
0

buildAndPush.sh 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env bash
  2. # Assume we're in wolfssl/Docker
  3. WOLFSSL_DIR=$(builtin cd ${BASH_SOURCE%/*}/..; pwd)
  4. DOCKER_BUILD_OPTIONS="$1"
  5. if [ "${DOCKER_BASE_IMAGE}" != "" ]; then
  6. DOCKER_BUILD_OPTIONS+=" --build-arg DOCKER_BASE_IMAGE=${DOCKER_BASE_IMAGE}"
  7. fi
  8. NUM_FAILURES=0
  9. CUR_DATE=$(date -u +%F)
  10. echo "Building wolfssl/wolfssl-builder:${CUR_DATE} as ${DOCKER_BUILD_OPTIONS}"
  11. docker build -t wolfssl/wolfssl-builder:${CUR_DATE} ${DOCKER_BUILD_OPTIONS} "${WOLFSSL_DIR}/Docker" && \
  12. docker tag wolfssl/wolfssl-builder:${CUR_DATE} wolfssl/wolfssl-builder:latest && \
  13. docker build --build-arg DOCKER_BASE_IMAGE=wolfssl/wolfssl-builder:${CUR_DATE} -t wolfssl/testing-cross-compiler:${CUR_DATE} "${WOLFSSL_DIR}/Docker" -f Dockerfile.cross-compiler && \
  14. docker tag wolfssl/testing-cross-compiler:${CUR_DATE} wolfssl/testing-cross-compiler:latest
  15. if [ $? -eq 0 ]; then
  16. echo "Push containers to DockerHub [y/N]? "
  17. read val
  18. if [ "$val" = "y" ]; then
  19. docker push wolfssl/wolfssl-builder:${CUR_DATE} && docker push wolfssl/wolfssl-builder:latest && \
  20. docker push wolfssl/testing-cross-compiler:${CUR_DATE} && docker push wolfssl/testing-cross-compiler:latest
  21. if [ $? -ne 0 ]; then
  22. echo "Warning: push failed. Continuing"
  23. ((NUM_FAILURES++))
  24. fi
  25. fi
  26. else
  27. echo "Warning: Build wolfssl/wolfssl-builder failed. Continuing"
  28. ((NUM_FAILURES++))
  29. fi
  30. echo "Building wolfssl/wolfCLU:${CUR_DATE}"
  31. DOCKER_ARGS="--pull --build-arg DUMMY=${CUR_DATE} --platform=linux/amd64,linux/arm64,linux/arm/v7 ${WOLFSSL_DIR}/Docker/wolfCLU"
  32. docker buildx build -t wolfssl/wolfclu:${CUR_DATE} ${DOCKER_ARGS} && \
  33. docker buildx build -t wolfssl/wolfclu:latest ${DOCKER_ARGS}
  34. if [ $? -eq 0 ]; then
  35. echo "Push containers to DockerHub [y/N]? "
  36. read val
  37. if [ "$val" = "y" ]; then
  38. docker buildx build ${DOCKER_ARGS} --push -t wolfssl/wolfclu:${CUR_DATE} && \
  39. docker buildx build ${DOCKER_ARGS} --push -t wolfssl/wolfclu:latest
  40. if [ $? -ne 0 ]; then
  41. echo "Warning: push failed. Continuing"
  42. ((NUM_FAILURES++))
  43. fi
  44. fi
  45. else
  46. echo "Warning: Build wolfssl/wolfclu failed. Continuing"
  47. ((NUM_FAILURES++))
  48. fi
  49. echo "Script completed in $SECONDS seconds. Had $NUM_FAILURES failures."