From 5c4945cafb82f034a139154bb27952a720d8404a Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 17 Oct 2023 17:55:42 +0530 Subject: [PATCH] Update setup for external go-nitro node --- app/data/compose/docker-compose-go-nitro.yml | 26 +++++++------------ ...ocker-compose-ipld-eth-server-payments.yml | 3 ++- app/data/config/go-nitro/run-nitro-node.sh | 2 +- app/data/config/ipld-eth-server/entrypoint.sh | 2 ++ .../container-build/cerc-go-nitro/Dockerfile | 16 ++++++++++++ .../container-build/cerc-go-nitro/build.sh | 4 ++- app/data/stacks/fixturenet-payments/stack.yml | 10 ++++--- 7 files changed, 40 insertions(+), 23 deletions(-) create mode 100644 app/data/container-build/cerc-go-nitro/Dockerfile diff --git a/app/data/compose/docker-compose-go-nitro.yml b/app/data/compose/docker-compose-go-nitro.yml index 69b3afc8..f10c861b 100644 --- a/app/data/compose/docker-compose-go-nitro.yml +++ b/app/data/compose/docker-compose-go-nitro.yml @@ -11,10 +11,13 @@ services: condition: service_completed_successfully environment: CERC_NITRO_CHAIN_URL: ${CERC_NITRO_CHAIN_URL:-ws://fixturenet-eth-geth-1:8546} - CERC_NITRO_PK: ${CERC_NITRO_PK:-2d999770f7b5d49b694080f987b82bbc9fc9ac2b4dcc10b0f8aba7d700f69c6d} - CERC_NITRO_CHAIN_PK: ${CERC_NITRO_CHAIN_PK:-570b909da9669b2f35a0b1ac70b8358516d55ae1b5b3710e95e9a94395090597} + CERC_NITRO_PK: ${CERC_NITRO_PK:-febb3b74b0b52d0976f6571d555f4ac8b91c308dfa25c7b58d1e6a7c3f50c781} + CERC_NITRO_CHAIN_PK: ${CERC_NITRO_CHAIN_PK:-be4aa664815ea3bc3d63118649a733f6c96b243744310806ecb6d96359ab62cf} CERC_NITRO_USE_DURABLE_STORE: ${CERC_NITRO_USE_DURABLE_STORE:-true} CERC_NITRO_DURABLE_STORE_FOLDER: ${CERC_NITRO_DURABLE_STORE_FOLDER:-/app/data/nitro-store} + CERC_NITRO_MSG_PORT: ${CERC_NITRO_MSG_PORT:-3006} + CERC_NITRO_WS_MSG_PORT: ${CERC_NITRO_WS_MSG_PORT:-5006} + CERC_NITRO_RPC_PORT: ${CERC_NITRO_RPC_PORT:-4006} CERC_NA_ADDRESS: ${CERC_NA_ADDRESS} CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS} CERC_CA_ADDRESS: ${CERC_CA_ADDRESS} @@ -23,26 +26,17 @@ services: - go_nitro_data:/app/data - nitro_deployment:/app/deployment - ../config/go-nitro/run-nitro-node.sh:/app/run-nitro-node.sh + - ../config/go-nitro/tls:/app/tls healthcheck: - test: ["CMD", "nc", "-vz", "localhost", "4005"] + test: ["CMD", "nc", "-vz", "localhost", "4006"] interval: 10s timeout: 5s retries: 10 start_period: 10s ports: - - "3005" - - "4005:4005" - - "5005:5005" - - nitro-rpc-client: - image: cerc/nitro-rpc-client:local - hostname: nitro-rpc-client - restart: on-failure - depends_on: - # Wait for the go-nitro node to start - go-nitro: - condition: service_healthy - command: ["bash", "-c", "tail -f /dev/null"] + - "3006:3006" + - "4006:4006" + - "5006:5006" volumes: go_nitro_data: diff --git a/app/data/compose/docker-compose-ipld-eth-server-payments.yml b/app/data/compose/docker-compose-ipld-eth-server-payments.yml index d80e88f0..50af67dc 100644 --- a/app/data/compose/docker-compose-ipld-eth-server-payments.yml +++ b/app/data/compose/docker-compose-ipld-eth-server-payments.yml @@ -44,12 +44,13 @@ services: - eth_server_nitro_data:/app/nitro-data - nitro_deployment:/app/deployment - ../config/ipld-eth-server/entrypoint.sh:/app/entrypoint.sh + - ../config/go-nitro/tls:/app/nitroTLS ports: - "8081" - "8082" - "8090" - "40000" - - "3005" + - "3005:3005" - "4005:4005" - "5005:5005" healthcheck: diff --git a/app/data/config/go-nitro/run-nitro-node.sh b/app/data/config/go-nitro/run-nitro-node.sh index 546e9448..5849c3d0 100755 --- a/app/data/config/go-nitro/run-nitro-node.sh +++ b/app/data/config/go-nitro/run-nitro-node.sh @@ -47,4 +47,4 @@ while true; do sleep $retry_interval done -./nitro -chainurl ${CERC_NITRO_CHAIN_URL} -msgport 3005 -rpcport 4005 -wsmsgport 5005 -pk ${CERC_NITRO_PK} -chainpk ${CERC_NITRO_CHAIN_PK} -naaddress ${NA_ADDRESS} -vpaaddress ${VPA_ADDRESS} -caaddress ${CA_ADDRESS} -usedurablestore ${CERC_NITRO_USE_DURABLE_STORE} -durablestorefolder ${CERC_NITRO_DURABLE_STORE_FOLDER} +./nitro -chainurl ${CERC_NITRO_CHAIN_URL} -msgport ${CERC_NITRO_MSG_PORT} -rpcport ${CERC_NITRO_RPC_PORT} -wsmsgport ${CERC_NITRO_WS_MSG_PORT} -pk ${CERC_NITRO_PK} -chainpk ${CERC_NITRO_CHAIN_PK} -naaddress ${NA_ADDRESS} -vpaaddress ${VPA_ADDRESS} -caaddress ${CA_ADDRESS} -usedurablestore ${CERC_NITRO_USE_DURABLE_STORE} -durablestorefolder ${CERC_NITRO_DURABLE_STORE_FOLDER} -publicip "0.0.0.0" diff --git a/app/data/config/ipld-eth-server/entrypoint.sh b/app/data/config/ipld-eth-server/entrypoint.sh index effe9dee..55cfddce 100755 --- a/app/data/config/ipld-eth-server/entrypoint.sh +++ b/app/data/config/ipld-eth-server/entrypoint.sh @@ -31,6 +31,8 @@ else done fi +# TODO: Wait for chain endpoint + echo "Beginning the ipld-eth-server process" START_CMD="./ipld-eth-server" diff --git a/app/data/container-build/cerc-go-nitro/Dockerfile b/app/data/container-build/cerc-go-nitro/Dockerfile new file mode 100644 index 00000000..1d0e31b4 --- /dev/null +++ b/app/data/container-build/cerc-go-nitro/Dockerfile @@ -0,0 +1,16 @@ +FROM golang:1.21-bullseye AS builder + +# Copy files into image +WORKDIR /app +COPY . . + +# Build the binary +RUN go build -v -o nitro . + +# Reduce image size +FROM debian:bullseye-slim +RUN apt-get update +RUN apt-get install -y ca-certificates jq netcat +RUN rm -rf /var/lib/apt/lists/* +WORKDIR /app +COPY --from=builder /app/nitro . diff --git a/app/data/container-build/cerc-go-nitro/build.sh b/app/data/container-build/cerc-go-nitro/build.sh index 0637f46d..28bdde44 100755 --- a/app/data/container-build/cerc-go-nitro/build.sh +++ b/app/data/container-build/cerc-go-nitro/build.sh @@ -3,4 +3,6 @@ source ${CERC_CONTAINER_BASE_DIR}/build-base.sh -docker build -t cerc/go-nitro:local -f ${CERC_REPO_BASE_DIR}/go-nitro/docker/local/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/go-nitro +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +docker build -t cerc/go-nitro:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/go-nitro diff --git a/app/data/stacks/fixturenet-payments/stack.yml b/app/data/stacks/fixturenet-payments/stack.yml index 14aba43b..15c2264d 100644 --- a/app/data/stacks/fixturenet-payments/stack.yml +++ b/app/data/stacks/fixturenet-payments/stack.yml @@ -7,10 +7,12 @@ repos: - git.vdb.to/cerc-io/lighthouse - git.vdb.to/cerc-io/ipld-eth-db@v5 # ipld-eth-server with payments -- to be used by ipld-eth-server-payments pod - - git.vdb.to/cerc-io/ipld-eth-server@payments + # - git.vdb.to/cerc-io/ipld-eth-server@payments + - git.vdb.to/deep-stack/ipld-eth-server@pm-external-nitro-node # TODO: Use payments branch after merging # nitro repo - github.com/cerc-io/ts-nitro@v0.1.13 - - github.com/cerc-io/go-nitro@v0.1.1-ts-port-0.1.7 + # - github.com/cerc-io/go-nitro@v0.1.1-ts-port-0.1.7 + - github.com/deep-stack/go-nitro@nv-validate-voucher # TODO: Use release # mobymask watcher repos - github.com/cerc-io/watcher-ts@v0.2.65 - github.com/cerc-io/mobymask-v2-watcher-ts@v0.2.3 @@ -31,7 +33,7 @@ containers: - cerc/ipld-eth-db - cerc/ipld-eth-server - cerc/nitro-contracts - # - cerc/go-nitro + - cerc/go-nitro - cerc/nitro-rpc-client # mobymask watcher images - cerc/watcher-ts @@ -47,7 +49,7 @@ pods: - ipld-eth-server-payments - ipld-eth-db - nitro-contracts - # - go-nitro + - go-nitro - nitro-rpc-client - watcher-mobymask-v3 - mobymask-snap