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

core: Docker integration #7

Merged
merged 3 commits into from
Dec 15, 2023
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: 5 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
NODE_ENV=development

NODE_PORT=3001

# Use 0.0.0.0 if Docker instance
NODE_HOST=localhost

COINGECKO_BASE_URL=https://api.coingecko.com/api/v3/
COINGECKO_API_KEY=
COINGECKO_API_KEY_QUERY_NAME=x_cg_demo_api_key

ETHERSCAN_BASE_URL=
ETHERSCAN_BASE_URL=https://api-sepolia.etherscan.io/
ETHERSCAN_API_KEY=
ETHERSCAN_API_KEY_QUERY_NAME=
ETHERSCAN_API_KEY_QUERY_NAME=apikey

ALCHEMY_URL=
ALCHEMY_URL=https://eth-sepolia.g.alchemy.com/v2/API_KEY_HERE
PRIVATE_KEY=

# Sepolia data
Expand Down
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:18
WORKDIR /usr/src/app

COPY package.json ./
COPY yarn.lock ./

RUN yarn

COPY . .
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,58 @@
# Token Price Oracle - Orchestrator 🎢
Token Price Oracle is simple oracle for tracking token prices on-chain.
In this repo is located the Typescript Client orchestrator used for
tracking, management and orchestration of the data.
tracking, management and orchestration of the data.

## Running the project πŸš€
### Requirements βœ…
- On your computer
* If setting up using Docker
* Installed [Docker](https://www.docker.com/)
* Installed docker-compose (Bundled with the official Docker setup)
* If setting up locally
* Installed [Node.js 18](https://nodejs.org/en/)
* Installed [yarn](https://yarnpkg.com/) package manager

### Installation βš™οΈ
#### Git
1. Clone the repo: ```git clone https://github.com/pajicf/token-price-oracle-orchestrator.git```
2. Navigate to the folder: ```cd token-price-oracle-orchestrator```

#### Setting up the environment
3. Run ```cp .env.example .env``` and fill the values`

**Where can I obtain the needed values?**

| Value | Description | Link |
|------------------|---------------------------------------------------------------------------------------------------------------|--------------------------------------------------|
| COINGECKO_API_KEY | The API key for consuming Coingecko service | https://www.coingecko.com/en/api/pricing |
| ETHERSCAN_API_KEY | The API key for consuming Etherscan service | https://docs.etherscan.io/getting-started/viewing-api-usage-statistics |
| ALCHEMY_URL | Url for interacting with Alchemy (Make sure the Network is the same as of other values) | https://docs.alchemy.com/docs/alchemy-quickstart-guide |
| PRIVATE_KEY | The Private key that your orchestrator instance will be using for interacting with the EVM compatible network | https://support.metamask.io/hc/en-us/articles/360015289632-How-to-export-an-account-s-private-key |

> [!IMPORTANT]
> Ensure that you've filled all the needed values in the .env

---
After you complete the previous steps, the following instruction will vary based on that
if you're trying to run the project using docker or your local setup
---

#### Docker setup
4. Run `docker-compose up`
5. That's it!
> [!NOTE]
> If you've pulled new code files you'll have to rebuild the Docker image using `docker-compose build --no-cache node_backend`

#### Running locally
4. Run ```yarn``` to install the dependencies
5. Building the project: ```yarn build```
6. Starting the project: ```yarn start```

### Commands πŸ§‘β€πŸ’»
| Name | Command | Description |
|------------------|------------------|--------------------------------------------------|
| Dev Environment | ```yarn dev``` | Starts the development environment |
| Build | ```yarn build``` | Compiles the project and builds production files |
| Start | ```yarn start``` | Starts the project from the production build |
| Contract Typings | ```yarn lint``` | Lints the project using `eslint` |
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "3"
services:
token_price_oracle_orchestrator_ts:
container_name: "token_price_oracle_orchestrator_ts"
build: .
entrypoint: ["./docker-entrypoint.sh"]
ports:
- ${NODE_PORT}:${NODE_PORT}
volumes:
- ./docker-entrypoint.sh:/usr/src/app/docker-entrypoint.sh
4 changes: 4 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

yarn build;
yarn start;
Loading