release_dockerhub.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/env bash
  2. # This script builds the official docker images and pushes them to dockerhub
  3. # after checking with the user.
  4. # NOTE: To clear the buildx cache, run the following command:
  5. # docker buildx prune --all or more specifically docker buildx rm <context_name>
  6. # bash strict mode
  7. set -euo pipefail
  8. # Check if exactly one argument is supplied
  9. if [ "$#" -ne 2 ]; then
  10. echo "Usage: $0 <user> <version>" >&2
  11. exit 1
  12. fi
  13. USER=${1}
  14. VERSION_STR=${2}
  15. if [[ -z "$USER" ]]; then
  16. echo "User name cannot be empty" >&2
  17. exit 3
  18. fi
  19. if [[ "$USER" != "sweagent" ]]; then
  20. echo "Careful here! Even if the username isn't sweagent, swe-eval will still be built on top of the sweagent/swe-agent image." >&2
  21. read -p "Do you want to proceed? (yes) " response
  22. if [[ "${response}" != "yes" ]]; then
  23. echo "Exiting..." >&2
  24. exit 4
  25. fi
  26. fi
  27. # The argument should be in the form of x.x.x where each x can be one or more digits
  28. if [[ $VERSION_STR =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || [ "$VERSION_STR" = "latest" ]; then
  29. echo "Validated version number"
  30. else
  31. echo "Argument must be 'latest' or in the form x.x.x, where x is one or more numbers." >&2
  32. exit 2
  33. fi
  34. DOCKER_CONTEXT_NAME="sweagent-multiplatform"
  35. docker buildx use "$DOCKER_CONTEXT_NAME" || docker buildx create --use --name "$DOCKER_CONTEXT_NAME"
  36. on_error() {
  37. echo "====> ERROR!!! IMPORTANT: Make sure that you've already pushed something to dockerhub or pushed the tag to github!" >&2
  38. }
  39. trap on_error ERR
  40. echo "------------------------------------------"
  41. echo "Building swe-agent"
  42. echo "------------------------------------------"
  43. docker buildx build --platform=linux/amd64,linux/arm64 -t ${USER}/swe-agent:${VERSION_STR} -f docker/swe.Dockerfile --push .
  44. echo "🔥 swe-agent pushed to dockerhub"
  45. echo "------------------------------------------"
  46. echo "Building swe-agent-run"
  47. echo "------------------------------------------"
  48. docker buildx build --platform=linux/amd64,linux/arm64 -t ${USER}/swe-agent-run:${VERSION_STR} --push .
  49. echo "🔥 swe-agent-run pushed to dockerhub"
  50. echo "------------------------------------------"
  51. echo "Building of all images done"
  52. echo "------------------------------------------"