provision.bash 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/usr/bin/env bash
  2. # Copyright Materialize, Inc. and contributors. All rights reserved.
  3. #
  4. # Use of this software is governed by the Business Source License
  5. # included in the LICENSE file at the root of this repository.
  6. #
  7. # As of the Change Date specified in that file, in accordance with
  8. # the Business Source License, use of this software will be governed
  9. # by the Apache License, Version 2.0.
  10. # Install necessary prerequisites for a remote EC2 host to run Materialize
  11. # demos, load tests, etc.
  12. set -euo pipefail
  13. arch=$(uname -m)
  14. arch=$(echo "$arch" | sed -e "s/aarch64/arm64/" -e "s/x86_64/amd64/" )
  15. # Install APT dependencies.
  16. apt-get update
  17. apt-get install -y \
  18. build-essential \
  19. cmake \
  20. g++ \
  21. libclang-dev \
  22. lld \
  23. postgresql-client \
  24. python3-dev \
  25. python3-venv \
  26. unzip
  27. # Update ec2-instance-connect scripts to a version that works with OpenSSL 3.
  28. # https://github.com/aws/aws-ec2-instance-connect-config/issues/38
  29. curl -L "https://github.com/aws/aws-ec2-instance-connect-config/archive/refs/tags/1.1.17.zip" > ec2-instance-connect.zip
  30. unzip ec2-instance-connect.zip
  31. cp aws-ec2-instance-connect-config-1.1.17/src/bin/* /usr/share/ec2-instance-connect/
  32. rm -r ec2-instance-connect.zip aws-ec2-instance-connect-config-1.1.17
  33. # Install docker as per the instructions from https://docs.docker.com/engine/install/ubuntu/
  34. sudo apt-get install -y \
  35. ca-certificates \
  36. curl \
  37. gnupg \
  38. lsb-release
  39. sudo mkdir -p /etc/apt/keyrings
  40. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
  41. echo \
  42. "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  43. $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  44. sudo apt-get update
  45. sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
  46. # Install Rust.
  47. sudo -u ubuntu sh -c "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y"
  48. # Install Bazel.
  49. sudo sh -c "curl -fsSL -o /usr/local/bin/bazel https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-$arch" \
  50. && if [[ "$arch" = arm64 ]]; then echo '467ec3821aca5e278c8570b7c25e0dfc1a061d2873be89e4a266aaf488148426 /usr/local/bin/bazel' | sha256sum --check; fi \
  51. && if [[ "$arch" = amd64 ]]; then echo 'd9af1fa808c0529753c3befda75123236a711d971d3485a390507122148773a3 /usr/local/bin/bazel' | sha256sum --check; fi \
  52. && sudo sh -c "chmod +x /usr/local/bin/bazel"
  53. # Install the AWS CLI.
  54. curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" > awscliv2.zip
  55. unzip awscliv2.zip
  56. aws/install
  57. rm -r aws awscliv2.zip
  58. # Allow the Ubuntu user to access the Docker daemon.
  59. sudo usermod -aG docker ubuntu
  60. sudo systemctl enable containerd.service --now
  61. sudo systemctl enable docker.service --now
  62. # Install tools for Kubernetes testing and debugging
  63. ## kubectl
  64. sudo sh -c 'curl -L "https://dl.k8s.io/release/v1.24.3/bin/linux/amd64/kubectl" > /usr/local/bin/kubectl'
  65. sudo chmod +x /usr/local/bin/kubectl
  66. ## kind
  67. sudo sh -c 'curl -L "https://kind.sigs.k8s.io/dl/v0.29.0/kind-linux-amd64" > /usr/local/bin/kind'
  68. sudo chmod +x /usr/local/bin/kind
  69. ## k9s
  70. curl -L 'https://github.com/derailed/k9s/releases/download/v0.26.3/k9s_Linux_x86_64.tar.gz' \
  71. | tar xzf - k9s
  72. chmod +x k9s
  73. sudo mv k9s /usr/local/bin
  74. # Report that provisioning has completed.
  75. mkdir /opt/provision
  76. touch /opt/provision/done