Skip to content

Docker: adding basic compose support #4

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM rust:1.45.2 as builder
WORKDIR /usr/src/
RUN git clone https://github.com/ergoplatform/oracle-core.git
WORKDIR /usr/src/oracle-core
RUN cargo build --release
RUN cargo install --path .

FROM rust:1.45.2-slim
COPY --from=builder /usr/local/cargo/bin/oracle-core /usr/local/bin/oracle-core
CMD ["oracle-core"]
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,42 @@ In order for an oracle pool to run, it must be first created/bootstrapped on-cha

Check out the [Oracle Pool Bootstrap folder](oracle-pool-bootstrap) for detailed instructions about how to bootstrap an oracle pool using the CLI tool or manually.

# Running An Oracle Using Docker Compose
It's possible to setup an oracle cluster using docker compose. We do not recommend this deployment for production, unless you know what you are doing.

1. Before bringing the cluster up, we need to update the `apiKeyHash` value inside `docker/ergo.conf`. This key will be used for interaction with the API.

2. After that is done, we can bring up the cluster.

```
docker-compose up -d
```

3. While our Ergo `node` syncs the blockchain we can restore our wallet using the API key defined in the first step. As you can see, we need to define a wallet password as well.

```
$ curl -XPOST -H "api_key: hello" \
-d '{"pass": "123", "mnemonic": "all all all..."}' \
-H "accept: application/json" \
-H "Content-Type: application/json" \
http://localhost:9053/wallet/restore
"OK"
```

4. Now we need to unlock the wallet using the password we defined in the step above.

```
$ curl -XPOST -H "api_key: hello" \
-d '{"pass": "123"}' \
-H "accept: application/json" \
-H "Content-Type: application/json" \
http://localhost:9053/wallet/unlock
"OK"
```

5. The node will sync over the next couple of hours or so which provides us with a good time frame to setup the oracle core itself and get the required UTXO-set scans registered.

...

# Writing A New Connector
If you are looking to create a new Oracle Pool for a new datapoint, you need to write a new Connector. This process has been greatly simplified thanks to [`Connector Lib`](connectors/connector-lib).
Expand All @@ -68,4 +104,4 @@ Now within 15-20 lines of Rust code, you can easily create your own Connector th

If you would like to integrate your pool with the Ergo Explorer we have also created [`Frontend Connector Lib`](connectors/frontend-connector-lib). This library builds off of `Connector Lib` and automatically provides + runs an API server which produces all of the data required for the frontend.

Building a Frontend Connector provides a single endpoint which summarizes the majority of relevant data about your Oracle Pool, and as such can also be useful if you intend to create your own custom website/frontend for showing off what is going on in your pool.
Building a Frontend Connector provides a single endpoint which summarizes the majority of relevant data about your Oracle Pool, and as such can also be useful if you intend to create your own custom website/frontend for showing off what is going on in your pool.
10 changes: 10 additions & 0 deletions connectors/ada-usd-connector/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM rust:1.45.2 as builder
WORKDIR /usr/src/
RUN git clone https://github.com/ergoplatform/oracle-core.git
WORKDIR /usr/src/oracle-core/connectors/ada-usd-connector
RUN cargo build --release
RUN cargo install --path .

FROM rust:1.45.2-slim
COPY --from=builder /usr/local/cargo/bin/ada-usd-connector /usr/local/bin/ada-usd-connector
CMD ["ada-usd-connector"]
10 changes: 10 additions & 0 deletions connectors/erg-usd-connector/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM rust:1.45.2 as builder
WORKDIR /usr/src/
RUN git clone https://github.com/ergoplatform/oracle-core.git
WORKDIR /usr/src/oracle-core/connectors/erg-usd-connector
RUN cargo build --release
RUN cargo install --path .

FROM rust:1.45.2-slim
COPY --from=builder /usr/local/cargo/bin/erg-usd-connector /usr/local/bin/erg-usd-connector
CMD ["erg-usd-connector"]
56 changes: 56 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
version: "3"

volumes:
ergo_node_storage:

services:
node:
image: ergoplatform/ergo:v3.3.1
restart: unless-stopped
volumes:
- "ergo_node_storage:/home/ergo/.ergo"
- "${PWD}/docker/ergo.conf:/etc/ergo.conf"
command: --mainnet -c /etc/ergo.conf
ports:
- 9030:9030
- 9053:9053

oracle-core-erg-usd:
build: .
restart: unless-stopped
network_mode: "host"
volumes:
- "${PWD}/scripts/erg-usd-oracle/oracle-config.yaml:/oracle-config.yaml"
depends_on:
- node

erg-usd-connector:
build: connectors/erg-usd-connector/
restart: unless-stopped
network_mode: "host"
volumes:
- "${PWD}/scripts/erg-usd-oracle/oracle-config.yaml:/oracle-config.yaml"
ports:
- 9092:9092
depends_on:
- oracle-core-erg-usd

oracle-core-ada-usd:
build: .
restart: unless-stopped
network_mode: "host"
volumes:
- "${PWD}/scripts/ada-usd-oracle/oracle-config.yaml:/oracle-config.yaml"
depends_on:
- node

ada-usd-connector:
build: connectors/ada-usd-connector/
restart: unless-stopped
network_mode: "host"
volumes:
- "${PWD}/scripts/ada-usd-oracle/oracle-config.yaml:/oracle-config.yaml"
ports:
- 9082:9082
depends_on:
- oracle-core-ada-usd
17 changes: 17 additions & 0 deletions docker/ergo.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ergo {
directory = ${ergo.directory}"/.ergo"
node {
mining = false
}
wallet.secretStorage.secretDir = ${ergo.directory}"/wallet/keystore"
}

scorex {
restApi {
# Hex-encoded Blake2b256 hash of an API key.
# Should be 64-chars long Base16 string.
# below is the hash of the string 'hello'
# replace with your actual hash
apiKeyHash = "324dcf027dd4a30a932c441f365a25e86b173defa4b8e58948253471b81b72cf"
}
}
1 change: 1 addition & 0 deletions docker/oracle-config.yaml