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

Commit

Permalink
Merge pull request #252 from CityOfZion/docker-up
Browse files Browse the repository at this point in the history
Improved Docker setup and documentation
  • Loading branch information
localhuman committed Feb 24, 2018
2 parents 6938c69 + 2485125 commit 9230e24
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 11 deletions.
11 changes: 0 additions & 11 deletions Dockerfile

This file was deleted.

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

0 comments on commit 9230e24

Please sign in to comment.