Add container to deploy Nitro contracts
This commit is contained in:
parent
0e1861563d
commit
2b06cbecc2
23
app/data/compose/docker-compose-nitro-contracts.yml
Normal file
23
app/data/compose/docker-compose-nitro-contracts.yml
Normal file
@ -0,0 +1,23 @@
|
||||
version: '3.7'
|
||||
|
||||
services:
|
||||
# Deploys the Nitro contracts
|
||||
nitro-contracts:
|
||||
image: cerc/nitro-contracts:local
|
||||
restart: on-failure
|
||||
environment:
|
||||
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
||||
CERC_ETH_RPC_ENDPOINT: ${CERC_ETH_RPC_ENDPOINT:-http://fixturenet-eth-geth-1:8545}
|
||||
CERC_PRIVATE_KEY_DEPLOYER: ${CERC_PRIVATE_KEY_DEPLOYER}
|
||||
CERC_NA_ADDRESS: ${CERC_NA_ADDRESS}
|
||||
CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS}
|
||||
CERC_CA_ADDRESS: ${CERC_CA_ADDRESS}
|
||||
volumes:
|
||||
- ../config/nitro-contracts/deploy.sh:/app/deploy.sh
|
||||
- nitro_deployment:/app/deployment
|
||||
command: ["bash", "-c", "/app/deploy.sh && tail -f"]
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
|
||||
volumes:
|
||||
nitro_deployment:
|
56
app/data/config/nitro-contracts/deploy.sh
Executable file
56
app/data/config/nitro-contracts/deploy.sh
Executable file
@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
NITRO_ADDRESSES_FILE_PATH="/app/deployment/nitro-addresses.json"
|
||||
|
||||
# Check if CERC_NA_ADDRESS environment variable set to skip contract deployment
|
||||
if [ -n "$CERC_NA_ADDRESS" ]; then
|
||||
echo "CERC_NA_ADDRESS is set to '$CERC_NA_ADDRESS'"
|
||||
echo "CERC_VPA_ADDRESS is set to '$CERC_VPA_ADDRESS'"
|
||||
echo "CERC_CA_ADDRESS is set to '$CERC_CA_ADDRESS'"
|
||||
echo "Skipping Nitro contracts deployment"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Check and exit if a deployment already exists (on restarts)
|
||||
if [ -f ${NITRO_ADDRESSES_FILE_PATH} ]; then
|
||||
echo "${NITRO_ADDRESSES_FILE_PATH} already exists, skipping Nitro contracts deployment"
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "Using ETH RPC endpoint ${CERC_ETH_RPC_ENDPOINT}"
|
||||
|
||||
# Wait till ETH RPC endpoint is available
|
||||
retry_interval=5
|
||||
while true; do
|
||||
block_number_hex=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' ${CERC_ETH_RPC_ENDPOINT} | jq -r '.result')
|
||||
|
||||
# Check if the request call was successful
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "RPC endpoint not yet available, retrying in $retry_interval seconds..."
|
||||
sleep $retry_interval
|
||||
continue
|
||||
fi
|
||||
|
||||
# Convert hex to decimal
|
||||
block_number_dec=$(printf %u ${block_number_hex})
|
||||
|
||||
# Check if block number is > 1 to avoid failures in the deployment
|
||||
if [ "$block_number_dec" -ge 1 ]; then
|
||||
echo "RPC endpoint is up"
|
||||
break
|
||||
else
|
||||
echo "RPC endpoint not yet available, retrying in $retry_interval seconds..."
|
||||
sleep $retry_interval
|
||||
continue
|
||||
fi
|
||||
done
|
||||
|
||||
# TODO: Fetch pk from ACCOUNTS_CSV_URL?
|
||||
echo "Using CERC_PRIVATE_KEY_DEPLOYER from env"
|
||||
|
||||
yarn test:deploy-contracts --chainurl ${CERC_ETH_RPC_ENDPOINT} --key ${CERC_PRIVATE_KEY_DEPLOYER} --addressesFilePath ${NITRO_ADDRESSES_FILE_PATH}
|
12
app/data/container-build/cerc-nitro-contracts/Dockerfile
Normal file
12
app/data/container-build/cerc-nitro-contracts/Dockerfile
Normal file
@ -0,0 +1,12 @@
|
||||
FROM node:18.17.1-alpine3.18
|
||||
|
||||
RUN apk --update --no-cache add python3 alpine-sdk bash curl jq
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN echo "Installing dependencies" && \
|
||||
yarn
|
||||
|
||||
WORKDIR /app/packages/nitro-util
|
9
app/data/container-build/cerc-nitro-contracts/build.sh
Executable file
9
app/data/container-build/cerc-nitro-contracts/build.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/nitro-contracts
|
||||
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
# See: https://stackoverflow.com/a/246128/1701505
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
docker build -t cerc/nitro-contracts:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/ts-nitro
|
@ -52,3 +52,4 @@ cerc/sushiswap-subgraphs
|
||||
cerc/webapp-base
|
||||
cerc/watcher-mobymask-v3
|
||||
cerc/go-nitro
|
||||
cerc/nitro-contracts
|
||||
|
@ -38,3 +38,4 @@ fixturenet-sushiswap-subgraph-v3
|
||||
watcher-mobymask-v3
|
||||
mobymask-app-v3
|
||||
go-nitro
|
||||
nitro-contracts
|
||||
|
@ -44,3 +44,4 @@ github.com/cerc-io/sushiswap-v3-periphery
|
||||
github.com/graphprotocol/graph-node
|
||||
github.com/sushiswap/subgraphs
|
||||
github.com/cerc-io/go-nitro
|
||||
github.com/cerc-io/ts-nitro
|
||||
|
@ -7,6 +7,7 @@ repos:
|
||||
- github.com/cerc-io/lighthouse
|
||||
- github.com/cerc-io/ipld-eth-db
|
||||
- github.com/cerc-io/ipld-eth-server
|
||||
- github.com/cerc-io/ts-nitro
|
||||
- github.com/cerc-io/go-nitro@ts-interop
|
||||
containers:
|
||||
# fixturenet images
|
||||
@ -18,9 +19,11 @@ containers:
|
||||
- cerc/fixturenet-eth-lighthouse
|
||||
- cerc/ipld-eth-db
|
||||
- cerc/ipld-eth-server
|
||||
- cerc/nitro-contracts
|
||||
- cerc/go-nitro
|
||||
pods:
|
||||
- fixturenet-eth
|
||||
- ipld-eth-server
|
||||
- ipld-eth-db
|
||||
- nitro-contracts
|
||||
- go-nitro
|
||||
|
Loading…
Reference in New Issue
Block a user