Skip to content

Instantly share code, notes, and snippets.

@JorritvandenBerg
Last active February 24, 2018 19:47
Show Gist options
  • Save JorritvandenBerg/c173a36aa98266e02d1c300cee3308a7 to your computer and use it in GitHub Desktop.
Save JorritvandenBerg/c173a36aa98266e02d1c300cee3308a7 to your computer and use it in GitHub Desktop.
NEO private network with neo-python container
This gist explains how to create a NEO private network with neo-python in a Docker container. This allows us to manage the dependencies by Docker, keeping to host free from clutter.
1. We set up a project directory (for instance "neo")
2. Add the docker-compose.ym and Dockerfile to that directory
3. Create a wallets subdirectory
4. Add any wallets we want to import in neo-python to the wallets subdirectory
Now we have the project structure, let's get stuff up and running. From within the project dir, run "docker-compose build" and "docker-compose up -d" once the build is finished.
Okay, but how do I use neo-python?
5. Run "docker-compose ps"
6. Grab the full name of the neo_python container ("neo_neo_python_1") in this example
7. Run "docker attach <name_from_step_2>"
8. Now you should see the prompt screen. Wallets can be imported from /neo-python/wallets/<wallet_name>
If you want to dettach from the container without stopping it, type the escape sequence "ctrl p + ctrl q".
With an alias in bashrc, you can define a persistent alias to attach to the container:
echo "alias neopython='docker attach <name_from_step_2>'" >> ~/.bashrc
This allows you to go to the container with just "neopython" as if it is a plain program.
version: "3.3"
services:
private_net:
image: cityofzion/neo-privatenet
neo_python:
build: ./
links:
- private_net
stdin_open: true
tty: true
FROM ubuntu:16.04
RUN apt-get update && apt-get -y install git python3-dev python3-pip libleveldb-dev libssl-dev screen
RUN git clone https://github.com/CityOfZion/neo-python.git
WORKDIR /neo-python
RUN pip3 install -r requirements.txt
COPY ./wallets /neo-python/wallets
RUN sed -i 's/127.0.0.1/private_net/g' ./protocol.privnet.json
CMD rm -rf /neo-python/Chains/privnet; screen python3 prompt.py -p
@JorritvandenBerg
Copy link
Author

Updated gist to replace hostname in protocol.privnet.json with sed instead of swapping the file. More robust for changes in the neo-python repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment