Skip to content

Commit cd0c1d6

Browse files
committed
Docker: adding basic compose support
1 parent 80fff75 commit cd0c1d6

File tree

6 files changed

+115
-1
lines changed

6 files changed

+115
-1
lines changed

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM rust:1.45.2 as builder
2+
WORKDIR /usr/src/
3+
RUN git clone https://github.com/ergoplatform/oracle-core.git
4+
WORKDIR /usr/src/oracle-core
5+
RUN cargo build --release
6+
RUN cargo install --path .
7+
8+
FROM rust:1.45.2-slim
9+
COPY --from=builder /usr/local/cargo/bin/oracle-core /usr/local/bin/oracle-core
10+
CMD ["oracle-core"]

README.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,50 @@ In order for an oracle pool to run, it must be first created/bootstrapped on-cha
6060

6161
Check out the [Bootstrap doc](docs/Bootstrap.md) for detailed instructions about how to bootstrap an oracle pool and each of the oracles within it.
6262

63+
# Running An Oracle Using Docker Compose
64+
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.
65+
66+
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.
67+
68+
2. After that is done, we can bring up the cluster.
69+
70+
```
71+
docker-compose up -d
72+
```
73+
74+
3. It will take a while until our Ergo `node` sync the blockchain. After it is done, we need to 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.
75+
76+
```
77+
$ curl -XPOST -H "api_key: hello" \
78+
-d '{"pass": "123", "mnemonic": "all all all..."}' \
79+
-H "accept: application/json" \
80+
-H "Content-Type: application/json" \
81+
http://localhost:9053/wallet/restore
82+
"OK"
83+
```
84+
85+
4. Now we need to unlock the wallet using the password we defined in the step above.
86+
87+
```
88+
$ curl -XPOST -H "api_key: hello" \
89+
-d '{"pass": "123"}' \
90+
-H "accept: application/json" \
91+
-H "Content-Type: application/json" \
92+
http://localhost:9053/wallet/unlock
93+
"OK"
94+
```
95+
96+
5. Verify your wallet is on the tip and has some balance in it.
97+
98+
```
99+
$ curl -XGET -H "api_key: hello" \
100+
-H "accept: application/json" \
101+
-H "Content-Type: application/json" \
102+
http://localhost:9053/wallet/balances
103+
```
104+
63105

64106
# Writing A New Connector
65107
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).
66108

67-
Now within 15-20 lines of Rust code, you can easily create your own Connector that plugs right in to the Oracle Core.
109+
Now within 15-20 lines of Rust code, you can easily create your own Connector that plugs right in to the Oracle Core.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM rust:1.45.2 as builder
2+
WORKDIR /usr/src/
3+
RUN git clone https://github.com/ergoplatform/oracle-core.git
4+
WORKDIR /usr/src/oracle-core/connectors/erg-usd-connector
5+
RUN cargo build --release
6+
RUN cargo install --path .
7+
8+
FROM rust:1.45.2-slim
9+
COPY --from=builder /usr/local/cargo/bin/erg-usd-connector /usr/local/bin/erg-usd-connector
10+
CMD ["erg-usd-connector"]

docker-compose.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: "3"
2+
3+
volumes:
4+
ergo_node_storage:
5+
6+
services:
7+
node:
8+
image: ergoplatform/ergo:v3.3.0
9+
restart: unless-stopped
10+
volumes:
11+
- "ergo_node_storage:/home/ergo/.ergo"
12+
- "${PWD}/docker/ergo.conf:/etc/ergo.conf"
13+
command: --mainnet -c /etc/ergo.conf
14+
ports:
15+
- 9030:9030
16+
- 9053:9053
17+
18+
oracle-core:
19+
build: .
20+
restart: unless-stopped
21+
network_mode: "host"
22+
volumes:
23+
- "${PWD}/docker/oracle-config.yaml:/oracle-config.yaml"
24+
depends_on:
25+
- node
26+
27+
erg-usd-connector:
28+
build: connectors/erg-usd-connector/
29+
restart: unless-stopped
30+
network_mode: "host"
31+
volumes:
32+
- "${PWD}/docker/oracle-config.yaml:/oracle-config.yaml"
33+
depends_on:
34+
- oracle-core

docker/ergo.conf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
ergo {
2+
directory = ${ergo.directory}"/.ergo"
3+
node {
4+
mining = false
5+
}
6+
wallet.secretStorage.secretDir = ${ergo.directory}"/wallet/keystore"
7+
}
8+
9+
scorex {
10+
restApi {
11+
# Hex-encoded Blake2b256 hash of an API key.
12+
# Should be 64-chars long Base16 string.
13+
# below is the hash of the string 'hello'
14+
# replace with your actual hash
15+
apiKeyHash = "324dcf027dd4a30a932c441f365a25e86b173defa4b8e58948253471b81b72cf"
16+
}
17+
}

docker/oracle-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../oracle-config.yaml

0 commit comments

Comments
 (0)