Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Commit

Permalink
Merge branch 'development' of github.com:CityOfZion/neo-python into d…
Browse files Browse the repository at this point in the history
…evelopment
  • Loading branch information
localhuman committed Feb 24, 2018
2 parents 0850f71 + 9230e24 commit 8dd0d9e
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 16 deletions.
11 changes: 0 additions & 11 deletions Dockerfile

This file was deleted.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ yum install -y readline-devel leveldb-devel libffi-devel gcc-c++ redhat-rpm-conf
Help needed. Installing the Python package plyvel seems to require C++ compiler
support tied to Visual Studio and libraries. Refer to [documentation](https://neo-python.readthedocs.io/en/latest/installwindows.html).

Currently you probably should use the Linux subsystem with Ubuntu, or a Virtual Machine with Linux. You can find more information
and a guide for setting up the Linux subsystem [here](https://medium.com/@gubanotorious/installing-and-running-neo-python-on-windows-10-284fb518b213).

### Python 3.5

neo-python is currently only compatible with **Python 3.5** (due to its `byteplay3` dependency).
Expand Down
15 changes: 12 additions & 3 deletions bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@ def main():
help="use MainNet instead of the default TestNet")
parser.add_argument("-c", "--config", action="store", help="Use a specific config file")

parser.add_argument("-n", "--notifications", action="store_true", default=False, help="Bootstrap notification dataase")
parser.add_argument("-n", "--notifications", action="store_true", default=False,
help="Bootstrap notification database")

parser.add_argument("-s", "--skipconfirm", action="store_true", default=False,
help="Bypass warning about overwritting data in {}".format(settings.LEVELDB_PATH))

args = parser.parse_args()

if args.mainnet and args.config:
print("Cannot use both --config and --mainnet parameters, please use only one.")
exit(1)

if args.skipconfirm:
require_confirm = False
else:
require_confirm = True

# Setup depending on command line arguments. By default, the testnet settings are already loaded.
if args.config:
Expand All @@ -24,9 +33,9 @@ def main():
settings.setup_mainnet()

if args.notifications:
BootstrapBlockchainFile(settings.NOTIFICATION_DB_PATH, settings.NOTIF_BOOTSTRAP_FILE)
BootstrapBlockchainFile(settings.NOTIFICATION_DB_PATH, settings.NOTIF_BOOTSTRAP_FILE, require_confirm)
else:
BootstrapBlockchainFile(settings.LEVELDB_PATH, settings.BOOTSTRAP_FILE)
BootstrapBlockchainFile(settings.LEVELDB_PATH, settings.BOOTSTRAP_FILE, require_confirm)


if __name__ == "__main__":
Expand Down
42 changes: 42 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Dockerfile to setup neo-python on the master branch.
# https://github.com/CityOfZion/neo-python/tree/master/docker
#
# Building (these commands create a Docker image called neopython):
#
# $ docker build -f Dockerfile -t neopython .
#
# Build without caching:
#
# $ docker build --no-cache -f Dockerfile -t neopython .
#
# At this point there is a Docker image called 'neopython'. If you want to run it connecting
# to a private network, make sure the privatenet container is already running.
# https://hub.docker.com/r/cityofzion/neo-privatenet
#
# Start a container interactively, opening a bash in `/neo-python`, and mounting the current directory as `/neo-python/sc`:
#
# $ docker run --rm -it -v $(pwd):/neo-python/sc --net=host -h neopython --name neopython neopython /bin/bash
#
# Once you are inside the container, you can start neo-python with `python3 prompt.py -p` (using -p to connect to a private net).
# To update neo-python, just run `git pull` and `pip install -e .`
FROM ubuntu:16.04

# Install dependencies
RUN apt-get update && apt-get install -y \
wget \
git-core \
python3-dev \
python3-pip \
libleveldb-dev \
libssl-dev \
man

# APT cleanup to reduce image size
RUN rm -rf /var/lib/apt/lists/*

# Clone and setup
RUN git clone https://github.com/CityOfZion/neo-python.git
WORKDIR neo-python
RUN pip3 install -e .

CMD python3 prompt.py
46 changes: 46 additions & 0 deletions docker/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Dockerfile to setup neo-python on the development branch.
# https://github.com/CityOfZion/neo-python/tree/master/docker
#
# Building (these commands create a Docker image called neopython-dev):
#
# $ docker build -f Dockerfile.dev -t neopython-dev .
#
# Build without caching:
#
# $ docker build --no-cache -f Dockerfile.dev -t neopython-dev .
#
# At this point there is a Docker image called 'neopython-dev'. If you want to run it connecting
# to a private network, make sure the privatenet container is already running.
# https://hub.docker.com/r/cityofzion/neo-privatenet
#
# Start a container interactively, opening a bash in `/neo-python`, and mounting the current directory as `/neo-python/sc`:
#
# $ docker run --rm -it -v $(pwd):/neo-python/sc --net=host -h neopython-dev --name neopython-dev neopython-dev /bin/bash
#
# Once you are inside the container, you can start neo-python with `python3 prompt.py -p` (using -p to connect to a private net).
# To update neo-python, just run `git pull` and `pip install -e .`
#
FROM ubuntu:16.04

# Install dependencies
RUN apt-get update && apt-get install -y \
wget \
git-core \
python3-dev \
python3-pip \
libleveldb-dev \
libssl-dev \
man

# APT cleanup to reduce image size
RUN rm -rf /var/lib/apt/lists/*

# Clone and setup
RUN git clone https://github.com/CityOfZion/neo-python.git
WORKDIR neo-python

RUN git checkout origin/development -b development
RUN git branch -u origin/development
RUN pip3 install -e .

CMD python3 prompt.py
50 changes: 50 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
This directory contains various Docker related utilities.

* `Dockerfile.master` -- a Dockerfile to build neo-python's master branch
* `Dockerfile.dev` -- a Dockerfile to build neo-python's development branch
* `docker-compose-neoscan.yml` -- a Docker compose file to start a private network and a neoscan container

---

## Simple Docker container for neo-python master and dev branches

Take a look at the Dockerfiles, they have some documentation and example usage inside.

Let's use the development branch Dockerfile as example. To build it, use this command:

$ docker build -f Dockerfile.dev -t neopython-dev .

Build without caching:

$ docker build --no-cache -f Dockerfile.dev -t neopython-dev .

At this point there is a Docker image called 'neopython-dev'. If you want to run it connecting
to a private network, make sure the privatenet container is already running.
https://hub.docker.com/r/cityofzion/neo-privatenet

Start a container interactively, opening a bash in `/neo-python`, and mounting the current directory as `/neo-python/sc`:

$ docker run --rm -it -v $(pwd):/neo-python/sc --net=host -h neopython-dev --name neopython-dev neopython-dev /bin/bash

Once you are inside the container, you can start neo-python with `python3 prompt.py -p` (using -p to connect to a private net).
To update neo-python, just run `git pull` and `pip install -e .`


## NeoScan and the private network

`docker-compose-neoscan.yml` sets you up with 2 Docker containers: one for the private network and one for neoscan connected to it.
The base project and neoscan Dockerfile is currently maintained here: https://github.com/slipo/neo-scan-docker

You can start the privatenet+neoscan combo with this command:

$ docker-compose -f docker-compose-neoscan.yml up

It will take some time to set up.

While you wait, add this line to your hosts file:

127.0.0.1 neo-privnet

That allows you to connect to the privnet NEO nodes with the URLs returned by the neo-scan container. If you're using neo-python to connect to the privnet, you can use the standard configuration. 127.0.0.1:30333 will continue to work, for example.

OK, if you waited a few minutes, it should be ready. Check: http://localhost:4000/. You should see neo-scan with some blocks.
39 changes: 39 additions & 0 deletions docker/docker-compose-neoscan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: "3"
services:
neo-scan:
image: slipoh/neo-scan
container_name: "neo-scan"
ports:
- 4000:4000
links:
- postgresql:postgres
- neo-privnet:20333
- neo-privnet:20334
- neo-privnet:20335
- neo-privnet:20336
- neo-privnet:30333
- neo-privnet:30334
- neo-privnet:30335
- neo-privnet:30336
depends_on:
- postgresql
- neo-privnet
postgresql:
image: postgres:10.1
ports:
- 5432:5432
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
neo-privnet:
image: cityofzion/neo-privatenet
container_name: "neo-privnet"
ports:
- 20333:20333
- 20334:20334
- 20335:20335
- 20336:20336
- 30333:30333
- 30334:30334
- 30335:30335
- 30336:30336
1 change: 1 addition & 0 deletions docs/source/installwindows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Installation (Windows)
----------------------

The instructions are written for Windows 7 x64 with MSYS2 environment and Visual Studio 2017. It should probably work for other Windows distributions.
Another option is to setup a Linux Subsystem with Ubuntu (see also [here](https://medium.com/@gubanotorious/installing-and-running-neo-python-on-windows-10-284fb518b213) for more infos and a guide).


Building LevelDB
Expand Down
3 changes: 1 addition & 2 deletions neo/Prompt/Commands/Bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ def BootstrapBlockchainFile(target_dir, download_file, require_confirm=True):
print("no bootstrap file specified. Please update your configuration file.")
sys.exit(0)

print("This will overwrite any data currently in %s.\nType 'confirm' to continue" % target_dir)

if require_confirm:
print("This will overwrite any data currently in %s.\nType 'confirm' to continue" % target_dir)
confirm = prompt("[confirm]> ", is_password=False)
if confirm == 'confirm':
return do_bootstrap(download_file, target_dir)
Expand Down

0 comments on commit 8dd0d9e

Please sign in to comment.