Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4r45h committed Sep 12, 2024
0 parents commit 9a08d0d
Show file tree
Hide file tree
Showing 6 changed files with 266 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NODE_P2P_PORT=31200
NODE_RPC_PORT=31201
NODE_EXTERNAL_IP=135.181.5.27
WALLET_NAME="example"
32 changes: 32 additions & 0 deletions .github/workflows/publish-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Docker
on:
push:
tags: [ 'v*.*.*' ]
env:
REGISTRY: ghcr.io
jobs:
build-node:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Create .env file
run: touch .env
shell: bash

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker Compose Build & Push
uses: 0x4r45h/docker-compose-ci@v0.1.1
with:
services: 'node'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env*
!.env.sample
25 changes: 25 additions & 0 deletions configs/node/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

lavad config chain-id $CHAIN_ID
lavad config keyring-backend file
lavad init $MONIKER --chain-id $CHAIN_ID

wget https://storage.googleapis.com/lavanet-public-asssets/tge/genesis.json -O $HOME/.lava/config/genesis.json
#Then verify the correctness of the genesis configuration file:
lavad validate-genesis

### config.toml changes
sed -i \
-e 's|^timeout_propose =.*|timeout_propose = "10s"|' \
-e 's|^timeout_propose_delta =.*|timeout_propose_delta = "500ms"|' \
-e 's|^timeout_prevote =.*|timeout_prevote = "1s"|' \
-e 's|^timeout_prevote_delta =.*|timeout_prevote_delta = "500ms"|' \
-e 's|^timeout_precommit =.*|timeout_precommit = "500ms"|' \
-e 's|^timeout_precommit_delta =.*|timeout_precommit_delta = "1s"|' \
-e 's|^timeout_commit =.*|timeout_commit = "15s"|' \
-e 's|^create_empty_blocks =.*|create_empty_blocks = true|' \
-e 's|^create_empty_blocks_interval =.*|create_empty_blocks_interval = "15s"|' \
-e 's|^timeout_broadcast_tx_commit =.*|timeout_broadcast_tx_commit = "151s"|' \
-e 's|^skip_timeout_commit =.*|skip_timeout_commit = false|' \
-e 's|^indexer =.*|indexer = "null"|' \
$HOME/.lava/config/config.toml
66 changes: 66 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
services:
node:
image: ${LAVA_DOCKER_IMAGE_REGISTRY:-ghcr.io/emberstake/lava-docker}/node:${NODE_TAG:-v3.1.0}
build:
dockerfile: docker/node/Dockerfile
context: .
restart: unless-stopped
profiles:
- node
networks:
lava:
environment:
- CHAIN_ID=${NODE_CHAIN_ID:-lava-mainnet-1}
- MONIKER=${NODE_MONIKER:-EmberStakeTools}
- WALLET=${NODE_WALLET_NAME:-example}
logging:
options:
max-size: "12m"
max-file: "5"
command:
- run
- start
- --log_level
- ${NODE_LOG_LEVEL:-info}
- --api.enable
- --grpc.enable
- --grpc.address
- "0.0.0.0:9090"
- --grpc-web.enable
- --grpc-web.address
- "0.0.0.0:9091"
- --proxy_app
- "tcp://0.0.0.0:26658"
- --p2p.laddr
- "tcp://0.0.0.0:26656"
- --p2p.seeds
- ${SEEDS}
- --p2p.persistent_peers
- ${PERSISTENT_PEERS}
- --p2p.external-address
- ${NODE_EXTERNAL_IP}:${NODE_P2P_PORT}
- --rpc.laddr
- "tcp://0.0.0.0:26657"
volumes:
- type: bind
source: ./configs/node/init.sh
target: /init.sh
read_only: true
- type: volume
source: node_data
target: /home/pilot/.lava/data
- type: volume
source: node_config
target: /home/pilot/.lava/config
- type: volume
source: node_keyring
target: /home/pilot/.lava/keyring-file
ports:
- "${NODE_P2P_PORT}:26656" # p2p
- "${NODE_RPC_PORT}:26657"
volumes:
node_config:
node_data:
node_keyring:
networks:
lava:
137 changes: 137 additions & 0 deletions docker/node/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
FROM golang:1.23-bookworm as genesis-builder
USER root
RUN apt-get update && apt-get install -y \
make \
curl \
git \
&& apt-get clean

WORKDIR /root

# Install Cosmovisor
RUN go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@v1.6.0
# Make Genesis binaries
RUN git clone -b v0.33.0 https://github.com/lavanet/lava.git
WORKDIR lava
RUN LAVA_BINARY=lavad make build

##build v0.34.0 binary
FROM golang:1.23-bookworm as upgrade-v0_34_0
USER root
RUN apt-get update && apt-get install -y \
make \
curl \
git \
&& apt-get clean
WORKDIR /root
# Make binaries
RUN git clone -b v0.34.0 https://github.com/lavanet/lava.git
WORKDIR lava
RUN LAVA_BINARY=lavad make build


##build v0.35.0 binary
FROM golang:1.23-bookworm as upgrade-v0_35_0
USER root
RUN apt-get update && apt-get install -y \
make \
curl \
git \
&& apt-get clean
WORKDIR /root
# Make binaries
RUN git clone -b v0.35.0 https://github.com/lavanet/lava.git
WORKDIR lava
RUN LAVA_BINARY=lavad make build


##build v1.0.1 binary
FROM golang:1.23-bookworm as upgrade-v1_0_1
USER root
RUN apt-get update && apt-get install -y \
make \
curl \
git \
&& apt-get clean
WORKDIR /root
# Make binaries
RUN git clone -b v1.0.1 https://github.com/lavanet/lava.git
WORKDIR lava
RUN LAVA_BINARY=lavad make build


##build v2.2.0 binary
FROM golang:1.23-bookworm as upgrade-v2_2_0
USER root
RUN apt-get update && apt-get install -y \
make \
curl \
git \
&& apt-get clean
WORKDIR /root
# Make binaries
RUN git clone -b v2.2.0 https://github.com/lavanet/lava.git
WORKDIR lava
RUN LAVA_BINARY=lavad make build

##build v3.1.0 binary
FROM golang:1.23-bookworm as upgrade-v3_1_0
USER root
RUN apt-get update && apt-get install -y \
make \
curl \
git \
&& apt-get clean
WORKDIR /root
# Make binaries
RUN git clone -b v3.1.0 https://github.com/lavanet/lava.git
WORKDIR lava
RUN LAVA_BINARY=lavad make build


FROM debian:bookworm-slim AS runtime
RUN apt-get update && apt-get install -y \
curl \
nano \
jq \
dnsutils \
wget \
unzip \
lz4 \
aria2 \
pv \
git \
iputils-ping \
iproute2 \
&& apt-get clean

# Create user operator
RUN useradd -m pilot
USER pilot
WORKDIR /home/pilot

# Set Cosmovisor env variables
ENV DAEMON_NAME=lavad
ENV DAEMON_HOME=/home/pilot/.lava
ENV DAEMON_ALLOW_DOWNLOAD_BINARIES=true
ENV DAEMON_RESTART_AFTER_UPGRADE=true
ENV UNSAFE_SKIP_BACKUP=true

RUN mkdir -p $DAEMON_HOME/cosmovisor/genesis/bin
RUN ln -s $DAEMON_HOME/cosmovisor/genesis $DAEMON_HOME/cosmovisor/current

ENV PATH=$PATH:$DAEMON_HOME/cosmovisor/current/bin

COPY --chown=pilot:pilot --from=genesis-builder /go/bin/cosmovisor /usr/local/bin/
COPY --chown=pilot:pilot --from=genesis-builder /root/lava/build/lavad $DAEMON_HOME/cosmovisor/genesis/bin/
COPY --chown=pilot:pilot --from=upgrade-v0_34_0 /root/lava/build/lavad $DAEMON_HOME/cosmovisor/upgrades/v0.34.0/bin/
COPY --chown=pilot:pilot --from=upgrade-v0_35_0 /root/lava/build/lavad $DAEMON_HOME/cosmovisor/upgrades/v0.35.0/bin/
COPY --chown=pilot:pilot --from=upgrade-v1_0_1 /root/lava/build/lavad $DAEMON_HOME/cosmovisor/upgrades/v1.0.1/bin/
COPY --chown=pilot:pilot --from=upgrade-v2_2_0 /root/lava/build/lavad $DAEMON_HOME/cosmovisor/upgrades/v2.2.0/bin/
COPY --chown=pilot:pilot --from=upgrade-v3_1_0 /root/lava/build/lavad $DAEMON_HOME/cosmovisor/upgrades/v3.1.0/bin/

# workaround to https://github.com/cosmos/cosmos-sdk/issues/20947
RUN mkdir -p $DAEMON_HOME/data $DAEMON_HOME/config $DAEMON_HOME/keyring-test $DAEMON_HOME/keyring-file

ENTRYPOINT ["/usr/local/bin/cosmovisor"]
CMD ["--help"]

0 comments on commit 9a08d0d

Please sign in to comment.