diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..bd6d9f20 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/README.md b/README.md index 60cd7430..b9d65021 100644 --- a/README.md +++ b/README.md @@ -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). @@ -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. \ No newline at end of file +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. diff --git a/connectors/ada-usd-connector/Dockerfile b/connectors/ada-usd-connector/Dockerfile new file mode 100644 index 00000000..0cd5f8d5 --- /dev/null +++ b/connectors/ada-usd-connector/Dockerfile @@ -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"] diff --git a/connectors/erg-usd-connector/Dockerfile b/connectors/erg-usd-connector/Dockerfile new file mode 100644 index 00000000..ea0972ef --- /dev/null +++ b/connectors/erg-usd-connector/Dockerfile @@ -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"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..d4de3086 --- /dev/null +++ b/docker-compose.yml @@ -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 diff --git a/docker/ergo.conf b/docker/ergo.conf new file mode 100644 index 00000000..6ff3c5ac --- /dev/null +++ b/docker/ergo.conf @@ -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" + } +} diff --git a/docker/oracle-config.yaml b/docker/oracle-config.yaml new file mode 120000 index 00000000..c5949635 --- /dev/null +++ b/docker/oracle-config.yaml @@ -0,0 +1 @@ +../oracle-config.yaml \ No newline at end of file