Rosetta Dockerfile (Stage 4 of Node API Overhaul) (#3385)
* [node] Add txpool .rlp file based on cmd datadir Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Init docker infra files Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Add Dockerfile run script & update README.md Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu> * [rosetta] Clarify docker usage in infra README.md Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>pull/3391/head
parent
4ce64b1387
commit
6ce8aeac3d
@ -0,0 +1,29 @@ |
||||
FROM golang:1.14 |
||||
|
||||
RUN apt update -y && apt upgrade -y |
||||
RUN apt install libgmp-dev libssl-dev curl git -y |
||||
|
||||
ENV GOPATH=/root/go |
||||
ENV GO111MODULE=on |
||||
ENV HMY_PATH=${GOPATH}/src/github.com/harmony-one |
||||
RUN mkdir -p $HMY_PATH |
||||
|
||||
WORKDIR $HMY_PATH |
||||
|
||||
RUN git clone https://github.com/harmony-one/harmony.git |
||||
RUN git clone https://github.com/harmony-one/bls.git |
||||
RUN git clone https://github.com/harmony-one/mcl.git |
||||
|
||||
WORKDIR $HMY_PATH/harmony |
||||
|
||||
RUN make linux_static |
||||
RUN cp ./bin/harmony /root && chmod +x /root/harmony |
||||
|
||||
WORKDIR $GOPATH |
||||
|
||||
RUN rm -rf * |
||||
|
||||
WORKDIR /root |
||||
|
||||
COPY run.sh run.sh |
||||
ENTRYPOINT ["/bin/bash","/root/run.sh"] |
@ -0,0 +1,127 @@ |
||||
# Docker deployment of a Rosetta enabled Harmony node |
||||
|
||||
## Docker Image |
||||
You can choose to build the docker image using the included Dockerfile with the following command: |
||||
```bash |
||||
docker build -t harmony-rosetta . |
||||
``` |
||||
|
||||
Or you can download/pull the image from dockerhub with the following command: |
||||
```bash |
||||
docker pull harmony-rosetta:latest |
||||
``` |
||||
|
||||
## Starting the node |
||||
You can start the node with the following command: |
||||
```bash |
||||
docker run -d -p 9700:9700 -v "$(pwd)/data:/root/data" harmony-rosetta --run.shard=0 |
||||
``` |
||||
> This command will create the container of the harmony node on shard 0 in the detached mode, |
||||
> binding port 9700 (the rosetta port) on the container to the host and mounting the shared |
||||
> `./data` directory on the host to `/root/data` on the container. Note that the container |
||||
> uses `/root/data` for all data storage (this is where the `harmony_db_*` directories will be stored). |
||||
|
||||
You can view your container with the following command: |
||||
```bash |
||||
docker ps |
||||
``` |
||||
|
||||
You can ensure that your node is running with the following curl command: |
||||
```bash |
||||
curl -X POST --data '{ |
||||
"network_identifier": { |
||||
"blockchain": "Harmony", |
||||
"network": "Mainnet", |
||||
"sub_network_identifier": { |
||||
"network": "shard 0", |
||||
"metadata": { |
||||
"is_beacon": true |
||||
} |
||||
} |
||||
}}' http://localhost:9700/network/status |
||||
``` |
||||
|
||||
Once can start the node in the offline mode with the following command: |
||||
```bash |
||||
docker run -d -p 9700:9700 -v "$(pwd)/data:/root/data" harmony-rosetta --run.shard=0 --run.offline |
||||
``` |
||||
> The offline mode implies that the node will not connect to any p2p peer or sync. |
||||
|
||||
|
||||
## Stopping the node |
||||
First get your `CONTAINER ID` using the following command: |
||||
```bash |
||||
docker ps |
||||
``` |
||||
> Note that if you do not see your node in the list, then your node is not running. |
||||
> You can verify this with the `docker ps -a` command. |
||||
|
||||
Once you have your `CONTAINER ID`, you can stop it with the following command: |
||||
```bash |
||||
docker stop [CONTAINER ID] |
||||
``` |
||||
|
||||
## Details |
||||
|
||||
**Note that all the arguments provided when running the docker img are immediately forwarded to the harmony node binary.** |
||||
> Note that the following args are **appended** to the provided arg when running the image: |
||||
> `--http.ip "0.0.0.0" --ws.ip "0.0.0.0" --http.rosetta --node_type "explorer" --datadir "./data" --log.dir "./data/logs"`. |
||||
> This effectively makes them args that you cannot change. |
||||
|
||||
### Running the node on testnet |
||||
All the args on the image run are forwarded to the harmony node binary. Therefore, you can simply add `-n testnet` to |
||||
run the node for testnet. For example: |
||||
```bash |
||||
docker run -d -p 9700:9700 -v "$(pwd)/data:/root/data" harmony-rosetta --run.shard=0 -n testnet |
||||
``` |
||||
|
||||
### Running the node with the http RPC capabilities |
||||
Similar to running a node on testnet, once can simply add `--http` to enable the rpc server. Then you have to forward |
||||
the host port to the container's rpc server port. |
||||
```bash |
||||
docker run -d -p 9700:9700 -p 9500:9500 -v "$(pwd)/data:/root/data" harmony-rosetta --run.shard=0 -n testnet --http |
||||
``` |
||||
|
||||
### Running the node with the web socket RPC capabilities |
||||
Similar to running a node on testnet, once can simply add `--ws` to enable the rpc server. Then you have to forward |
||||
the host port to the container's rpc server port. |
||||
```bash |
||||
docker run -d -p 9700:9700 -p 9800:9900 -v "$(pwd)/data:/root/data" harmony-rosetta --run.shard=0 -n testnet --ws |
||||
``` |
||||
|
||||
### Running the node in non-archival mode |
||||
One can append `--run.archive=false` to the docker run command to run the node in non-archival mode. For example: |
||||
```bash |
||||
docker run -d -p 9700:9700 -v "$(pwd)/data:/root/data" harmony-rosetta --run.shard=0 -n testnet --run.archive=false |
||||
``` |
||||
|
||||
### Running a node with a rcloned DB |
||||
Note that all node data will be stored in the `/root/data` directory within the container. Therefore, you can rclone |
||||
the `harmony_db_*` directory to some directory (i.e: `./data`) and mount the volume on the docker run. |
||||
This way, the node will use DB in the volume that is shared between the container and host. For example: |
||||
```bash |
||||
docker run -d -p 9700:9700 -v "$(pwd)/data:/root/data" harmony-rosetta --run.shard=0 |
||||
``` |
||||
|
||||
Note that the directory structure for `/root/data` (== `./data`) should look something like: |
||||
``` |
||||
. |
||||
├── explorer_storage_127.0.0.1_9000 |
||||
├── harmony_db_0 |
||||
├── harmony_db_1 |
||||
├── logs |
||||
│ ├── node_execution.log |
||||
│ └── zerolog-harmony.log |
||||
└── transactions.rlp |
||||
``` |
||||
|
||||
### Inspecting Logs |
||||
If you mount `./data` on the host to `/root/data` in the container, you van view the harmony node logs at |
||||
`./data/logs/` on your host machine. |
||||
|
||||
### View rosetta request logs |
||||
You can view all the rosetta endpoint requests with the following command: |
||||
```bash |
||||
docker logs [CONTAINER ID] |
||||
``` |
||||
> The `[CONTAINER ID]` can be found with this command: `docker ps` |
@ -0,0 +1,11 @@ |
||||
#!/usr/bin/env bash |
||||
set -e |
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
||||
DATA="$DIR/data" |
||||
LOGS="$DATA/logs" |
||||
BASE_ARGS=(--http.ip "0.0.0.0" --ws.ip "0.0.0.0" --http.rosetta --node_type "explorer" --datadir "$DATA" --log.dir "$LOGS") |
||||
|
||||
mkdir -p "$LOGS" |
||||
echo -e NODE ARGS: \" "$@" "${BASE_ARGS[@]}" \" |
||||
"$DIR/harmony" "$@" "${BASE_ARGS[@]}" |
Loading…
Reference in new issue