Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfile #41

Open
nileshtrivedi opened this issue Feb 22, 2018 · 3 comments
Open

Add Dockerfile #41

nileshtrivedi opened this issue Feb 22, 2018 · 3 comments

Comments

@nileshtrivedi
Copy link

Make it possible to run this app as a docker container. Take care to pick up configuration from environment variables so that it can be embedded in docker-compose setups.

It will then be possible to include this explorer in the standard puppeth tool which comes with geth. See this tweet by Péter Szilágyi and the replies: https://twitter.com/peter_szilagyi/status/965553294323126272

puppeth is used mostly for deploying private network names, so it might also be a good idea to NOT hard-code the native currency name to "Ether" and instead pick it up from run-time config.

@Alaradia
Copy link

it already is possible to run it as a docker container just nobody has done it.

@saniales
Copy link

can you show us how? @Alaradia

@jotorren
Copy link

jotorren commented Mar 19, 2018

Try:

Dockerfile

FROM node:8.10.0

RUN git clone https://github.com/carsenk/explorer

WORKDIR /explorer

RUN sed 's/-a localhost -p 8000/-a 0.0.0.0 -p 8000/g' package.json > pkg.json
RUN rm -f package.json
RUN mv pkg.json package.json

RUN npm install
RUN node_modules/.bin/bower install --allow-root

COPY startscript.sh .

RUN adduser --disabled-password --gid 0 --gecos "EthereumExplorerV2 user" ethexplorer
RUN chown -R ethexplorer. /explorer

EXPOSE 8000

USER ethexplorer
RUN chown ethexplorer:root /home/ethexplorer && chmod 0775 /home/ethexplorer
ENV HOME /home/ethexplorer
RUN chmod -R g+w /explorer
ENTRYPOINT ["/explorer/startscript.sh"]

startscript.sh:

#!/bin/sh

sed "s/var GETH_HOSTNAME\t= \"localhost\";/var GETH_HOSTNAME\t= \"$GETH_HOSTNAME\";/g" /explorer/app/app.js > /explorer/app/apptmp.js
sed "s/var GETH_RPCPORT  \t= 8545;/var GETH_RPCPORT  \t= $GETH_RPCPORT;/g" /explorer/app/apptmp.js > /explorer/app/app.js
rm -f /explorer/app/apptmp.js
npm start

You can build the docker image running (from the directory containing the Dockerfile):

# docker build -t blockchain/eth-explorer .

# docker images
REPOSITORY                            TAG                 IMAGE ID            CREATED             SIZE
blockchain/eth-explorer               latest              10c97739e654        About an hour ago   1.084 GB

And finally start a container giving it, as environment variables, Ethereum node IP and port:

# docker run -e GETH_HOSTNAME=192.168.99.100 -e GETH_RPCPORT=32001 -p 8000:8000 -t blockchain/eth-explorer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants