From ec02226eb055c5725391a08c3bacf6bd5b793382 Mon Sep 17 00:00:00 2001 From: ryardley Date: Wed, 11 Dec 2024 20:40:00 +1100 Subject: [PATCH] Update env vars --- .deploy/.env.example | 20 +++++++++---------- .deploy/agg.yaml | 4 ++-- .deploy/cn2.yaml | 4 ++-- .deploy/cn3.yaml | 4 ++-- .deploy/deploy.sh | 13 ++++++++++++ .deploy/docker-compose.yml | 28 ++++++++++++++++++-------- .deploy/run.sh | 5 ----- .deploy/swarm_deployment.md | 40 +++++++++++++++++++++++++++++++++++-- 8 files changed, 87 insertions(+), 31 deletions(-) create mode 100755 .deploy/deploy.sh delete mode 100755 .deploy/run.sh diff --git a/.deploy/.env.example b/.deploy/.env.example index 4d2b4940..95786950 100644 --- a/.deploy/.env.example +++ b/.deploy/.env.example @@ -1,11 +1,11 @@ -export TAG=20241210-44aac5b0 -export AGG_ADDRESS="0x8626a6940E2eb28930eFb4CeF49B2d1F2C9C1199" -export CN1_ADDRESS="0xbDA5747bFD65F08deb54cb465eB87D40e51B197E" -export CN2_ADDRESS="0xdD2FD4581271e230360230F9337D5c0430Bf44C0" -export CN3_ADDRESS="0x2546BcD3c84621e976D8185a91A922aE77ECEc30" +TAG=20241210-44aac5b0 +AGG_ADDRESS=0x8626a6940E2eb28930eFb4CeF49B2d1F2C9C1199 +CN1_ADDRESS=0xbDA5747bFD65F08deb54cb465eB87D40e51B197E +CN2_ADDRESS=0xdD2FD4581271e230360230F9337D5c0430Bf44C0 +CN3_ADDRESS=0x2546BcD3c84621e976D8185a91A922aE77ECEc30 -export CN1_QUIC_PORT=9091 -export CN2_QUIC_PORT=9092 -export CN3_QUIC_PORT=9093 -export AGG_QUIC_PORT=9094 -export RPC_URL=wss://eth-sepolia.g.alchemy.com/v2/API_KEY +RPC_URL=wss://eth-sepolia.g.alchemy.com/v2/API_KEY + +SEPOLIA_ENCLAVE_ADDRESS=0xCe087F31e20E2F76b6544A2E4A74D4557C8fDf77 +SEPOLIA_CIPHERNODE_REGISTRY_ADDRESS=0x0952388f6028a9Eda93a5041a3B216Ea331d97Ab +SEPOLIA_FILTER_REGISTRY=0xcBaCE7C360b606bb554345b20884A28e41436934 diff --git a/.deploy/agg.yaml b/.deploy/agg.yaml index e41b6d79..064cf8c7 100644 --- a/.deploy/agg.yaml +++ b/.deploy/agg.yaml @@ -1,5 +1,5 @@ -address: "${AGG_ADDRESS}" -quic_port: ${AGG_QUIC_PORT} +address: "${ADDRESS}" +quic_port: ${QUIC_PORT} enable_mdns: false chains: - name: "sepolia" diff --git a/.deploy/cn2.yaml b/.deploy/cn2.yaml index 84fba006..064cf8c7 100644 --- a/.deploy/cn2.yaml +++ b/.deploy/cn2.yaml @@ -1,5 +1,5 @@ -address: "${CN2_ADDRESS}" -quic_port: ${CN2_QUIC_PORT} +address: "${ADDRESS}" +quic_port: ${QUIC_PORT} enable_mdns: false chains: - name: "sepolia" diff --git a/.deploy/cn3.yaml b/.deploy/cn3.yaml index 8d167ddc..064cf8c7 100644 --- a/.deploy/cn3.yaml +++ b/.deploy/cn3.yaml @@ -1,5 +1,5 @@ -address: "${CN3_ADDRESS}" -quic_port: ${CN3_QUIC_PORT} +address: "${ADDRESS}" +quic_port: ${QUIC_PORT} enable_mdns: false chains: - name: "sepolia" diff --git a/.deploy/deploy.sh b/.deploy/deploy.sh new file mode 100755 index 00000000..f881472e --- /dev/null +++ b/.deploy/deploy.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +if [ ! -f ".env" ]; then + echo "Environment file .env not found!" + exit 1 +fi + +# Source the environment file +set -a # automatically export all variables +source .deploy/.env +set +a # turn off auto-export + +docker stack deploy -c .deploy/docker-compose.yml enclave-stack --detach=false diff --git a/.deploy/docker-compose.yml b/.deploy/docker-compose.yml index 40f9c368..b1838375 100644 --- a/.deploy/docker-compose.yml +++ b/.deploy/docker-compose.yml @@ -1,17 +1,20 @@ services: cn1: - image: ghcr.io/gnosisguild/ciphernode:${TAG} + image: ghcr.io/gnosisguild/ciphernode:${TAG:-latest} volumes: - ./cn1.yaml:/home/ciphernode/.config/enclave/config.yaml:ro - cn1-data:/home/ciphernode/.local/share/enclave secrets: - source: secrets_cn1 target: secrets.json + env_file: .env environment: RUST_LOG: "info" AGGREGATOR: "false" + ADDRESS: ${CN1_ADDRESS} + QUIC_PORT: 9091 ports: - - 9091:9091 + - "9091:9091" deploy: replicas: 1 update_config: @@ -25,7 +28,7 @@ services: cn2: - image: ghcr.io/gnosisguild/ciphernode:${TAG} + image: ghcr.io/gnosisguild/ciphernode:${TAG:-latest} depends_on: - cn1 volumes: @@ -34,11 +37,14 @@ services: secrets: - source: secrets_cn2 target: secrets.json + env_file: .env environment: RUST_LOG: "info" AGGREGATOR: "false" + ADDRESS: ${CN2_ADDRESS} + QUIC_PORT: 9092 ports: - - 9092:9092 + - "9092:9092" deploy: replicas: 1 @@ -52,7 +58,7 @@ services: - global-network cn3: - image: ghcr.io/gnosisguild/ciphernode:${TAG} + image: ghcr.io/gnosisguild/ciphernode:${TAG:-latest} depends_on: - cn1 volumes: @@ -61,11 +67,14 @@ services: secrets: - source: secrets_cn3 target: secrets.json + env_file: .env environment: RUST_LOG: "info" AGGREGATOR: "false" + ADDRESS: ${CN3_ADDRESS} + QUIC_PORT: 9093 ports: - - 9093:9093 + - "9093:9093" deploy: replicas: 1 update_config: @@ -79,7 +88,7 @@ services: aggregator: - image: ghcr.io/gnosisguild/ciphernode:${TAG} + image: ghcr.io/gnosisguild/ciphernode:${TAG:-latest} depends_on: - cn1 volumes: @@ -88,11 +97,14 @@ services: secrets: - source: secrets_agg target: secrets.json + env_file: .env environment: RUST_LOG: "info" AGGREGATOR: "true" + ADDRESS: ${AGG_ADDRESS} + QUIC_PORT: 9094 ports: - - 9094:9094 + - "9094:9094" deploy: replicas: 1 diff --git a/.deploy/run.sh b/.deploy/run.sh deleted file mode 100755 index 807ce5a9..00000000 --- a/.deploy/run.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -source .deploy/.env - -docker stack deploy -c .deploy/docker-compose.yml enclave-stack --detach=false diff --git a/.deploy/swarm_deployment.md b/.deploy/swarm_deployment.md index ee084749..78299248 100644 --- a/.deploy/swarm_deployment.md +++ b/.deploy/swarm_deployment.md @@ -1,3 +1,34 @@ +# Setup `.env` vars + +Copy the `.env.example` file to `.env` + +``` +cp .env.example .env +``` + +Alter the variables to reflect the correct values required for the stack: + +``` +export TAG=latest +export AGG_ADDRESS=0x8626a6940E2eb28930eFb4CeF49B2d1F2C9C1199 +export CN1_ADDRESS=0xbDA5747bFD65F08deb54cb465eB87D40e51B197E +export CN2_ADDRESS=0xdD2FD4581271e230360230F9337D5c0430Bf44C0 +export CN3_ADDRESS=0x2546BcD3c84621e976D8185a91A922aE77ECEc30 + +export CN1_QUIC_PORT=9091 +export CN2_QUIC_PORT=9092 +export CN3_QUIC_PORT=9093 +export AGG_QUIC_PORT=9094 +export RPC_URL=wss://eth-sepolia.g.alchemy.com/v2/ + +export SEPOLIA_ENCLAVE_ADDRESS=0xCe087F31e20E2F76b6544A2E4A74D4557C8fDf77 +export SEPOLIA_CIPHERNODE_REGISTRY_ADDRESS=0x0952388f6028a9Eda93a5041a3B216Ea331d97Ab +export SEPOLIA_FILTER_REGISTRY=0xcBaCE7C360b606bb554345b20884A28e41436934 +``` + +Pay special attention to the `TAG` and `RPC_URL` vars. + +You can peruse the yaml config files for the nodes to see how the vars are used within the config. # Secrets Setup Script @@ -23,7 +54,7 @@ Skipping cn2.secrets.json - file already exists Remember to modify any highlighted files before use. -# Run docker swarm +# Initialize docker swarm First we need to initialize swarm. @@ -37,7 +68,12 @@ If you get an error about not being able to choose between IP addresses choose t docker swarm init --advertise-addr 10.49.x.x ``` + +# Deploy a version to the stack + +To deploy + ``` -TAG=latest docker stack deploy -c .deploy/docker-compose.yml enclave-stack --detach=false +.deploy/deploy.sh ```