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

fixes make commands & docs #17

Merged
merged 2 commits into from
Sep 12, 2022
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
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN mkdir -p /app \
WORKDIR /app

ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y curl clang git
RUN apt-get update && apt-get install -y curl clang git pkg-config libssl-dev

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH=/root/.cargo/bin:$PATH
Expand All @@ -45,15 +45,15 @@ ENV ROCKET_ENV "production"
RUN apt-get update && apt-get install -y libssl-dev

RUN mkdir -p /app/data \
&& chown -R nobody:nogroup /app
&& chown -R nobody:nogroup /app

WORKDIR /app

# Copy binary from bitcoin-node-builder
COPY --from=bitcoin-node-builder /app/node-runner /app/node-runner

# Copy binary from rosetta-bitcoin-server
COPY --from=rosetta-mentat-builder /app/* /app
COPY --from=rosetta-mentat-builder /app/* /app

# Set permissions for everything added to /app
RUN chmod -R 755 /app/*
Expand Down
19 changes: 11 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@ build-release:
docker build -t mentat-rosetta-bitcoin:$(version) .
docker save mentat-rosetta-bitcoin:$(version) | gzip > mentat-rosetta-bitcoin-$(version).tar.gz;

run-mainnet-online:
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/data:/data" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -p 8080:8080 -p 4132:4132 mentat-rosetta-bitcoin:latest
run:
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/data:/data" -p 8080:8080 -p 4132:4132 mentat-rosetta-bitcoin:latest

run-mainnet-offline:
docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -p 8080:8080 -p 4132:4132 mentat-rosetta-bitcoin:latest
# run-mainnet-online:
# docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/data:/data" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -p 8080:8080 -p 4132:4132 mentat-rosetta-bitcoin:latest

run-testnet-online:
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/data:/data" -e "MODE=ONLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -p 8080:8080 -p 4132:4132 mentat-rosetta-bitcoin:latest
# run-mainnet-offline:
# docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -p 8080:8080 -p 4132:4132 mentat-rosetta-bitcoin:latest

run-testnet-offline:
docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -p 8080:8080 -p 4132:4132 mentat-rosetta-bitcoin:latest
# run-testnet-online:
# docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/data:/data" -e "MODE=ONLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -p 8080:8080 -p 4132:4132 mentat-rosetta-bitcoin:latest

# run-testnet-offline:
# docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -p 8080:8080 -p 4132:4132 mentat-rosetta-bitcoin:latest

tracing:
docker run -d -p6831:6831/udp -p6832:6832/udp -p16686:16686 -p14268:14268 jaegertracing/all-in-one:latest
Expand Down
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,31 @@ make build-local

#### Run Docker

Running these commands will start a Docker container in [detached mode](https://docs.docker.com/engine/reference/run/#detached--d) with a data directory at `<working directory>/bitcoin-data` and the Rosetta API accessible at port `8080`.
Running these commands will start a Docker container in [detached mode](https://docs.docker.com/engine/reference/run/#detached--d) with a data directory at `<working directory>/data` and the Rosetta API accessible at port `8080`.

##### Configuration

the file [docker.conf.toml](docker.conf.toml) contains the settings that the docker image will use
the file [docker.conf.toml](docker.conf.toml) contains the settings that the docker image will use. You can control if the node runs in `Online` or `Offline` mode, as well as if it runs on `Mainnet` or `Testnet`

##### Command Examples

You can run these commands from the command line. If you cloned the repository, you can use the `make` commands shown after the examples.

###### **Mainnet:Online**
###### **Running a Container**

Uncloned repo:

```text
docker run -d --rm --ulimit "nofile=100000:100000" -v "$(pwd)/data:/data" -p 8080:8080 -p 4132:4132 mentat-rosetta-bitcoin:latest
```

Cloned repo:

```text
make run
```

<!-- ###### **Mainnet:Online**

Uncloned repo:
```text
Expand Down Expand Up @@ -51,7 +65,7 @@ Uncloned repo:
docker run -d --rm --ulimit "nofile=100000:100000" -v "$(pwd)/bitcoin-data:/data" -p 8080:8080 -p 18333:18333 rosetta-bitcoin:latest
```

Cloned repo:
Cloned repo:
```text
make run-testnet-online
```
Expand All @@ -63,10 +77,10 @@ Uncloned repo:
docker run -d --rm -p 8081:8081 rosetta-bitcoin:latest
```

Cloned repo:
Cloned repo:
```text
make run-testnet-offline
```
``` -->

### Example Requests

Expand Down
2 changes: 1 addition & 1 deletion docker.conf.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ address = '0.0.0.0'
port = 8080
mode = 'ONLINE'
node_path = './node-runner'
network = 'TESTNET'
network = 'MAINNET'
secure_http = false
node_address = '0.0.0.0'
node_rpc_port = 4032
Expand Down
2 changes: 1 addition & 1 deletion dockerdev.conf.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ address = '0.0.0.0'
port = 8080
mode = 'ONLINE'
node_path = '/usr/bin/bitcoind'
network = 'TESTNET'
network = 'MAINNET'
secure_http = false
node_address = '0.0.0.0'
node_rpc_port = 4032
Expand Down
22 changes: 13 additions & 9 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{path::PathBuf, process::Command, str::FromStr};

use mentat_server::{
axum::async_trait,
conf::{Configuration, NodeConf},
conf::{Configuration, Network, NodeConf},
reqwest::Url,
serde::{Deserialize, Serialize},
};
Expand All @@ -27,20 +27,24 @@ impl NodeConf for BitcoinConfig {

fn node_command(config: &Configuration<Self>) -> Command {
let mut command = Command::new(&config.node_path);
command.args(&[
let mut args = vec![
// TODO cant bind to address without setting a whitelist
// &format!("--bind={address}:4132"),
// &format!("--rpcbind={address}:3032"),
"-port=4132",
"-port=4132".to_string(),
// TODO `Config options rpcuser and rpcpassword will soon be deprecated.
// Locally-run instances may remove rpcuser to use cookie-based auth, or may be
// replaced with rpcauth. Please see share/rpcauth for rpcauth auth generation.`
&format!("-rpcport={}", config.node_rpc_port),
&format!("-rpcuser={}", config.custom.user),
&format!("-rpcpassword={}", config.custom.pass),
"-txindex=1",
&format!("--datadir={}", config.custom.data_dir.display()),
]);
format!("-rpcport={}", config.node_rpc_port),
format!("-rpcuser={}", config.custom.user),
format!("-rpcpassword={}", config.custom.pass),
"-txindex=1".into(),
format!("--datadir={}", config.custom.data_dir.display()),
];
if config.network == Network::Testnet {
args.push("--testnet".to_string())
}
command.args(&args);
command
}
}
Expand Down