Skip to content
This repository was archived by the owner on Apr 3, 2023. It is now read-only.

Commit c6b7fa9

Browse files
authored
Add Docker and docker-compose (#34)
* Add Docker and docker-compose
1 parent c311f36 commit c6b7fa9

File tree

5 files changed

+153
-3
lines changed

5 files changed

+153
-3
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Build and Push EVM Price Pusher Image
2+
on:
3+
push:
4+
tags:
5+
- pyth-evm-price-pusher-v*
6+
workflow_dispatch:
7+
inputs:
8+
dispatch_description:
9+
description: "Dispatch description"
10+
required: true
11+
type: string
12+
permissions:
13+
contents: read
14+
id-token: write
15+
jobs:
16+
evm-price-pusher-image:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Set image tag to version of the git tag
21+
if: ${{ startsWith(github.ref, 'refs/tags/pyth-evm-price-pusher-v') }}
22+
run: |
23+
PREFIX="refs/tags/pyth-evm-price-pusher-"
24+
VERSION="${GITHUB_REF:${#PREFIX}}"
25+
echo "IMAGE_TAG=${VERSION}" >> "${GITHUB_ENV}"
26+
- name: Set image tag to the git commit hash
27+
if: ${{ !startsWith(github.ref, 'refs/tags/pyth-evm-price-pusher-v') }}
28+
run: |
29+
echo "IMAGE_TAG=${{ github.sha }}" >> "${GITHUB_ENV}"
30+
- uses: aws-actions/configure-aws-credentials@8a84b07f2009032ade05a88a28750d733cc30db1
31+
with:
32+
role-to-assume: arn:aws:iam::192824654885:role/github-actions-ecr
33+
aws-region: eu-west-2
34+
- uses: docker/login-action@v2
35+
with:
36+
registry: public.ecr.aws
37+
env:
38+
AWS_REGION: us-east-1
39+
- uses: aws-actions/amazon-ecr-login@v1
40+
id: ecr_login
41+
- run: |
42+
cd pyth-evm-price-pusher
43+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
44+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
45+
env:
46+
ECR_REGISTRY: public.ecr.aws
47+
ECR_REPOSITORY: pyth-network/xc-evm-price-pusher

pyth-evm-price-pusher/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM node:16-alpine@sha256:72a490e7ed8aed68e16b8dc8f37b5bcc35c5b5c56ee3256effcdee63e2546f93
2+
3+
RUN addgroup -S pyth -g 10001 && adduser -S pyth -G pyth -u 10001
4+
USER pyth
5+
6+
ARG PRICE_PUSHER_PATH=/usr/src/pyth-evm-price-pusher
7+
WORKDIR ${PRICE_PUSHER_PATH}
8+
COPY --chown=pyth:pyth . .
9+
RUN npm ci && npm run build && npm cache clean --force
10+
11+
ENTRYPOINT [ "npm", "run", "start" ]

pyth-evm-price-pusher/README.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ The parameters above are configured per price feed in a price configuration YAML
4040
- ...
4141
```
4242
43+
You can get the list of available price feeds from
44+
[here](https://pyth.network/developers/price-feed-ids/#pyth-cross-chain-testnet).
45+
4346
To run the price pusher, please run the following commands, replacing the command line arguments as necessary:
4447
4548
```sh
@@ -50,6 +53,9 @@ npm run start -- --evm-endpoint wss://example-rpc.com --mnemonic-file "path/to/m
5053
--price-config-file "path/to/price-config-file.yaml" \
5154
[--cooldown-duration 10] \
5255
[--evm-polling-frequency 5]
56+
57+
# Or, run the price pusher docker image instead of building from the source
58+
docker run public.ecr.aws/pyth-network/xc-evm-price-pusher:v<version> -- <above-arguments>
5359
```
5460

5561
### Command Line Arguments
@@ -77,8 +83,6 @@ The program accepts the following command line arguments:
7783
if the RPC is not a Websocket. It has no effect if the RPC is a Websocket.
7884
Default: 5 seconds.
7985

80-
[price feed ids page]: https://pyth.network/developers/price-feed-ids/#pyth-cross-chain-testnet
81-
8286
### Example
8387

8488
For example, to push `BTC/USD` and `BNB/USD` prices on BNB testnet, run the following command:
@@ -91,3 +95,27 @@ npm run start -- --evm-endpoint "https://data-seed-prebsc-1-s1.binance.org:8545"
9195

9296
[`price-config.testnet.sample.yaml`](./price-config.testnet.sample.yaml) contains configuration for `BTC/USD`
9397
and `BNB/USD` price feeds on Pyth testnet.
98+
99+
## Running using a standalone price service (via docker-compose)
100+
101+
EVM price pusher communicates with [Pyth price service][] to get the most recent price updates. Pyth price service listens to the
102+
Wormhole network to get latest price updates, and serves REST and websocket APIs for consumers to fetch the updates.
103+
Pyth hosts public endpoints for the price service; however, it is recommended to run it standalone to achieve more resiliency and
104+
scalability.
105+
106+
This directory contains a sample testnet [docker compose file](./docker-compose.testnet.sample.yaml) that runs a EVM price pusher and all of its dependencies, including a price service and a Wormhole spy. A price service depends on a Wormhole spy. A spy listens to the
107+
Wormhole network and reports all Pyth-related Wormhole messages to the price service.
108+
109+
To run the services via docker-compose, please modify the sample docker-compose file to adjust
110+
the path to your mnemonic file, the path to your price configuration file, the EVM endpoint, and the Pyth contract address
111+
as necessary.
112+
113+
Then, start the docker-compose like this:
114+
115+
```
116+
docker-compose -f docker-compose.testnet.sample.yaml up
117+
```
118+
119+
It will take a few minutes until all the services are up and running.
120+
121+
[pyth price service]: https://github.com/pyth-network/pyth-crosschain/tree/main/third_party/pyth/price-service
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
services:
2+
spy:
3+
image: ghcr.io/certusone/guardiand:v2.8.8.1
4+
command:
5+
- "spy"
6+
- "--nodeKey"
7+
- "/node.key"
8+
- "--spyRPC"
9+
- "[::]:7072"
10+
- "--bootstrap"
11+
- "/dns4/wormhole-testnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWBY9ty9CXLBXGQzMuqkziLntsVcyz4pk1zWaJRvJn6Mmt"
12+
- "--network"
13+
- "/wormhole/testnet/2/1"
14+
- "--logLevel"
15+
- "debug"
16+
price-service:
17+
image: public.ecr.aws/pyth-network/xc-server:v1.0.0
18+
environment:
19+
- SPY_SERVICE_HOST=spy:7072
20+
- SPY_SERVICE_FILTERS=[{"chain_id":1,"emitter_address":"f346195ac02f37d60d4db8ffa6ef74cb1be3550047543a4a9ee9acf4d78697b0"}]
21+
- REST_PORT=4200
22+
- PROM_PORT=8081
23+
- READINESS_SPY_SYNC_TIME_SECONDS=60
24+
- READINESS_NUM_LOADED_SYMBOLS=8
25+
- LOG_LEVEL=debug
26+
healthcheck:
27+
test: ["CMD", "curl", "-f", "http://localhost:4200/ready"]
28+
start_period: 60s
29+
depends_on:
30+
- spy
31+
price-pusher:
32+
build:
33+
context: .
34+
# Uncomment this line (and comment out the above lines) to use a prebuilt image. Replace <version>
35+
# with the latest released image of the EVM price pusher from this repo release page:
36+
# https://github.com/pyth-network/pyth-js/releases
37+
# image: public.ecr.aws/pyth-network/xc-evm-price-pusher:v<version>
38+
restart: always
39+
command:
40+
- "--"
41+
- "--evm-endpoint"
42+
# Replace this with RPC endpoint URL for the EVM network.
43+
- "https://data-seed-prebsc-1-s1.binance.org:8545"
44+
- "--mnemonic-file"
45+
- "/mnemonic"
46+
- "--pyth-contract"
47+
# Replace this with the Pyth contract address. Provide the network name on which Pyth is deployed
48+
# or the Pyth contract address if you use a local network
49+
- "bnb_testnet"
50+
- "--price-endpoint"
51+
- "http://price-service:4200"
52+
- "--price-config-file"
53+
- "/price_config"
54+
configs:
55+
- mnemonic
56+
- price_config
57+
depends_on:
58+
price-service:
59+
condition: service_healthy
60+
configs:
61+
mnemonic:
62+
file: ./path/to/mnemonic.txt # Replace this with the path to the mnemonic file
63+
price_config:
64+
file: ./price-config.testnet.sample.yaml # Replace this with the path to the price configuration file

pyth-evm-price-pusher/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"build": "tsc",
1818
"format": "prettier --write \"src/**/*.ts\"",
1919
"lint": "eslint src/",
20-
"start": "npm run build && node lib/index.js",
20+
"start": "node lib/index.js",
2121
"prepare": "npm run build",
2222
"prepublishOnly": "npm test && npm run lint",
2323
"preversion": "npm run lint",

0 commit comments

Comments
 (0)