Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Add dockerfile and update docker compose to start ensonet container
Browse files Browse the repository at this point in the history
  • Loading branch information
imbenwolf committed Mar 23, 2022
1 parent d655fc9 commit ca92921
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 11 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
build
generated
.env

# Ignore the files generated by templates
subgraph.yaml
src/addresses.ts
data
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INFURA_API_KEY=
MNEMONIC=
ARCHIVE_NODE=
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
build
generated
.env

# Ignore the files generated by templates
subgraph.yaml
Expand Down
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:16-alpine

# Add system dependencies
RUN apk add libsecret-dev bash git curl

# Copy the source files into the image
WORKDIR /app
COPY . .

# Download dependencies
RUN yarn --frozen-lockfile

CMD ["sh", "-c", "yarn prepare ensonet && yarn build:graph && yarn deploy:local"]
51 changes: 43 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
version: '3'
volumes:
node_modules:
services:
deploy-subgraph:
build: .
image: deploy-subgraph
volumes:
- .:/app
- node_modules:/app/node_modules
depends_on:
graph-node:
condition: service_started

ensonet:
image: ensonet
ports:
- 3000:3000
environment:
- INFURA_API_KEY=${INFURA_API_KEY}
- MNEMONIC=${MNEMONIC}
- ARCHIVE_NODE=${ARCHIVE_NODE}
- LOG=quiet
secrets:
- ssh_key
healthcheck:
test: "wget -q localhost:3000/api/deployments -O - | grep v1-core"
interval: "10s"
timeout: "15s"
start_period: "3m"
retries: 24

graph-node:
image: graphprotocol/graph-node:v0.24.0
ports:
Expand All @@ -9,24 +39,27 @@ services:
- '8030:8030'
- '8040:8040'
depends_on:
- ipfs
- postgres
ipfs:
condition: service_started
postgres:
condition: service_started
ensonet:
condition: service_healthy
environment:
postgres_host: postgres
postgres_user: graph-node
postgres_pass: let-me-in
postgres_db: graph-node
postgres_db: graph-node
ipfs: 'ipfs:5001'
ethereum: 'mainnet:http://18.223.196.75:8545'
ethereum: 'mainnet:http://ensonet:3000'
GRAPH_LOG: info
GRAPH_ALLOW_NON_DETERMINISTIC_FULLTEXT_SEARCH: 1

ipfs:
image: ipfs/go-ipfs:v0.4.23
ports:
- '5001:5001'
volumes:
- ./data/ipfs:/data/ipfs

postgres:
image: postgres
ports:
Expand All @@ -36,5 +69,7 @@ services:
POSTGRES_USER: graph-node
POSTGRES_PASSWORD: let-me-in
POSTGRES_DB: graph-node
volumes:
- ./data/postgres:/var/lib/postgresql/data

secrets:
ssh_key:
file: ~/.ssh/ensonet
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"prepare": "./scripts/build-manifest.sh",
"build:graph": "graph codegen && graph build",
"deploy:local": "graph remove --node http://127.0.0.1:8020 ensofinance/enso-v1 && graph create --node http://127.0.0.1:8020 ensofinance/enso-v1 && graph deploy --node http://127.0.0.1:8020/ --ipfs http://127.0.0.1:5001 ensofinance/enso-v1",
"deploy:local": "graph remove --node http://graph-node:8020 ensofinance/enso-v1 && graph create --node http://graph-node:8020 ensofinance/enso-v1 && graph deploy --node http://graph-node:8020/ --ipfs http://ipfs:5001 ensofinance/enso-v1",
"deploy:remote": "graph remove --node http://$DOCKHERO_HOST:8020 ensofinance/enso-v1 && graph create --node http://$DOCKHERO_HOST:8020 ensofinance/enso-v1 && graph deploy --node http://$DOCKHERO_HOST:8020 --ipfs http://$DOCKHERO_HOST:5001 ensofinance/enso-v1",
"deploy:kovan": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ ensofinance/enso-v1"
},
Expand Down
4 changes: 2 additions & 2 deletions scripts/build-manifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ if [[ "$NETWORK" == "local" ]]; then
fi

if [[ "$NETWORK" == "ensonet" ]]; then
REMOTE_BLOCK=$(curl -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"eth_blockNumber","id":1}' http://127.0.0.1:3000 | node_modules/node-jq/bin/jq ".result" | tr -d '"')
ENSONET_DEPLOYMENTS=$(curl http://127.0.0.1:3000/api/deployments)
REMOTE_BLOCK=$(curl -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"eth_blockNumber","id":1}' http://ensonet:3000 | node_modules/node-jq/bin/jq ".result" | tr -d '"')
ENSONET_DEPLOYMENTS=$(curl http://ensonet:3000/api/deployments)
echo $ENSONET_DEPLOYMENTS | node_modules/node-jq/bin/jq '."v1-core" + {"network":"mainnet","ChainlinkFeedRegistry":"0x47Fb2585D2C56Fe188D0E6ec628a38b74fCeeeDf","blockNumber":'$(($REMOTE_BLOCK))'}' | node_modules/.bin/mustache - templates/subgraph.template.yaml > subgraph.yaml
echo $ENSONET_DEPLOYMENTS | node_modules/node-jq/bin/jq '."v1-core" + {"ChainlinkFeedRegistry":"0x47Fb2585D2C56Fe188D0E6ec628a38b74fCeeeDf"}' | node_modules/.bin/mustache - templates/addresses.ts > src/addresses.ts
fi
Expand Down

0 comments on commit ca92921

Please sign in to comment.