use-colima.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/bash
  2. if ! [[ -x ~/.local/share/sentry-devenv/bin/colima ]]; then
  3. echo "You need to install devenv! https://github.com/getsentry/devenv/#install"
  4. exit 1
  5. fi
  6. if [[ "$(sysctl -n machdep.cpu.brand_string)" != Intel* ]]; then
  7. case "$(sw_vers -productVersion)" in
  8. *12.*|*13.*)
  9. echo "Your ARM Mac is on a version incompatible with colima."
  10. echo "Use Docker Desktop for now until you upgrade to at least MacOS 14."
  11. exit 1
  12. ;;
  13. esac
  14. fi
  15. echo "Copying your postgres volume for use with colima. Will take a few minutes."
  16. tmpdir=$(mktemp -d)
  17. docker context use desktop-linux
  18. docker run --rm -v sentry_postgres:/from -v "${tmpdir}:/to" alpine ash -c "cd /from ; cp -a . /to" || { echo "You need to start Docker Desktop."; exit 1; }
  19. echo "Stopping Docker.app. If a 'process terminated unexpectedly' dialog appears, dismiss it."
  20. osascript - <<'EOF' || exit
  21. quit application "Docker"
  22. EOF
  23. # We aren't uninstalling for now - this makes rolling back to docker desktop faster.
  24. # Also, less breakage as people may be using things like docker-credential-desktop.
  25. # echo "Uninstalling docker cask (which includes Docker Desktop)."
  26. # brew uninstall --cask docker
  27. # We do want to get people on just the docker cli though, to enable uninstalling the cask.
  28. echo "Installing docker (cli only)."
  29. brew install docker
  30. # Unlinks docker (cask).
  31. brew unlink docker
  32. brew link --overwrite docker
  33. # This removes credsStore, saving it under oldCredsStore so it can be restored later.
  34. # The right value under colima for this is "colima", but I think vast majority of people
  35. # are authing their docker through gcloud, not docker cli.
  36. python3 <<'EOF'
  37. import os
  38. import json
  39. with open(os.path.expanduser("~/.docker/config.json"), "rb") as f:
  40. config = json.loads(f.read())
  41. credsStore = config.get("credsStore")
  42. if credsStore is None:
  43. exit(0)
  44. config["oldCredsStore"] = credsStore
  45. del config["credsStore"]
  46. with open(os.path.expanduser("~/.docker/config.json"), "w") as f:
  47. f.write(json.dumps(config))
  48. EOF
  49. echo "Starting colima."
  50. python3 -uS scripts/start-colima.py
  51. echo "Recreating your postgres volume for use with colima. May take a few minutes."
  52. docker volume create --name sentry_postgres
  53. docker run --rm -v "${tmpdir}:/from" -v sentry_postgres:/to alpine ash -c "cd /from ; cp -a . /to"
  54. rm -rf "$tmpdir"
  55. echo "-----------------------------------------------"
  56. echo "All done. Start devservices at your discretion."