Skip to content

Instantly share code, notes, and snippets.

@8teAPi
Last active August 29, 2022 05:16
Show Gist options
  • Save 8teAPi/8b7e21f02e1ee4256766fd30a4241b9c to your computer and use it in GitHub Desktop.
Save 8teAPi/8b7e21f02e1ee4256766fd30a4241b9c to your computer and use it in GitHub Desktop.
Debian EC2 setup for a working solana, anchor development environment
#!/bin/bash
# This script is used to setup the EC2 instance for the project.
# It is run by the EC2 instance after it is created.
# Minimum requirements:
# - Debian 10 - t2.small (2 vCPUs, 2 GB RAM)
wget https://static.rust-lang.org/rustup/archive/1.24.3/x86_64-unknown-linux-gnu/rustup-init
chmod +x rustup-init
./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.56.1-x86_64-unknown-linux-gnu --default-host x86_64-unknown-linux-gnu
rm rustup-init
echo 'export PATH=/home/admin/.cargo/bin:$PATH' >>~/.profile
source ~/.profile
# smoke test
cargo --version
source $HOME/.cargo/env
rustup component add rustfmt
# base intall
sudo apt-get update
sudo apt install -y build-essential
sudo apt-get install -y libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang make
sudo apt install -y git
# solana install
wget https://github.com/solana-labs/solana/releases/download/v1.8.5/solana-release-x86_64-unknown-linux-gnu.tar.bz2
tar jxf solana-release-x86_64-unknown-linux-gnu.tar.bz2
rm solana-release-x86_64-unknown-linux-gnu.tar.bz2
echo 'export PATH=/home/admin/solana-release/bin:$PATH' >>~/.profile
source ~/.profile
# smoke test
solana --version
# solana-test-validator
# nodejs install
# https://github.com/nodesource/distributions
# Add the NodeSource package signing key
KEYRING=/usr/share/keyrings/nodesource.gpg
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | sudo tee "$KEYRING" >/dev/null
# wget can also be used:
# wget --quiet -O - https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | sudo tee "$KEYRING" >/dev/null
gpg --no-default-keyring --keyring "$KEYRING" --list-keys
# Replace with the branch of Node.js or io.js you want to install: node_6.x, node_8.x, etc...
NODE_VERSION=node_16.x
# Replace with the keyring above, if different
KEYRING=/usr/share/keyrings/nodesource.gpg
# The below command will set this correctly, but if lsb_release isn't available, you can set it manually:
# - For Debian distributions: jessie, sid, etc...
# - For Ubuntu distributions: xenial, bionic, etc...
# - For Debian or Ubuntu derived distributions your best option is to use the codename corresponding to the upstream release your distribution is based off. This is an advanced scenario and unsupported if your distribution is not listed as supported per earlier in this README.
DISTRO="$(lsb_release -s -c)"
echo "deb [signed-by=$KEYRING] https://deb.nodesource.com/$NODE_VERSION $DISTRO main" | sudo tee /etc/apt/sources.list.d/nodesource.list
echo "deb-src [signed-by=$KEYRING] https://deb.nodesource.com/$NODE_VERSION $DISTRO main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list
sudo apt-get update
sudo apt-get install nodejs
sudo npm install -g yarn
# Anchor
sudo npm i -g @project-serum/anchor-cli
# anchor init hello
# cd hello/programs/hello
# anchor build
# keygen
# solana-keygen new -o /home/admin/.config/solana/id.json
# anchor deploy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment