Skip to content

Instantly share code, notes, and snippets.

@sirneb
Last active May 25, 2019 23:26
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sirneb/8419e41aea4f2d5770555301006cea20 to your computer and use it in GitHub Desktop.
Save sirneb/8419e41aea4f2d5770555301006cea20 to your computer and use it in GitHub Desktop.
aws ec2 setup
// Tested this on ubuntu 16.x or debian 9 stretch
// ubuntu is the default user on AWS EC2 Ubuntu image (skip if you already ssh'ed in)
ssh ubuntu@<instance ip>
// install docker
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
// verify fingerprint, should be 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
sudo apt-key fingerprint 0EBFCD88
// ubuntu
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
// use the following instead in debian
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce
// add ubuntu user to the "docker" user group, this assumes "ubuntu" is the user, adjust as needed
sudo adduser ubuntu docker
// install docker compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
// create "docker-compose.yml" with the following
curl -O https://gist.githubusercontent.com/sirneb/3bebdbc3eadcfdfdcc41f625fe6ddac7/raw/3e18b89e99e9cd98d764a177868365d00b9d61d5/docker-compose.yml
// you should now have a "docker-compose.yml" file, with the following contents,
// this directory is where you want to run the following docker-compose commands.
```
version: "2"
services:
node:
image: tezos/tezos:mainnet
hostname: node
command: tezos-node
ports:
- "8732:8732"
- "9732:9732"
expose:
- '8732'
- '9732'
volumes:
- node_data:/var/run/tezos/node
- client_data:/var/run/tezos/client
restart: always
upgrader:
image: tezos/tezos:mainnet
hostname: node
command: tezos-upgrade-storage
volumes:
- node_data:/var/run/tezos/node
- client_data:/var/run/tezos/client
# Only needed if you want to import a snapshot, this will convert to a "full" node,
# also deleting node data volume is required
# **IMPORTANT** Change the snapshot path before use!!
importer:
image: tezos/tezos:mainnet
hostname: node
command: tezos-snapshot-import
volumes:
- node_data:/var/run/tezos/node
- client_data:/var/run/tezos/client
- <LOCAL_PATH_TO_SNAPSHOT_FILE>:/snapshot
# example:
# - /home/<USERNAME>/tmp/mainnet-BKs95uX1zPD7wa45TuuxDaPpbmuhXpV8TiX9y3F7HjiyCdLGBue.full:/snapshot
volumes:
node_data:
client_data:
```
// update to the newest image and start the node/client
docker-compose pull && docker-compose up -d
// DONE!
// Lastly, the way the docker compose file is set up, it forwards 8732 (tezos client) and
// 9732 (allows others to connect to your node) ports. What you may want to do is remove those lines
// in the docker compose if you don't want to allow others to connect to your node. Another option
// is use iptables(or AWS security policy if AWS) to block those ports on your server.
//
// ** THE FOLLOWING ARE JUST HELPFUL DOCKER COMMANDS **
//
// check if the container is running and get the name of the container
docker ps
// use this to monitor the node's logs
docker logs -f <USERNAME>_node_1
// turn off the container/node
docker-compose down
// "/var/lib/docker/volumes/" is where your node and client data lives on your server
// run a command on the docker
docker exec -it <USERNAME>_node_1 <COMMAND IN THE CONTAINER>
// examples:
docker exec -it <USERNAME>_node_1 sh // runs a prompt in the container
docker exec -it <USERNAME>_node_1 tezos-admin-client p2p stat
docker exec -it <USERNAME>_node_1 tezos-client rpc get /chains/main/blocks/head
// Remove node data
docker volume rm <USERNAME>_node_data
// Storage Upgrade, this will upgrade the storage version (Athens upgrade), this also requires the "upgrader" service
// in the docker_compose.yml
docker-compose pull && docker-compose up upgrader
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment