From 7bc0a41ccd348f35cd91583e2d5f01c2462c2615 Mon Sep 17 00:00:00 2001 From: Konrad Feldmeier Date: Tue, 21 Apr 2015 15:43:16 +0200 Subject: [PATCH] Add Dockerfile --- Dockerfile | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 8 +++++-- 2 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..de3d39c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,61 @@ +## Dockerfile for eth-net-intelligence-api (build from git). +## +## Build via: +# +# `docker build -t ethnetintel:latest .` +# +## Run via: +# +# `docker run -v :/home/ethnetintel/eth-net-intelligence-api/app.json ethnetintel:latest` +# +## Make sure, to mount your configured 'app.json' into the container at +## '/home/ethnetintel/eth-net-intelligence-api/app.json', e.g. +## '-v /path/to/app.json:/home/ethnetintel/eth-net-intelligence-api/app.json' +## +## Note: if you actually want to monitor a client, you'll need to make sure it can be reached from this container. +## The best way in my opinion is to start this container with all client '-p' port settings and then +# share its network with the client. This way you can redeploy the client at will and just leave 'ethnetintel' running. E.g. with +## the python client 'pyethapp': +## +# +# `docker run -d --name ethnetintel \ +# -v /home/user/app.json:/home/ethnetintel/eth-net-intelligence-api/app.json \ +# -p 0.0.0.0:30303:30303 \ +# -p 0.0.0.0:30303:30303/udp \ +# ethnetintel:latest` +# +# `docker run -d --name pyethapp \ +# --net=container:ethnetintel \ +# -v /path/to/data:/data \ +# pyethapp:latest` +# +## If you now want to deploy a new client version, just redo the second step. + + +FROM debian + +RUN apt-get update &&\ + apt-get install -y curl git-core &&\ + curl -sL https://deb.nodesource.com/setup | bash - &&\ + apt-get update &&\ + apt-get install -y nodejs + +RUN apt-get update &&\ + apt-get install -y build-essential + +RUN adduser ethnetintel + +RUN cd /home/ethnetintel &&\ + git clone https://github.com/cubedro/eth-net-intelligence-api &&\ + cd eth-net-intelligence-api &&\ + npm install &&\ + npm install -g pm2 + +RUN echo '#!/bin/bash\nset-e\n\ncd /home/ethnetintel/eth-net-intelligence-api\n/usr/bin/pm2 start ./app.json\ntail -f \ + /home/ethnetintel/.pm2/logs/node-app-out-0.log' > /home/ethnetintel/startscript.sh + +RUN chmod +x /home/ethnetintel/startscript.sh &&\ + chown -R ethnetintel. /home/ethnetintel + +USER ethnetintel +ENTRYPOINT ["/home/ethnetintel/startscript.sh"] diff --git a/README.md b/README.md index 78bd659..8467bb1 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Ethereum Network Intelligence API This is the backend service which runs along with the node for tracking the ethereum network status, fetches information through the JSON-RPC and connects through WebSockets to [eth-netstats](https://github.com/cubedro/eth-netstats) and feed information constantly. ## Prerequisite -* eth or geth +* eth, geth or pyethapp * node * npm @@ -17,6 +17,10 @@ Fetch and run the build shell. This will install everything you need: latest eth ```bash bash <(curl https://raw.githubusercontent.com/cubedro/eth-net-intelligence-api/master/bin/build.sh) ``` +## Installation as docker container (optional) + +There is a `Dockerfile` in the root directory of the repository. Please read through the header of said file for +instructions on how to build/run/setup. Configuration instructions below still apply. ## Configuration @@ -58,4 +62,4 @@ It will stop the current netstats client processes, automatically detect your et [travis-image]: https://travis-ci.org/cubedro/eth-net-intelligence-api.svg [travis-url]: https://travis-ci.org/cubedro/eth-net-intelligence-api [dep-image]: https://david-dm.org/cubedro/eth-net-intelligence-api.svg -[dep-url]: https://david-dm.org/cubedro/eth-net-intelligence-api \ No newline at end of file +[dep-url]: https://david-dm.org/cubedro/eth-net-intelligence-api