Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Docker support #175

Merged
merged 2 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@ sh <(wget -qO- https://raw.githubusercontent.com/onggunhao/node-binary/master/in
> In the future, we may release an official installer script
> e.g. `sh <(wget -qO- https://get.binance.org)`

## Docker node

### Building locally

```
git clone https://github.com/binance-chain/node-binary.git
cd node-binary/docker && docker build . -t binance/binance-node
```

### Run interactively

`docker run --rm -it --ulimit nofile=16000:16000 binance/binance-node`

### Run as daemon

```
ufw allow 27146/tcp
docker run -d --name binance-node -v binance-data:/opt/bnbchaind -e "BNET=prod" -p 27146:27146 -p 27147:27147 -p 26660:26660 --restart unless-stopped --security-opt no-new-privileges --ulimit nofile=16000:16000 binance/binance-node
```

For more details see README.md in the docker directory.

## Manual Installation

We currently use this repo to store historical versions of the compiled `node-binaries`.
Expand Down
67 changes: 67 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# UPDATE ME when new version is out !!!!
ARG BVER=0.6.3
ARG CLIVER=0.6.3
FROM ubuntu:18.04 as builder

# Dockerfile for running Binance node from binary packages under docker
# https://docs.binance.org/fullnode.html#run-full-node-to-join-binance-chain
# MIT license
LABEL Maintainer = "Evgeny Varnavskiy <varnavruz@gmail.com>"
LABEL Description="Docker image for Binance full and light nodes"
LABEL License="MIT License"

ARG DEBIAN_FRONTEND=noninteractive

ARG BVER
ARG CLIVER
ARG NODETYPE=fullnode
#ARG NODETYPE=lightnode

RUN apt-get update && apt-get install -y --no-install-recommends upx ca-certificates wget git git-lfs binutils
RUN git lfs clone --depth 1 https://github.com/binance-chain/node-binary.git

# RUN upx /node-binary/cli/testnet/${CLIVER}/linux/tbnbcli \
# && upx /node-binary/cli/prod/${CLIVER}/linux/bnbcli \
# && upx /node-binary/${NODETYPE}/testnet/${BVER}/linux/bnbchaind \
# && upx /node-binary/${NODETYPE}/prod/${BVER}/linux/bnbchaind

# Final stage

FROM ubuntu:18.04

ARG HOST_USER_UID=1000
ARG HOST_USER_GID=1000

ARG BVER
ARG CLIVER
ENV BVER=$BVER
ENV CLIVER=$CLIVER
ARG NODETYPE=fullnode
#ARG NODETYPE=lightnode
ENV BNET=testnet
#ENV BNET=prod
ENV BNCHOME=/opt/bnbchaind

COPY --from=builder /node-binary/cli/testnet/${CLIVER}/linux/tbnbcli /node-binary/cli/testnet/${BVER}/linux/
COPY --from=builder /node-binary/cli/prod/${CLIVER}/linux/bnbcli /node-binary/cli/prod/${BVER}/linux/
COPY --from=builder /node-binary/${NODETYPE}/testnet/${BVER}/linux/bnbchaind /node-binary/fullnode/testnet/${BVER}/linux/
COPY --from=builder /node-binary/${NODETYPE}/prod/${BVER}/linux/bnbchaind /node-binary/fullnode/prod/${BVER}/linux/
COPY --from=builder /node-binary/${NODETYPE}/testnet/${BVER}/config/* /node-binary/fullnode/testnet/${BVER}/config/
COPY --from=builder /node-binary/${NODETYPE}/prod/${BVER}/config/* /node-binary/fullnode/prod/${BVER}/config/
COPY ./bin/*.sh /usr/local/bin/

RUN set -ex \
&& chmod +x /usr/local/bin/*.sh \
&& mkdir -p "$BNCHOME" \
&& groupadd --gid "$HOST_USER_GID" bnbchaind \
&& useradd --uid "$HOST_USER_UID" --gid "$HOST_USER_GID" --shell /bin/bash --no-create-home bnbchaind \
&& chown -R bnbchaind:bnbchaind "$BNCHOME"

VOLUME ${BNCHOME}

# RPC service listen on port 27147 and P2P service listens on port 27146 by default.
# Prometheus is enabled on port 26660 by default, and the endpoint is /metrics.

EXPOSE 27146 27147 26660

ENTRYPOINT ["entrypoint.sh"]
21 changes: 21 additions & 0 deletions docker/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Evgeny Varnavskiy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
50 changes: 50 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# binance-node-docker

[Binance full node docs](https://docs.binance.org/fullnode.html#run-full-node-to-join-binance-chain)
[Binance full node repo](https://github.com/binance-chain/node-binary)

Docker image for Binance Full Node

### Features:

* Spin up full Binance node with single command.
* Works for testnet, prod, or both at once.
* Small image about 100MB, compared to bigger than 6 GB official repository.
* Easy updates

## Building locally

```
git clone https://github.com/binance-chain/node-binary.git
cd node-binary/docker && docker build . -t binance/binance-node
```

### Run interactively

`docker run --rm -it --ulimit nofile=16000:16000 binance/binance-node`

### Run as daemon

```
ufw allow 27146/tcp
docker run -d --name binance-node -v binance-data:/opt/bnbchaind -e "BNET=prod" -p 27146:27146 -p 27147:27147 -p 26660:26660 --restart unless-stopped --security-opt no-new-privileges --ulimit nofile=16000:16000 binance/binance-node
```

You can run both testnet and prod at once, use `-p 27147:27147` for publishing RPC port for one of them.

### Check logs

`docker logs -f binance-node`

### CLI access

```
docker exec -it binance-node /bin/bash
tbnbcli version
```

use `tbnbcli` for testnet and `bnbcli` for prod

### Update

`docker stop binance-node && docker rm binance-node`, pull fresh image with `docker pull binance/binance-node` and then run again, data and configs in the volume `binance-data` are preserved.
6 changes: 6 additions & 0 deletions docker/bin/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

source setup.sh
echo "Running $0 in $PWD"
set -ev
su bnbchaind -c "/usr/local/bin/bnbchaind start --home ${BNCHOME}"
24 changes: 24 additions & 0 deletions docker/bin/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -ex

if [ ! -d "${BNCHOME}/config/" ]; then
mkdir -p ${BNCHOME}/config/
cp /node-binary/fullnode/${BNET}/${BVER}/config/* ${BNCHOME}/config/
chown -R bnbchaind:bnbchaind ${BNCHOME}/config/
fi

ln -sf /node-binary/fullnode/${BNET}/${BVER}/linux/bnbchaind /usr/local/bin/bnbchaind
chmod +x /usr/local/bin/bnbchaind

if [ ${BNET} == "testnet" ]; then
ln -sf /node-binary/cli/${BNET}/${BVER}/linux/tbnbcli /usr/local/bin/tbnbcli
chmod +x /usr/local/bin/tbnbcli
else
ln -sf /node-binary/cli/${BNET}/${BVER}/linux/bnbcli /usr/local/bin/bnbcli
chmod +x /usr/local/bin/bnbcli
fi

# Turn on console logging

sed -i 's/logToConsole = false/logToConsole = true/g' ${BNCHOME}/config/app.toml