Add helpers for CI setup and document
This commit is contained in:
@@ -7,6 +7,8 @@ FROM golang:1.13-buster AS build-env
|
|||||||
# Install minimum necessary dependencies, build Cosmos SDK, remove packages
|
# Install minimum necessary dependencies, build Cosmos SDK, remove packages
|
||||||
RUN apt update
|
RUN apt update
|
||||||
RUN apt install -y curl git build-essential
|
RUN apt install -y curl git build-essential
|
||||||
|
# debug: for live editting in the image
|
||||||
|
RUN apt install -y vim
|
||||||
|
|
||||||
# Set working directory for the build
|
# Set working directory for the build
|
||||||
WORKDIR /go/src/github.com/cosmwasm/wasmd
|
WORKDIR /go/src/github.com/cosmwasm/wasmd
|
||||||
|
|||||||
49
README.md
49
README.md
@@ -28,20 +28,25 @@ If you want to deploy a whole cluster, [look at the network scripts](./networks/
|
|||||||
|
|
||||||
## Dockerized
|
## Dockerized
|
||||||
|
|
||||||
|
We provide a docker image to help with test setups. There are two modes to use it
|
||||||
|
|
||||||
|
Build: `docker build -t wasmd:manual .` or pull from dockerhub
|
||||||
|
|
||||||
|
### Dev server
|
||||||
|
|
||||||
|
Bring up a local node with a test account containing tokens
|
||||||
|
|
||||||
This is just designed for local testing/CI - DO NOT USE IN PRODUCTION
|
This is just designed for local testing/CI - DO NOT USE IN PRODUCTION
|
||||||
|
|
||||||
Build: `docker build -t wasmd:manual .`
|
|
||||||
|
|
||||||
Run:
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker volume rm -f wasmd_data
|
docker volume rm -f wasmd_data
|
||||||
|
|
||||||
# pass password (one time) as env variable for setup, so we don't need to keep typing it
|
# pass password (one time) as env variable for setup, so we don't need to keep typing it
|
||||||
|
# add some addresses that you have private keys for (locally) to give them genesis funds
|
||||||
docker run --rm -it \
|
docker run --rm -it \
|
||||||
-e PASSWORD=my-secret-password \
|
-e PASSWORD=my-secret-password \
|
||||||
--mount type=volume,source=wasmd_data,target=/root \
|
--mount type=volume,source=wasmd_data,target=/root \
|
||||||
wasmd:manual ./setup.sh
|
wasmd:manual ./setup.sh cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6
|
||||||
|
|
||||||
# This will start both wasmd and wasmcli rest-server, only wasmcli output is shown on the screen
|
# This will start both wasmd and wasmcli rest-server, only wasmcli output is shown on the screen
|
||||||
docker run --rm -it -p 26657:26657 -p 26656:26656 -p 1317:1317 \
|
docker run --rm -it -p 26657:26657 -p 26656:26656 -p 1317:1317 \
|
||||||
@@ -53,3 +58,37 @@ docker run --rm -it \
|
|||||||
--mount type=volume,source=wasmd_data,target=/root,readonly \
|
--mount type=volume,source=wasmd_data,target=/root,readonly \
|
||||||
wasmd:manual ./logs.sh
|
wasmd:manual ./logs.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### CI
|
||||||
|
|
||||||
|
For CI, we want to generate a template one time and save to disk/repo. Then we can start a chain copying the initial state, but not modifying it. This lets us get the same, fresh start every time.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Init chain and pass addresses so they are non-empty accounts
|
||||||
|
rm -rf ./template && mkdir ./template
|
||||||
|
docker run --rm -it \
|
||||||
|
-e PASSWORD=my-secret-password \
|
||||||
|
--mount type=bind,source=$(pwd)/template,target=/root \
|
||||||
|
wasmd:manual ./setup.sh cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6
|
||||||
|
|
||||||
|
sudo chown -R $(id -u):$(id -g) ./template
|
||||||
|
|
||||||
|
# FIRST TIME
|
||||||
|
# bind to non-/root and pass an argument to run.sh to copy the template into /root
|
||||||
|
# we need wasmd_data volume mount not just for restart, but also to view logs
|
||||||
|
docker volume rm -f wasmd_data
|
||||||
|
docker run --rm -it -p 26657:26657 -p 26656:26656 -p 1317:1317 \
|
||||||
|
--mount type=bind,source=$(pwd)/template,target=/template \
|
||||||
|
--mount type=volume,source=wasmd_data,target=/root \
|
||||||
|
wasmd:manual ./run.sh /template
|
||||||
|
|
||||||
|
# RESTART CHAIN with existing state
|
||||||
|
docker run --rm -it -p 26657:26657 -p 26656:26656 -p 1317:1317 \
|
||||||
|
--mount type=volume,source=wasmd_data,target=/root \
|
||||||
|
wasmd:manual ./run.sh
|
||||||
|
|
||||||
|
# view wasmd logs in another shell
|
||||||
|
docker run --rm -it \
|
||||||
|
--mount type=volume,source=wasmd_data,target=/root,readonly \
|
||||||
|
wasmd:manual ./logs.sh
|
||||||
|
```
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
if test -n "$1"; then
|
||||||
|
# need -R not -r to copy hidden files
|
||||||
|
cp -R "$1/.wasmd" /root
|
||||||
|
cp -R "$1/.wasmcli" /root
|
||||||
|
fi
|
||||||
|
|
||||||
echo Starting Wasmd...
|
echo Starting Wasmd...
|
||||||
|
|
||||||
mkdir -p /root/log
|
mkdir -p /root/log
|
||||||
wasmd start --rpc.laddr tcp://0.0.0.0:26657 > /root/log/wasmd.log &
|
wasmd start --rpc.laddr tcp://0.0.0.0:26657 >> /root/log/wasmd.log &
|
||||||
|
|
||||||
sleep 10
|
sleep 4
|
||||||
echo Starting Rest Server...
|
echo Starting Rest Server...
|
||||||
|
|
||||||
wasmcli rest-server --laddr tcp://0.0.0.0:1317 --trust-node
|
wasmcli rest-server --laddr tcp://0.0.0.0:1317 --trust-node
|
||||||
|
|||||||
@@ -4,6 +4,12 @@ PASSWORD=${PASSWORD:-1234567890}
|
|||||||
|
|
||||||
wasmd init --chain-id=testing testing
|
wasmd init --chain-id=testing testing
|
||||||
(echo $PASSWORD; echo $PASSWORD) | wasmcli keys add validator
|
(echo $PASSWORD; echo $PASSWORD) | wasmcli keys add validator
|
||||||
echo $PASSWORD | wasmd add-genesis-account validator 1000000000stake,1000000000validatortoken
|
# hardcode the validator account for this instance
|
||||||
|
echo $PASSWORD | wasmd add-genesis-account validator 1000000000stake,1000000000cosm
|
||||||
|
# (optionally) add a few more genesis accounts
|
||||||
|
for addr in "$@"; do
|
||||||
|
wasmd add-genesis-account $addr 1000000000stake,1000000000cosm
|
||||||
|
done
|
||||||
|
# submit a genesis validator tx
|
||||||
(echo $PASSWORD; echo $PASSWORD; echo $PASSWORD) | wasmd gentx --name validator
|
(echo $PASSWORD; echo $PASSWORD; echo $PASSWORD) | wasmd gentx --name validator
|
||||||
wasmd collect-gentxs
|
wasmd collect-gentxs
|
||||||
Reference in New Issue
Block a user