Building your private NEO network on AWS (part 2)

Written by dominicfung_58781 | Published 2018/08/08
Tech Story Tags: docker | smart-contracts | aws | linux | blockchain

TLDRvia the TL;DR App

Last week, we created an AWS account, deployed an EC2 Linux instance and learned how to SSH into that server. With the help of Docker, we’ll deploy a private NEO network within the linux AMI we’ve just created!

So what is Docker? Docker is containerization technology — it helps us run an “image” or package, where we don’t have to worry about the NEO nodes, network, dependencies and any pre-configurations. It is all written out for us as a docker image, all we need to do is download and run it!

Lets, though, take a moment to understand our particular Docker image. It contains 4 NEO consensus nodes, the minimum required to bring up a working NEO network, communicating internally via ports 30333-30336 TCP. We will then expose the testNet communication ports (20331–20334) to the outside world by manipulating our AWS security group.

Check out the Citizen of Zion, an open-source community in partnership with NEO. This is their Docker image source code, for those of you who want to check it out!

After entering your Amazon Linux instance via secure shell, we will install Docker …

Step 1: Install Docker

sudo yum update -ysudo yum install -y dockersudo service docker startsudo usermod -a -G docker ec2-user

Step 2: Check and deploy our Docker NEO network image

docker info #just a checkdocker pull cityofzion/neo-privatenet

docker run --rm -d --name neo-privatenet --expose=20331-20334 --expose=30333-30336 -p 20333-20336:20333-20336/tcp -p 30333-30336:30333-30336/tcp cityofzion/neo-privatenet

Check that your image is running! docker ps

Step 3: Adding port 30331–30334 to your security group

Log onto the AWS console, Services > EC2. Under NETWORK & SECURITY, click Security Groups. Click Edit on the security group assigned to your instance. Create the following inbound rules:

*These rules apply immediately!

Step 4: Connect from your neo-prompt!

Open command prompt on local:

ubuntusudo -i

cd <location of neo-python>source venv/bin/activate

Remember how we made note of the public IP in the last article? Let’s use that here:

np-prompt -p <server IP>

Great! we are done!

Bonus command: Restarting the NEO block-chain.

From our experience, due to server memory constraints, your image will need to be whipped and restarted weekly. The command to do so is as follows:

docker stop neo-privatenet

Then use the following on your own np-prompt (Ubuntu):

rm -rf /root/.neopython/Chains/

As usual, I’ll give my project a shout out: Nodis.io is a marketing platform for local business, generating engagement through small activities and rewarding users with cryptocurrency they can later spend on these stores. Check us out and give us your feedback on Instagram and Facebook!

Next week’s guide: Deploying a NEP-5 smart contract (part 1)


Published by HackerNoon on 2018/08/08