Skip to content

Commit

Permalink
chore: update docker setup
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Sep 25, 2023
1 parent ce63b7e commit 2e23afa
Show file tree
Hide file tree
Showing 12 changed files with 2,538 additions and 2,285 deletions.
31 changes: 19 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,25 @@ jobs:
- name: Run Matchstick tests
run: yarn test

# integration-test:
# runs-on: ubuntu-20.04
# steps:
# - name: Checkout
# uses: actions/checkout@v2
integration-test:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2

# - name: Start containers
# run: docker-compose up -d --build
- name: Start containers
run: docker-compose up -d

# - name: Run integration tests
# run: docker exec -i subgraph-hardhat-node yarn workspace isolated-pools-subgraph run test:integration
- name: Generate graphql types
run: |
docker exec -i subgraph-hardhat-node yarn workspace isolated-pools-subgraph run generate-subgraph-types
- name: Run integration tests
run: |
docker exec -i subgraph-hardhat-node yarn workspace isolated-pools-subgraph run test:integration
# - name: Stop containers
# if: always()
# run: docker-compose down -v
- name: Stop containers
if: always()
run: |
docker-compose down -v
docker system prune -f -a --volumes
3 changes: 2 additions & 1 deletion Dockerfile.hardhat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16.14.2-alpine3.14
FROM node:18-alpine3.17

RUN apk add g++ make py3-pip git openssh;

Expand All @@ -11,6 +11,7 @@ COPY package.json /usr/app/package.json
COPY yarn.lock /usr/app/yarn.lock
COPY .yarn /usr/app/.yarn
COPY .yarnrc.yml /usr/app/.yarnrc.yml
COPY mocks /usr/app/mocks
COPY copy_contracts.sh /usr/app/copy_contracts.sh

WORKDIR /usr/app
Expand Down
19 changes: 12 additions & 7 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
version: '3'
services:
graph-node:
image: graphprotocol/graph-node:v0.29.0
image: graphprotocol/graph-node:v0.32.0
ports:
- 8000:8000
- 8001:8001
- 8020:8020
- 8030:8030
- 8040:8040
depends_on:
- hardhat
- ipfs
- postgres
hardhat:
condition: service_healthy
ipfs:
condition: service_started
postgres:
condition: service_started
environment:
postgres_host: postgres
postgres_user: graph-node
postgres_pass: let-me-in
postgres_db: graph-node
ipfs: ipfs:5001
ethereum: hardhat:archive,full:http://hardhat:8545
ethereum: hardhat:http://hardhat:8545
hardhat:
container_name: subgraph-hardhat-node
build:
Expand All @@ -30,7 +33,8 @@ services:
- sh
- -c
- |
PACKAGE=isolated-pools yarn workspace isolated-pools-subgraph run hardhat node --hostname 0.0.0.0
yarn &&PACKAGE=isolated-pools yarn workspace isolated-pools-subgraph run hardhat node --hostname 0.0.0.0
# Installing again to link workspaces
ports:
- 8545:8545
volumes:
Expand Down Expand Up @@ -58,4 +62,5 @@ services:
environment:
POSTGRES_USER: graph-node
POSTGRES_PASSWORD: let-me-in
POSTGRES_DB: graph-node
POSTGRES_DB: graph-node
POSTGRES_INITDB_ARGS: '--encoding=UTF-8 --lc-collate=C --lc-ctype=C'
2 changes: 1 addition & 1 deletion hardhat-healthcheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
async function healthCheck() {
const ethers = require('ethers');
const localProvider = new ethers.providers.JsonRpcProvider(`http://localhost:8545`)
const localProvider = new ethers.providers.JsonRpcProvider(`http://hardhat:8545`)
localBlockNum = await localProvider.getBlockNumber();
}

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@
"@typechain/hardhat": "^6.1.2",
"@types/mocha": "^9.1.1",
"@types/mustache": "^4.2.1",
"@types/node": "^20.6.0",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/parser": "^5.40.1",
"@venusprotocol/governance-contracts": "^1.0.0",
"@venusprotocol/isolated-pools": "1.0.0",
"@venusprotocol/oracle": "^1.7.2",
"@venusprotocol/venus-protocol": "^0.6.0",
"@venusprotocol/venus-protocol": "0.6.0",
"assemblyscript": "0.19.23",
"chai": "^4.3.6",
"eslint": "^8.25.0",
Expand Down
8 changes: 3 additions & 5 deletions packages/utils/src/subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ export const exec = (cmd: string, srcDir: string) => {

// Subgraph Support
export const fetchSubgraphs = createApolloFetch({
uri: process.env.LOCAL ? 'http://127.0.0.1:8030/graphql' : 'http://graph-node:8030/graphql',
uri: 'http://graph-node:8030/graphql',
});

export const fetchSubgraph = (subgraphUser: string, subgraphName: string) => {
return createApolloFetch({
uri: process.env.LOCAL
? `http://127.0.0.1:8000/subgraphs/name/${subgraphUser}/${subgraphName}`
: `http://graph-node:8000/subgraphs/name/${subgraphUser}/${subgraphName}`,
uri: `http://graph-node:8000/subgraphs/name/${subgraphUser}/${subgraphName}`,
});
};

Expand Down Expand Up @@ -102,7 +100,7 @@ export const deploy = async ({
exec(`yarn workspace ${packageName} run build:local`, root);
exec(`yarn workspace ${packageName} run create:local`, root);
exec(
`npx graph deploy ${subgraphAccount}/${subgraphName} --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020/ --version-label ${Date.now().toString()}`,
`npx graph deploy ${subgraphAccount}/${subgraphName} --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020/ --version-label ${Date.now().toString()}`,
root,
);
await waitForSubgraphToBeSynced(syncDelay);
Expand Down
13 changes: 7 additions & 6 deletions subgraphs/isolated-pools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
"create:docker": "npx graph create venusprotocol/venus-isolated-pools --node http://graph-node:8020/",
"build:docker": "npx graph build --ipfs http://ipfs:5001",
"build:bsc": "npx graph build --ipfs https://api.thegraph.com/ipfs/ ",
"deploy:local": "LOCAL=true npx mustache config/local.json template.yaml > subgraph.yaml && npx graph deploy venusprotocol/venus-isolated-pools --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020/",
"deploy:docker": "npx mustache config/local.json template.yaml > subgraph.yaml && npx graph deploy venusprotocol/venus-isolated-pools --debug --ipfs http://ipfs:5001 --node http://graph-node:8020/",
"deploy:chapel": "npx mustache config/chapel.json template.yaml > subgraph.yaml && npx graph deploy venusprotocol/venus-isolated-pools-chapel --debug --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:bsc": "npx mustache config/bsc.json template.yaml > subgraph.yaml && npx graph deploy venusprotocol/venus-isolated-pools --debug --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:sepolia": "yarn prepare:sepolia && npx graph deploy --studio venus-isolated-pools-sepolia",
"deploy:local": "LOCAL=true npx mustache config/local.json template.yaml > subgraph.yaml && npx graph deploy venusprotocol/venus-isolated-pools --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020/",
"deploy:docker": "npx mustache config/local.json template.yaml > subgraph.yaml && npx graph deploy venusprotocol/venus-isolated-pools --ipfs http://ipfs:5001 --node http://graph-node:8020/",
"deploy:chapel": "npx mustache config/chapel.json template.yaml > subgraph.yaml && npx graph deploy venusprotocol/venus-isolated-pools-chapel --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:bsc": "npx mustache config/bsc.json template.yaml > subgraph.yaml && npx graph deploy venusprotocol/venus-isolated-pools --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:sepolia": "npx prepare:sepolia && npx graph deploy --studio venus-isolated-pools-sepolia",
"prepare:local": "npx mustache config/local.json template.yaml > subgraph.yaml && npx mustache config/local.json src/constants/config-template > src/constants/config.ts",
"prepare:docker": "npx mustache config/local.json template.yaml > subgraph.yaml && npx mustache config/local.json src/constants/config-template > src/constants/config.ts",
"prepare:chapel": "npx mustache config/chapel.json template.yaml > subgraph.yaml && npx mustache config/chapel.json src/constants/config-template > src/constants/config.ts",
"prepare:bsc": "npx mustache config/bsc.json template.yaml > subgraph.yaml && npx mustache config/bsc.json src/constants/config-template > src/constants/config.ts",
"prepare:sepolia": "npx mustache config/sepolia.json template.yaml > subgraph.yaml && npx mustache config/sepolia.json src/constants/config-template > src/constants/config.ts",
Expand All @@ -30,7 +31,7 @@
"generate-subgraph-types": "rm -rf /subgraph-client/.graphclient && yarn graphclient build --dir ./subgraph-client",
"pretty": "prettier —-write '**/*.ts'",
"test": "yarn prepare:local && graph test",
"node:integration": "PACKAGE=isolated-pools hardhat node",
"node:integration": "PACKAGE=isolated-pools hardhat node --hostname 0.0.0.0",
"test:integration": "PACKAGE=isolated-pools hardhat test tests/integration/index.ts --network localhost"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sources:
- name: isolated-pools-subgraph
handler:
graphql:
endpoint: http://127.0.0.1:8000/subgraphs/name/venusprotocol/venus-isolated-pools
endpoint: http://graph-node:8000/subgraphs/name/venusprotocol/venus-isolated-pools

documents:
- '../**/*.graphql'
2 changes: 1 addition & 1 deletion subgraphs/isolated-pools/subgraph-client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@ class SubgraphClient {
}

export default new SubgraphClient(
'http://127.0.0.1:8000/subgraphs/name/venusprotocol/venus-isolated-pools',
'http://graph-node:8000/subgraphs/name/venusprotocol/venus-isolated-pools',
);
8 changes: 4 additions & 4 deletions subgraphs/isolated-pools/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dataSources:
- name: VToken
file: ../../node_modules/@venusprotocol/isolated-pools/artifacts/contracts/VToken.sol/VToken.json
- name: PriceOracle
file: ../../node_modules/@venusprotocol/oracle/artifacts/contracts/PriceOracle.sol/PriceOracle.json
file: ../../node_modules/@venusprotocol/oracle/artifacts/contracts/ResilientOracle.sol/ResilientOracle.json
- name: BEP20
file: ../../packages/isolated-pools-abis/Bep20.json
- name: PoolLens
Expand Down Expand Up @@ -72,7 +72,7 @@ templates:
- name: PoolLens
file: ../../node_modules/@venusprotocol/isolated-pools/artifacts/contracts/Lens/PoolLens.sol/PoolLens.json
- name: PriceOracle
file: ../../node_modules/@venusprotocol/oracle/artifacts/contracts/PriceOracle.sol/PriceOracle.json
file: ../../node_modules/@venusprotocol/oracle/artifacts/contracts/ResilientOracle.sol/ResilientOracle.json
- name: RewardsDistributor
file: ../../node_modules/@venusprotocol/isolated-pools/artifacts/contracts/Rewards/RewardsDistributor.sol/RewardsDistributor.json
eventHandlers:
Expand All @@ -98,7 +98,7 @@ templates:
handler: handleNewMinLiquidatableCollateral
- event: NewSupplyCap(indexed address,uint256)
handler: handleNewSupplyCap
- event: NewRewardsDistributor(indexed address)
- event: NewRewardsDistributor(indexed address,indexed address)
handler: handleNewRewardsDistributor
- name: VToken
kind: ethereum/contract
Expand All @@ -118,7 +118,7 @@ templates:
- name: VToken
file: ../../node_modules/@venusprotocol/isolated-pools/artifacts/contracts/VToken.sol/VToken.json
- name: PriceOracle
file: ../../node_modules/@venusprotocol/oracle/artifacts/contracts/PriceOracle.sol/PriceOracle.json
file: ../../node_modules/@venusprotocol/oracle/artifacts/contracts/ResilientOracle.sol/ResilientOracle.json
- name: BEP20
file: ../../packages/isolated-pools-abis/Bep20.json
- name: Comptroller
Expand Down
14 changes: 8 additions & 6 deletions subgraphs/isolated-pools/tests/integration/utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { exec, fetchSubgraph, waitForSubgraphToBeSynced } from 'venus-subgraph-u
import { SUBGRAPH_ACCOUNT, SUBGRAPH_NAME, SYNC_DELAY } from '../constants';

const deploy = async () => {
const root = `${__dirname}/../../..`;
const env = process.env.LOCAL ? 'local' : 'docker';
const root = __dirname;
const env = process.env.LOCAL ? ('local' as const) : ('docker' as const);

// Create Subgraph Connection
const subgraph = fetchSubgraph(SUBGRAPH_ACCOUNT, SUBGRAPH_NAME);
Expand All @@ -15,11 +15,13 @@ const deploy = async () => {
exec(`yarn workspace isolated-pools-subgraph run codegen`, root);
exec(`yarn workspace isolated-pools-subgraph run build:${env}`, root);
exec(`yarn workspace isolated-pools-subgraph run create:${env}`, root);
const deployCmd = process.env.LOCAL
? `npx graph deploy ${SUBGRAPH_ACCOUNT}/${SUBGRAPH_NAME} --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020/ --version-label ${Date.now().toString()}`
: `npx graph deploy ${SUBGRAPH_ACCOUNT}/${SUBGRAPH_NAME} --debug --ipfs http://ipfs:5001 --node http://graph-node:8020/ --version-label ${Date.now().toString()}`;

const deployCmd =
env === 'local'
? `npx graph deploy ${SUBGRAPH_ACCOUNT}/${SUBGRAPH_NAME} --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020/ --version-label ${Date.now().toString()}`
: `npx graph deploy ${SUBGRAPH_ACCOUNT}/${SUBGRAPH_NAME} --ipfs http://ipfs:5001 --node http://graph-node:8020/ --version-label ${Date.now().toString()}`;
exec(deployCmd, root);
exec(`echo "" | yarn workspace isolated-pools-subgraph deploy:${env}`, __dirname);

await waitForSubgraphToBeSynced(SYNC_DELAY);
return { subgraph };
};
Expand Down
Loading

0 comments on commit 2e23afa

Please sign in to comment.