janoside / btc-rpc-explorer

Database-free, self-hosted Bitcoin explorer, via RPC to Bitcoin Core.
https://bitcoinexplorer.org
MIT License
1.52k stars 1.13k forks source link

Dockerfile example #358

Closed lorenz10 closed 2 years ago

lorenz10 commented 3 years ago

I'm a newbie in the Docker world, but I was recently able to setup:

The btc-rpc-explorer will be available on port 80 of the server's domain.

I want to provide the Dockerfile and commands I used as an example to run btc-rpc-explorer (that I adapted for my Peercoin fork) with these two services, hoping that will be usefull for someone, even though I'm not sure this is the best way:

Dockerfile:

FROM node:16.6.1-alpine3.12
RUN apk --no-cache add git
RUN git clone --single-branch --branch master \
    https://github.com/lorenz10/btc-rpc-explorer.git btc-rpc-explorer
WORKDIR /btc-rpc-explorer
RUN echo -e 'BTCEXP_BITCOIND_HOST=host.docker.internal \
\nBTCEXP_BITCOIND_PORT=9904 \nBTCEXP_BITCOIND_USER=<USER> \
\nBTCEXP_BITCOIND_PASS=<PASSWORD> \nBTCEXP_BITCOIND_RPC_TIMEOUT=10000 \
\nBTCEXP_ADDRESS_API=electrum \
\nBTCEXP_ELECTRUM_SERVERS=tcp://host.docker.internal:50001 \
\nBTCEXP_HOST=0.0.0.0 \nBTCEXP_PORT=80' > .env
RUN npm install
CMD npm start
EXPOSE 80

Docker Image: docker build -t btc-rpc-explorer . Docker Container docker run -it -p 80:80 -d btc-rpc-explorer adding also --add-host=host.docker.internal:host-gateway if the guest OS is Linux.

lorenz10 commented 2 years ago

Vary bad implementation...