diff --git a/nitro-bridge-demo.md b/nitro-bridge-demo.md index 7bddb26..ad7a89b 100644 --- a/nitro-bridge-demo.md +++ b/nitro-bridge-demo.md @@ -99,6 +99,9 @@ ```bash laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node build-containers --force-rebuild + + # Build nitro-contracts container image + laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-contracts build-containers --force-rebuild ``` - Create a deployment spec-file for Alice's L1 nitro-node: @@ -264,7 +267,7 @@ ```bash export GETH_CHAIN_ID="1212" - export ASSET_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json") + export ASSET_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.TestToken.address' /app/deployment/nitro-addresses.json") export A_CHAIN_ADDRESS="0xe22AD83A0dE117bA0d03d5E94Eb4E0d80a69C62a" export C_CHAIN_ADDRESS="0xf1ac8Dd1f6D6F5c0dA99097c57ebF50CD99Ce293" @@ -276,7 +279,7 @@ # Send tokens to Alice laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "cd packages/nitro-protocol && yarn hardhat transfer --contract $ASSET_ADDRESS --to $A_CHAIN_ADDRESS --amount 1000 --network geth" - #Send tokens to Charlie + # Send tokens to Charlie laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "cd packages/nitro-protocol && yarn hardhat transfer --contract $ASSET_ADDRESS --to $C_CHAIN_ADDRESS --amount 1000 --network geth" ``` @@ -438,7 +441,7 @@ ```bash export BRIDGE_NITRO_ADDRESS=0xBBB676f9cFF8D242e9eaC39D063848807d3D1D94 export GETH_CHAIN_ID="1212" - export ASSET_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json") + export ASSET_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.TestToken.address' /app/deployment/nitro-addresses.json") ``` - Create ledger channel between A and Bridge with custom token diff --git a/nitro-node-demo.md b/nitro-node-demo.md index fcbc205..29e81e8 100644 --- a/nitro-node-demo.md +++ b/nitro-node-demo.md @@ -96,6 +96,9 @@ ```bash laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node build-containers --force-rebuild + + # Build nitro-contracts container image + laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-contracts build-containers --force-rebuild ``` ## Run diff --git a/stack-orchestrator/compose/docker-compose-nitro-contracts.yml b/stack-orchestrator/compose/docker-compose-nitro-contracts.yml index 796357f..b7826a4 100644 --- a/stack-orchestrator/compose/docker-compose-nitro-contracts.yml +++ b/stack-orchestrator/compose/docker-compose-nitro-contracts.yml @@ -3,7 +3,8 @@ name: nitro-contracts services: # Optionally deploys the Nitro contracts nitro-contracts: - image: cerc/nitro-client:local + image: cerc/nitro-contracts:local + working_dir: /app restart: on-failure environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} diff --git a/stack-orchestrator/config/go-nitro/run-bridge.sh b/stack-orchestrator/config/go-nitro/run-bridge.sh index 06dea26..c9dac33 100755 --- a/stack-orchestrator/config/go-nitro/run-bridge.sh +++ b/stack-orchestrator/config/go-nitro/run-bridge.sh @@ -43,4 +43,4 @@ EOF # Start bridge echo "Starting nitro-bridge" -./nitro-bridge -config $bridge_config_file +./bridge -config $bridge_config_file diff --git a/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile b/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile index af75157..46c8179 100644 --- a/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile +++ b/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile @@ -1,29 +1,25 @@ -FROM golang:1.22-bullseye AS builder +FROM ubuntu:latest + +RUN apt-get update +RUN apt-get install -y jq netcat-traditional ca-certificates curl +RUN rm -rf /var/lib/apt/lists/* # Copy files into image WORKDIR /app -COPY . . # Install mkcert RUN curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64" RUN chmod +x mkcert-v*-linux-amd64 RUN cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert -RUN go mod tidy +# Download binaries +RUN curl -LO https://git.vdb.to/cerc-io/nitro/releases/download/latest/nitro +RUN curl -LO https://git.vdb.to/cerc-io/nitro/releases/download/latest/bridge -# Build the binary -RUN go build -v -o nitro . -RUN go build -o nitro-bridge cmd/start-bridge/main.go +# Make binaries executable +RUN chmod +x ./nitro +RUN chmod +x ./bridge - -# Reduce image size -FROM debian:bullseye-slim -RUN apt-get update -RUN apt-get install -y jq netcat ca-certificates -RUN rm -rf /var/lib/apt/lists/* - -WORKDIR /app - -COPY --from=builder /app/nitro . -COPY --from=builder /app/nitro-bridge . -COPY --from=builder /usr/local/bin/mkcert /usr/local/bin/mkcert +# Verify that binaries are correctly setup +RUN ./nitro help +RUN ./bridge help diff --git a/stack-orchestrator/container-build/cerc-nitro-client/Dockerfile b/stack-orchestrator/container-build/cerc-nitro-client/Dockerfile index 77bc6c8..50bca80 100644 --- a/stack-orchestrator/container-build/cerc-nitro-client/Dockerfile +++ b/stack-orchestrator/container-build/cerc-nitro-client/Dockerfile @@ -4,10 +4,7 @@ RUN apk --update --no-cache add python3 alpine-sdk bash curl jq WORKDIR /app -COPY . . - -RUN echo "Installing dependencies" && \ - yarn && yarn build +RUN npm config set @cerc-io:registry https://git.vdb.to/api/packages/cerc-io/npm/ RUN echo "Installing nitro-rpc-client" && \ - npm install -g ./packages/nitro-rpc-client + npm install -g @cerc-io/nitro-rpc-client diff --git a/stack-orchestrator/container-build/cerc-nitro-contracts/Dockerfile b/stack-orchestrator/container-build/cerc-nitro-contracts/Dockerfile new file mode 100644 index 0000000..5fe2df7 --- /dev/null +++ b/stack-orchestrator/container-build/cerc-nitro-contracts/Dockerfile @@ -0,0 +1,10 @@ +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 && yarn build diff --git a/stack-orchestrator/container-build/cerc-nitro-contracts/build.sh b/stack-orchestrator/container-build/cerc-nitro-contracts/build.sh new file mode 100755 index 0000000..e70c7d0 --- /dev/null +++ b/stack-orchestrator/container-build/cerc-nitro-contracts/build.sh @@ -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}/go-nitro diff --git a/stack-orchestrator/stacks/bridge/README.md b/stack-orchestrator/stacks/bridge/README.md index c46d0c2..1baa9ba 100644 --- a/stack-orchestrator/stacks/bridge/README.md +++ b/stack-orchestrator/stacks/bridge/README.md @@ -8,12 +8,6 @@ laconic-so fetch-stack git.vdb.to/cerc-io/nitro-stack ``` -- Clone required repositories: - - ```bash - laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge setup-repositories - ``` - - Build container images: ```bash diff --git a/stack-orchestrator/stacks/bridge/stack.yml b/stack-orchestrator/stacks/bridge/stack.yml index a162378..008c1b0 100644 --- a/stack-orchestrator/stacks/bridge/stack.yml +++ b/stack-orchestrator/stacks/bridge/stack.yml @@ -2,10 +2,9 @@ version: "1.0" name: bridge description: "Nitro bridge with contracts deployment and nitro-rpc-client" repos: - - github.com/cerc-io/go-nitro containers: - - cerc/nitro-client - cerc/go-nitro + - cerc/nitro-client pods: - nitro-bridge - nitro-rpc-client diff --git a/stack-orchestrator/stacks/nitro-contracts/README.md b/stack-orchestrator/stacks/nitro-contracts/README.md index 8dc0e92..352b0f2 100644 --- a/stack-orchestrator/stacks/nitro-contracts/README.md +++ b/stack-orchestrator/stacks/nitro-contracts/README.md @@ -11,8 +11,9 @@ - Clone required repositories: ```bash - laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-contracts setup-repositories + laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-contracts setup-repositories --git-ssh --pull ``` + Make sure you have access to the `go-nitro` repository - Build container images: diff --git a/stack-orchestrator/stacks/nitro-contracts/stack.yml b/stack-orchestrator/stacks/nitro-contracts/stack.yml index ece621d..4938465 100644 --- a/stack-orchestrator/stacks/nitro-contracts/stack.yml +++ b/stack-orchestrator/stacks/nitro-contracts/stack.yml @@ -4,6 +4,6 @@ description: "Deploy nitro contracts" repos: - github.com/cerc-io/go-nitro containers: - - cerc/nitro-client + - cerc/nitro-contracts pods: - nitro-contracts diff --git a/stack-orchestrator/stacks/nitro-node/README.md b/stack-orchestrator/stacks/nitro-node/README.md index f813c07..5d71018 100644 --- a/stack-orchestrator/stacks/nitro-node/README.md +++ b/stack-orchestrator/stacks/nitro-node/README.md @@ -8,14 +8,6 @@ laconic-so fetch-stack git.vdb.to/cerc-io/nitro-stack ``` -- Clone required repositories - - ```bash - laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node setup-repositories - ``` - - Note: Replace path to nitro stack with actual path - - Build the container image ```bash diff --git a/stack-orchestrator/stacks/nitro-node/stack.yml b/stack-orchestrator/stacks/nitro-node/stack.yml index 2b1fb80..ed078b0 100644 --- a/stack-orchestrator/stacks/nitro-node/stack.yml +++ b/stack-orchestrator/stacks/nitro-node/stack.yml @@ -2,7 +2,6 @@ version: "1.0" name: nitro-node description: "Nitro node with nitro-rpc-client" repos: - - github.com/cerc-io/go-nitro containers: - cerc/go-nitro - cerc/nitro-client