Skip to content

Commit

Permalink
Fix docker setup for local cluster (sei-protocol#1806)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wojciech Małota-Wójcik authored Aug 12, 2024
1 parent c3aaf99 commit 1ca3dd4
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 42 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,6 @@ jobs:
with:
go-version: 1.21

- name: Install Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
- name: Start 4 node docker cluster
run: make clean && INVARIANT_CHECK_INTERVAL=10 ${{matrix.test.env}} make docker-cluster-start &

Expand Down
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ run-local-node: kill-sei-node build-docker-node
docker run --rm \
--name sei-node \
--network host \
--user="$(shell id -u):$(shell id -g)" \
-v $(PROJECT_HOME):/sei-protocol/sei-chain:Z \
-v $(GO_PKG_PATH)/mod:/root/go/pkg/mod:Z \
-v $(shell go env GOCACHE):/root/.cache/go-build:Z \
--platform linux/x86_64 \
sei-chain/localnode
.PHONY: run-local-node
Expand All @@ -149,11 +151,13 @@ run-rpc-node: build-rpc-node
docker run --rm \
--name sei-rpc-node \
--network docker_localnet \
--user="$(shell id -u):$(shell id -g)" \
-v $(PROJECT_HOME):/sei-protocol/sei-chain:Z \
-v $(PROJECT_HOME)/../sei-tendermint:/sei-protocol/sei-tendermint:Z \
-v $(PROJECT_HOME)/../sei-cosmos:/sei-protocol/sei-cosmos:Z \
-v $(PROJECT_HOME)/../sei-db:/sei-protocol/sei-db:Z \
-v $(GO_PKG_PATH)/mod:/root/go/pkg/mod:Z \
-v $(shell go env GOCACHE):/root/.cache/go-build:Z \
-p 26668-26670:26656-26658 \
--platform linux/x86_64 \
sei-chain/rpcnode
Expand All @@ -163,39 +167,43 @@ run-rpc-node-skipbuild: build-rpc-node
docker run --rm \
--name sei-rpc-node \
--network docker_localnet \
--user="$(shell id -u):$(shell id -g)" \
-v $(PROJECT_HOME):/sei-protocol/sei-chain:Z \
-v $(PROJECT_HOME)/../sei-tendermint:/sei-protocol/sei-tendermint:Z \
-v $(PROJECT_HOME)/../sei-cosmos:/sei-protocol/sei-cosmos:Z \
-v $(PROJECT_HOME)/../sei-db:/sei-protocol/sei-db:Z \
-v $(GO_PKG_PATH)/mod:/root/go/pkg/mod:Z \
-v $(shell go env GOCACHE):/root/.cache/go-build:Z \
-p 26668-26670:26656-26658 \
--platform linux/x86_64 \
--env SKIP_BUILD=true \
sei-chain/rpcnode
.PHONY: run-rpc-node

kill-sei-node:
docker ps --filter name=sei-node --filter status=running -aq | xargs docker kill
docker ps --filter name=sei-node --filter status=running -aq | xargs docker kill 2> /dev/null || true

kill-rpc-node:
docker ps --filter name=sei-rpc-node --filter status=running -aq | xargs docker kill
docker ps --filter name=sei-rpc-node --filter status=running -aq | xargs docker kill 2> /dev/null || true

# Run a 4-node docker containers
docker-cluster-start: docker-cluster-stop build-docker-node
@rm -rf $(PROJECT_HOME)/build/generated
@cd docker && NUM_ACCOUNTS=10 INVARIANT_CHECK_INTERVAL=${INVARIANT_CHECK_INTERVAL} UPGRADE_VERSION_LIST=${UPGRADE_VERSION_LIST} docker-compose up
@mkdir -p $(shell go env GOPATH)/pkg/mod
@mkdir -p $(shell go env GOCACHE)
@cd docker && USERID=$(shell id -u) GROUPID=$(shell id -g) GOCACHE=$(shell go env GOCACHE) NUM_ACCOUNTS=10 INVARIANT_CHECK_INTERVAL=${INVARIANT_CHECK_INTERVAL} UPGRADE_VERSION_LIST=${UPGRADE_VERSION_LIST} docker compose up

.PHONY: localnet-start

# Use this to skip the seid build process
docker-cluster-start-skipbuild: docker-cluster-stop build-docker-node
@rm -rf $(PROJECT_HOME)/build/generated
@cd docker && NUM_ACCOUNTS=10 SKIP_BUILD=true docker-compose up
@cd docker && USERID=$(shell id -u) GROUPID=$(shell id -g) GOCACHE=$(shell go env GOCACHE) NUM_ACCOUNTS=10 SKIP_BUILD=true docker compose up
.PHONY: localnet-start

# Stop 4-node docker containers
docker-cluster-stop:
@cd docker && docker-compose down
@cd docker && USERID=$(shell id -u) GROUPID=$(shell id -g) GOCACHE=$(shell go env GOCACHE) docker compose down
.PHONY: localnet-stop


Expand Down
8 changes: 8 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
platform: linux/amd64
container_name: sei-node-0
image: "sei-chain/localnode"
user: "${USERID}:${GROUPID}"
ports:
- "26656-26658:26656-26658"
- "9090-9091:9090-9091"
Expand All @@ -23,6 +24,7 @@ services:
- "${PROJECT_HOME}/../sei-db:/sei-protocol/sei-db:Z"
- "${PROJECT_HOME}/../go-ethereum:/sei-protocol/go-ethereum:Z"
- "${GO_PKG_PATH}/mod:/root/go/pkg/mod:Z"
- "${GOCACHE}:/root/.cache/go-build:Z"
networks:
localnet:
ipv4_address: 192.168.10.10
Expand All @@ -31,6 +33,7 @@ services:
platform: linux/amd64
container_name: sei-node-1
image: "sei-chain/localnode"
user: "${USERID}:${GROUPID}"
ports:
- "26659-26661:26656-26658"
- "9092-9093:9090-9091"
Expand All @@ -48,6 +51,7 @@ services:
- "${PROJECT_HOME}/../sei-db:/sei-protocol/sei-db:Z"
- "${PROJECT_HOME}/../go-ethereum:/sei-protocol/go-ethereum:Z"
- "${GO_PKG_PATH}/mod:/root/go/pkg/mod:Z"
- "${GOCACHE}:/root/.cache/go-build:Z"
networks:
localnet:
ipv4_address: 192.168.10.11
Expand All @@ -56,6 +60,7 @@ services:
platform: linux/amd64
container_name: sei-node-2
image: "sei-chain/localnode"
user: "${USERID}:${GROUPID}"
environment:
- ID=2
- CLUSTER_SIZE=4
Expand All @@ -73,6 +78,7 @@ services:
- "${PROJECT_HOME}/../sei-db:/sei-protocol/sei-db:Z"
- "${PROJECT_HOME}/../go-ethereum:/sei-protocol/go-ethereum:Z"
- "${GO_PKG_PATH}/mod:/root/go/pkg/mod:Z"
- "${GOCACHE}:/root/.cache/go-build:Z"
networks:
localnet:
ipv4_address: 192.168.10.12
Expand All @@ -81,6 +87,7 @@ services:
platform: linux/amd64
container_name: sei-node-3
image: "sei-chain/localnode"
user: "${USERID}:${GROUPID}"
environment:
- ID=3
- CLUSTER_SIZE=4
Expand All @@ -98,6 +105,7 @@ services:
- "${PROJECT_HOME}/../sei-db:/sei-protocol/sei-db:Z"
- "${PROJECT_HOME}/../go-ethereum:/sei-protocol/go-ethereum:Z"
- "${GO_PKG_PATH}/mod:/root/go/pkg/mod:Z"
- "${GOCACHE}:/root/.cache/go-build:Z"
networks:
localnet:
ipv4_address: 192.168.10.13
Expand Down
22 changes: 8 additions & 14 deletions docker/localnode/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
FROM ubuntu:latest
ENV HOME="/root" PATH="/root/go/bin:/sei-protocol/sei-chain/integration_test/upgrade_module/scripts/:$PATH"
RUN apt-get update && \
apt-get install -y make git wget build-essential jq python3 curl vim uuid-runtime
RUN rm -rf build/generated
RUN wget https://go.dev/dl/go1.22.4.linux-amd64.tar.gz
RUN tar -xvf go1.22.4.linux-amd64.tar.gz
RUN mv go /usr/local/
apt-get install -y make git build-essential jq python3 curl vim uuid-runtime nodejs
RUN curl -L https://go.dev/dl/go1.22.4.linux-amd64.tar.gz | tar xvzf - -C /usr/local/
RUN curl -L https://foundry.paradigm.xyz | bash
RUN /root/.foundry/bin/foundryup
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash
RUN apt-get install -y nodejs
RUN mkdir -p /root/.config && \
chmod -R 777 /root/.config
RUN /root/.foundry/bin/foundryup
RUN mkdir -p /root/go/pkg/mod && \
mkdir -p /root/.cache && \
chmod -R a+rwX /root
SHELL ["/bin/bash", "-c"]


VOLUME [ "/sei-protocol" ]
VOLUME [ "/root/go/pkg/mod" ]

WORKDIR /sei-protocol/sei-chain

EXPOSE 26656 26657 26658 9090 9091 7171
Expand All @@ -33,4 +27,4 @@ COPY scripts/step3_add_validator_to_genesis.sh /usr/bin/add_validator_to_gensis.
COPY scripts/step4_config_override.sh /usr/bin/config_override.sh
COPY scripts/step5_start_sei.sh /usr/bin/start_sei.sh
COPY scripts/step6_start_price_feeder.sh /usr/bin/start_price_feeder.sh
ENV PATH "$PATH:$HOME/go/bin:/sei-protocol/sei-chain/integration_test/upgrade_module/scripts/"

10 changes: 5 additions & 5 deletions docker/localnode/scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
NODE_ID=${ID:-0}
CLUSTER_SIZE=${CLUSTER_SIZE:-1}


# Clean up and env set up
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export BUILD_PATH=/sei-protocol/sei-chain/build
export PATH=$GOBIN:$PATH:/usr/local/go/bin:$BUILD_PATH
echo "export GOPATH=$HOME/go" >> /root/.bashrc
echo "GOBIN=$GOPATH/bin" >> /root/.bashrc
echo "export PATH=$GOBIN:$PATH:/usr/local/go/bin:$BUILD_PATH:/root/.foundry/bin" >> /root/.bashrc
/bin/bash -c "source /root/.bashrc"
echo "export GOPATH=$HOME/go" >> "$HOME/.bashrc"
echo "GOBIN=$GOPATH/bin" >> "$HOME/.bashrc"
echo "export PATH=$GOBIN:$PATH:/usr/local/go/bin:$BUILD_PATH:$HOME/.foundry/bin" >> "$HOME/.bashrc"
rm -rf build/generated
/bin/bash -c "source $HOME/.bashrc"
mkdir -p $GOBIN
# Step 0: Build on node 0
if [ "$NODE_ID" = 0 ] && [ -z "$SKIP_BUILD" ]
Expand Down
10 changes: 5 additions & 5 deletions docker/localnode/scripts/step6_start_price_feeder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ ORACLE_ACCOUNT="oracle"
VALIDATOR_ACCOUNT="node_admin"

# Create an oracle account
printf "12345678\n" | /root/go/bin/seid keys add $ORACLE_ACCOUNT --output json > /root/.sei/config/oracle_key.json
ORACLE_ACCOUNT_ADDRESS=$(printf "12345678\n" | /root/go/bin/seid keys show $ORACLE_ACCOUNT -a)
SEIVALOPER=$(printf "12345678\n" | /root/go/bin/seid keys show $VALIDATOR_ACCOUNT --bech=val -a)
printf "12345678\n" | /root/go/bin/seid tx oracle set-feeder "$ORACLE_ACCOUNT_ADDRESS" --from $VALIDATOR_ACCOUNT --fees 2000usei -b block -y --chain-id sei >/dev/null 2>&1
printf "12345678\n" | /root/go/bin/seid tx bank send $VALIDATOR_ACCOUNT "$ORACLE_ACCOUNT_ADDRESS" --from $VALIDATOR_ACCOUNT 1000sei --fees 2000usei -b block -y >/dev/null 2>&1
printf "12345678\n" | "$HOME/go/bin/seid" keys add $ORACLE_ACCOUNT --output json > "$HOME/.sei/config/oracle_key.json"
ORACLE_ACCOUNT_ADDRESS=$(printf "12345678\n" | "$HOME/go/bin/seid" keys show $ORACLE_ACCOUNT -a)
SEIVALOPER=$(printf "12345678\n" | "$HOME/go/bin/seid" keys show $VALIDATOR_ACCOUNT --bech=val -a)
printf "12345678\n" | "$HOME/go/bin/seid" tx oracle set-feeder "$ORACLE_ACCOUNT_ADDRESS" --from $VALIDATOR_ACCOUNT --fees 2000usei -b block -y --chain-id sei >/dev/null 2>&1
printf "12345678\n" | "$HOME/go/bin/seid" tx bank send $VALIDATOR_ACCOUNT "$ORACLE_ACCOUNT_ADDRESS" --from $VALIDATOR_ACCOUNT 1000sei --fees 2000usei -b block -y >/dev/null 2>&1


sed -i.bak -e "s|^address *=.*|address = \"$ORACLE_ACCOUNT_ADDRESS\"|" $ORACLE_CONFIG_FILE
Expand Down
13 changes: 6 additions & 7 deletions docker/rpcnode/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM ubuntu:latest
ENV HOME="/root" PATH="/root/go/bin:$PATH"
RUN apt-get update && \
apt-get install -y make git wget build-essential jq python3 curl vim uuid-runtime
RUN wget https://go.dev/dl/go1.21.4.linux-amd64.tar.gz
RUN tar -xvf go1.21.4.linux-amd64.tar.gz
RUN mv go /usr/local/
apt-get install -y make git build-essential jq python3 curl vim uuid-runtime
RUN curl -L https://go.dev/dl/go1.21.4.linux-amd64.tar.gz | tar xvzf - -C /usr/local/
RUN mkdir -p /root/go/pkg/mod && \
mkdir -p /root/.cache && \
chmod -R a+rwX /root
SHELL ["/bin/bash", "-c"]

VOLUME [ "/sei-protocol" ]
VOLUME [ "/root/go/pkg/mod" ]
WORKDIR /sei-protocol/sei-chain

EXPOSE 26656 26657 26658 9090 9091
Expand All @@ -20,4 +20,3 @@ COPY scripts/deploy.sh /usr/bin/deploy.sh
COPY scripts/step0_build.sh /usr/bin/build.sh
COPY scripts/step1_configure_init.sh /usr/bin/configure_init.sh
COPY scripts/step2_start_sei.sh /usr/bin/start_sei.sh
ENV PATH "$PATH:$HOME/go/bin"

0 comments on commit 1ca3dd4

Please sign in to comment.