Skip to content

Commit

Permalink
Setup deploy folder
Browse files Browse the repository at this point in the history
  • Loading branch information
ryardley committed Dec 19, 2024
1 parent 1c0162c commit e364201
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 68 deletions.
7 changes: 0 additions & 7 deletions .deploy/.env.example
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
TAG=latest
AGG_ADDRESS=0x8626a6940E2eb28930eFb4CeF49B2d1F2C9C1199
CN1_ADDRESS=0xbDA5747bFD65F08deb54cb465eB87D40e51B197E
CN2_ADDRESS=0xdD2FD4581271e230360230F9337D5c0430Bf44C0
CN3_ADDRESS=0x2546BcD3c84621e976D8185a91A922aE77ECEc30

RPC_URL=wss://eth-sepolia.g.alchemy.com/v2/API_KEY

SEPOLIA_ENCLAVE_ADDRESS=0xCe087F31e20E2F76b6544A2E4A74D4557C8fDf77
SEPOLIA_CIPHERNODE_REGISTRY_ADDRESS=0x0952388f6028a9Eda93a5041a3B216Ea331d97Ab
SEPOLIA_FILTER_REGISTRY=0xcBaCE7C360b606bb554345b20884A28e41436934
5 changes: 5 additions & 0 deletions .deploy/cn1.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
address: "${ADDRESS}"
quic_port: ${QUIC_PORT}
enable_mdns: false
peers:
- "/dns4/cn1/udp/9091/quic-v1"
- "/dns4/cn1/udp/9092/quic-v1"
- "/dns4/cn1/udp/9093/quic-v1"
- "/dns4/cn1/udp/9094/quic-v1"
chains:
- name: "sepolia"
rpc_url: "${RPC_URL}"
Expand Down
5 changes: 5 additions & 0 deletions .deploy/cn2.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
address: "${ADDRESS}"
quic_port: ${QUIC_PORT}
enable_mdns: false
peers:
- "/dns4/cn1/udp/9091/quic-v1"
- "/dns4/cn1/udp/9092/quic-v1"
- "/dns4/cn1/udp/9093/quic-v1"
- "/dns4/cn1/udp/9094/quic-v1"
chains:
- name: "sepolia"
rpc_url: "${RPC_URL}"
Expand Down
5 changes: 5 additions & 0 deletions .deploy/cn3.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
address: "${ADDRESS}"
quic_port: ${QUIC_PORT}
enable_mdns: false
peers:
- "/dns4/cn1/udp/9091/quic-v1"
- "/dns4/cn1/udp/9092/quic-v1"
- "/dns4/cn1/udp/9093/quic-v1"
- "/dns4/cn1/udp/9094/quic-v1"
chains:
- name: "sepolia"
rpc_url: "${RPC_URL}"
Expand Down
2 changes: 1 addition & 1 deletion .deploy/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ wait_removed() {
stack_name=${1:-enclave}
docker stack rm $stack_name
wait_removed $stack_name
docker stack deploy -c docker-compose.yml --prune $stack_name
docker stack deploy -c ./.deploy/docker-compose.yml --prune $stack_name
wait_ready $stack_name
51 changes: 7 additions & 44 deletions .deploy/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
cn1:
image: ghcr.io/gnosisguild/ciphernode:latest
image: ghcr.io/gnosisguild/ciphernode
volumes:
- ./cn1.yaml:/home/ciphernode/.config/enclave/config.yaml:ro
- cn1-data:/home/ciphernode/.local/share/enclave
Expand All @@ -13,25 +13,14 @@ services:
AGGREGATOR: "false"
ADDRESS: "0xbDA5747bFD65F08deb54cb465eB87D40e51B197E"
QUIC_PORT: 9091
ports:
- "9091:9091/udp"
- "9091:9091/tcp"
deploy:
replicas: 1
endpoint_mode: dnsrr
update_config:
parallelism: 1
order: stop-first
failure_action: rollback
restart_policy:
condition: any
networks:
- global-network

cn2:
image: ghcr.io/gnosisguild/ciphernode:latest
depends_on:
- cn1
image: ghcr.io/gnosisguild/ciphernode
volumes:
- ./cn2.yaml:/home/ciphernode/.config/enclave/config.yaml:ro
- cn2-data:/home/ciphernode/.local/share/enclave
Expand All @@ -44,24 +33,14 @@ services:
AGGREGATOR: "false"
ADDRESS: "0xdD2FD4581271e230360230F9337D5c0430Bf44C0"
QUIC_PORT: 9092
ports:
- "9092:9092/udp"
- "9092:9092/tcp"
deploy:
replicas: 1
update_config:
parallelism: 1
order: stop-first
failure_action: rollback
restart_policy:
condition: any
endpoint_mode: dnsrr
networks:
- global-network

cn3:
image: ghcr.io/gnosisguild/ciphernode:latest
depends_on:
- cn1
image: ghcr.io/gnosisguild/ciphernode
volumes:
- ./cn3.yaml:/home/ciphernode/.config/enclave/config.yaml:ro
- cn3-data:/home/ciphernode/.local/share/enclave
Expand All @@ -74,22 +53,14 @@ services:
AGGREGATOR: "false"
ADDRESS: "0x2546BcD3c84621e976D8185a91A922aE77ECEc30"
QUIC_PORT: 9093
ports:
- "9093:9093/udp"
- "9093:9093/tcp"
deploy:
replicas: 1
update_config:
parallelism: 1
order: stop-first
failure_action: rollback
restart_policy:
condition: any
endpoint_mode: dnsrr
networks:
- global-network

aggregator:
image: ghcr.io/gnosisguild/ciphernode:latest
image: ghcr.io/gnosisguild/ciphernode
depends_on:
- cn1
volumes:
Expand All @@ -104,17 +75,9 @@ services:
AGGREGATOR: "true"
ADDRESS: "0x8626a6940E2eb28930eFb4CeF49B2d1F2C9C1199"
QUIC_PORT: 9094
ports:
- "9094:9094/udp"
- "9094:9094/tcp"
deploy:
replicas: 1
update_config:
parallelism: 1
order: stop-first
failure_action: rollback
restart_policy:
condition: any
endpoint_mode: dnsrr
networks:
- global-network

Expand Down
48 changes: 48 additions & 0 deletions .deploy/inspect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash

get_logs_by_version() {
local SERVICE_NAME=$1

# Get current version number
CURRENT_VERSION=$(docker service inspect --format '{{.Version.Index}}' $SERVICE_NAME)

# Get all tasks with this version
TASK_IDS=$(docker service ps --filter "desired-state=running" \
--format '{{.ID}}' $SERVICE_NAME)

# Get logs from these specific tasks
for TASK_ID in $TASK_IDS; do
docker service logs --raw "$TASK_ID"
done
}

echo ""
echo "================================="
echo " CN1 "
echo "================================="

get_logs_by_version enclave_cn1


echo ""
echo "================================="
echo " CN2 "
echo "================================="

get_logs_by_version enclave_cn2


echo ""
echo "================================="
echo " CN3 "
echo "================================="

get_logs_by_version enclave_cn3


echo ""
echo "================================="
echo " AGG "
echo "================================="

get_logs_by_version enclave_aggregator
7 changes: 6 additions & 1 deletion .deploy/swarm_deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,17 @@ 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
```

# Build the dockerfile image

```
./.deploy/build.sh
```

# Deploy a version to the stack

To deploy

```
.deploy/deploy.sh
./.deploy/deploy.sh
```

13 changes: 1 addition & 12 deletions packages/ciphernode/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,7 @@
!Cargo.toml
!Cargo.lock

# Allow core crate
!core/
!core/Cargo.toml
!core/src/**/*.rs

# net
!net/
!net/Cargo.toml
!net/src/**/*.rs


# Allow all other workspace members (adjust paths as needed)
# Allow all other workspace members
!*/Cargo.toml
!*/src/**/*.rs

Expand Down
29 changes: 26 additions & 3 deletions packages/ciphernode/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,35 @@ RUN yarn install && yarn compile
# Build stage
FROM rust:1.81 AS ciphernode-builder

# Force incremental
ENV CARGO_INCREMENTAL=1
ENV RUSTC_FORCE_INCREMENTAL=1
ENV CARGO_BUILD_JOBS=8

# Create build directory
WORKDIR /build/packages/ciphernode
COPY ./packages/ciphernode ./
COPY --from=evm-builder /build/packages/evm/artifacts ../evm/artifacts
COPY --from=evm-builder /build/packages/evm/deployments ../evm/deployments

# Copy workpace Cargo.toml
COPY ./packages/ciphernode/Cargo.toml ./Cargo.toml
COPY ./packages/ciphernode/Cargo.lock ./Cargo.lock
COPY ./packages/ciphernode/*/Cargo.toml ./

# Build all dependencies and add them to the build cache
RUN mkdir -p src && \
echo "fn main() {}" > src/main.rs && \
for d in ./*/ ; do \
if [ -f "$d/Cargo.toml" ]; then \
mkdir -p "$d/src" && \
echo "fn main() {}" > "$d/src/lib.rs"; \
fi \
done

RUN cargo build --release

COPY ./packages/ciphernode .

RUN cargo build --release

# Runtime stage
Expand Down Expand Up @@ -44,5 +68,4 @@ ENV DATA_DIR=/home/ciphernode/.local/share/enclave
ENV RUST_LOG=info

# Add entrypoint script

ENTRYPOINT ["ciphernode-entrypoint.sh"]
ENTRYPOINT ["ciphernode-entrypoint.sh"]

0 comments on commit e364201

Please sign in to comment.