Skip to content

Instantly share code, notes, and snippets.

@slipo
Created January 30, 2018 23:00
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save slipo/f18f1a0b5e6adb7b0bf172b93379d891 to your computer and use it in GitHub Desktop.
Save slipo/f18f1a0b5e6adb7b0bf172b93379d891 to your computer and use it in GitHub Desktop.
Super simple docker compose file giving you a private NEO network and neon-wallet-db ... see comments.
version: '3'
services:
neon-wallet-db:
container_name: "neon-wallet-db"
image: slipoh/neon-wallet-db:latest
environment:
- MONGOURL=mongodb:27017
- MONGOPASS=neo
- MONGOUSER=gas
- MONGOAPP=test
- REDISTOGO_URL=redis://redis:6379
- PYTHONUNBUFFERED=0
- NET=private
- PRIVNET_SEEDS=http://neo-privnet:30333,http://neo-privnet:30334,http://neo-privnet:30335,http://neo-privnet:30336
ports:
- 5000:5000
links:
- mongodb:27017
- redis:6379
- 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:
- mongodb
- redis
- neo-privnet
neo-privnet:
image: metachris/neo-privnet-with-gas
container_name: "neo-privnet"
ports:
- 20333:20333
- 20334:20334
- 20335:20335
- 20336:20336
- 30333:30333
- 30334:30334
- 30335:30335
- 30336:30336
redis:
image: redis:latest
container_name: "redis"
ports:
- 6379:6379
mongodb:
image: mongo:latest
container_name: "mongodb"
environment:
- MONGO_DATA_DIR=/data/db
- MONGO_LOG_DIR=/dev/null
volumes:
- ./data/db:/data/db
ports:
- 27017:27017
command: mongod --smallfiles --logpath=/dev/null # --quiet
@slipo
Copy link
Author

slipo commented Jan 30, 2018

Make a workspace:

mkdir local-neo
cd local-neo

Download raw version of this gist into a file named docker-compose.yml in that directory.

Boot it up:

docker-compose up

Note: this creates a mongodb directory in data/ ... when reinitializing the whole thing, you might need to delete that.

Give it a minute to detect the nodes and start indexing. While you wait, add the following to your hosts file:

127.0.0.1 neo-privnet

Test everything's working

curl http://127.0.0.1:5000/v2/network/nodes

You should see 4 nodes with block_height numbers. Wait a couple more minutes if needed.

@slipo
Copy link
Author

slipo commented Feb 1, 2018

If you're already running a neo-privnet, you'll need to bring it down to replace it with this.

@StefanKern
Copy link

I'm getting the following error when I want to start it:

C:\....\local-neo>docker-compose up
Starting neo-privnet ...
Starting mongodb ...
Starting redis ... done
Starting neon-wallet-db ... done
Attaching to neo-privnet, mongodb, redis, neon-wallet-db
redis             | 1:C 12 Feb 22:23:49.578 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis             | 1:C 12 Feb 22:23:49.579 # Redis version=4.0.8, bits=64, commit=00000000, modified=0, pid=1, just started
redis             | 1:C 12 Feb 22:23:49.579 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
neon-wallet-db    | export GPG_KEY='97FC712E4C024BBEA48A61ED3A5CA953F73C700D'
redis             | 1:M 12 Feb 22:23:49.581 * Running mode=standalone, port=6379.
neon-wallet-db    | export HOME='/root'
redis             | 1:M 12 Feb 22:23:49.582 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
neon-wallet-db    | export HOSTNAME='855eefb18812'
neon-wallet-db    | export LANG='C.UTF-8'
redis             | 1:M 12 Feb 22:23:49.582 # Server initialized
neon-wallet-db    | export MONGOAPP='test'
redis             | 1:M 12 Feb 22:23:49.583 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
neon-wallet-db    | export MONGOPASS='neo'
neon-wallet-db    | export MONGOURL='mongodb:27017'
redis             | 1:M 12 Feb 22:23:49.583 * DB loaded from disk: 0.000 seconds
neon-wallet-db    | export MONGOUSER='gas'
redis             | 1:M 12 Feb 22:23:49.583 * Ready to accept connections
neon-wallet-db    | export NET='private'
neon-wallet-db    | export PATH='/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
neon-wallet-db    | export PRIVNET_SEEDS='http://neo-privnet:30333,http://neo-privnet:30334,http://neo-privnet:30335,http://neo-privnet:30336'
neon-wallet-db    | export PWD='/opt/neon-wallet-db'
neon-wallet-db    | export PYTHONUNBUFFERED='0'
neon-wallet-db    | export PYTHON_PIP_VERSION='9.0.1'
neon-wallet-db    | export PYTHON_VERSION='3.5.4'
neon-wallet-db    | export REDISTOGO_URL='redis://redis:6379'
mongodb exited with code 100
neon-wallet-db    | /usr/local/lib/python3.5/site-packages/flask_cache/jinja2ext.py:33: ExtDeprecationWarning: Importing flask.ext.cache is deprecated, use flask_cache instead.
neon-wallet-db    |   from flask.ext.cache import make_template_fragment_key
neon-wallet-db    | http://neo-privnet:30333
neon-wallet-db    | http://neo-privnet:30334
neon-wallet-db    | {'time': 1.6811773777008057, 'url': 'http://neo-privnet:30334', 'block_height': 1071, 'status': True}
neon-wallet-db    | http://neo-privnet:30335
neon-wallet-db    | {'time': 1.2399823665618896, 'url': 'http://neo-privnet:30335', 'block_height': 1071, 'status': True}
neon-wallet-db    | http://neo-privnet:30336
neon-wallet-db    | {'time': 0.30244946479797363, 'url': 'http://neo-privnet:30336', 'block_height': 1071, 'status': True}
neon-wallet-db    | Traceback (most recent call last):
neon-wallet-db    |   File "init.py", line 4, in <module>
neon-wallet-db    |     blockchain.checkSeeds()
neon-wallet-db    |   File "/opt/neon-wallet-db/api/blockchain.py", line 50, in checkSeeds
neon-wallet-db    |     blockchain_db['meta'].update_one({"name": "node_status"}, {"$set": {"nodes": seeds}}, upsert=True)
neon-wallet-db    |   File "/usr/local/lib/python3.5/site-packages/pymongo/collection.py", line 890, in update_one
neon-wallet-db    |     with self._socket_for_writes() as sock_info:
neon-wallet-db    |   File "/usr/local/lib/python3.5/contextlib.py", line 59, in __enter__
neon-wallet-db    |     return next(self.gen)
neon-wallet-db    |   File "/usr/local/lib/python3.5/site-packages/pymongo/mongo_client.py", line 823, in _get_socket
neon-wallet-db    |     server = self._get_topology().select_server(selector)
neon-wallet-db    |   File "/usr/local/lib/python3.5/site-packages/pymongo/topology.py", line 214, in select_server
neon-wallet-db    |     address))
neon-wallet-db    |   File "/usr/local/lib/python3.5/site-packages/pymongo/topology.py", line 189, in select_servers
neon-wallet-db    |     self._error_message(selector))
neon-wallet-db    | pymongo.errors.ServerSelectionTimeoutError: mongodb:27017: [Errno -2] Name or service not known
neon-wallet-db exited with code 1

image

@StefanKern
Copy link

switching to "tutum/mongodb" fixed it for me. See https://gist.github.com/StefanKern/aad447bf13f1cffb1e486d404ada6e45

@slipo
Copy link
Author

slipo commented Feb 18, 2018

Just checked docker-compose pull and docker-compose up and everything's working fine for me. Asking @StefanKern to try the same.

@slipo
Copy link
Author

slipo commented Feb 18, 2018

@StefanKern is still having the issue. We believe it may affect Windows users. If you have the same issue, try out "tutum/mongodb" like in his gist above.

@vncoelho
Copy link

vncoelho commented Mar 4, 2018

It also seems to be a necessary step with Linux.

@slipo
Copy link
Author

slipo commented Mar 9, 2018

https://github.com/slipo/neo-scan-docker is another option if you want to run neoscan instead of neon-wallet-db ... They provide similar functionality but most dev is moving to neoscan.

@yurii-cnw
Copy link

Everythihg works fine, thanks. But, how to run neon-wallet-db or neoscan with non dockerized privatenet?

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