feat: Dockerize our wasmd single-node validator (#110)
Signed-off-by: Thane Thomson <connect@thanethomson.com>
This commit is contained in:
parent
2afbe50f76
commit
88f738daae
7 changed files with 193 additions and 0 deletions
30
docker/wasmd/Dockerfile
Normal file
30
docker/wasmd/Dockerfile
Normal file
|
@ -0,0 +1,30 @@
|
|||
ARG WASMD_VERSION=v0.44.0
|
||||
|
||||
FROM cosmwasm/wasmd:${WASMD_VERSION}
|
||||
|
||||
# Increase the amount of ucosm given to accounts
|
||||
RUN sed -i 's/1000000000/12000000000000/g' /opt/setup_wasmd.sh
|
||||
|
||||
# Set up wasmd. The account numbers correspond to those in the ./accounts/
|
||||
# folder.
|
||||
RUN /opt/setup_wasmd.sh \
|
||||
wasm1mkrm9m8g0dzv5z73xg8yzlj6srqc72qru5xfv3 \
|
||||
wasm19azg82cx3qx88gar8nl08rz7x0p27amtmadfep \
|
||||
wasm1adcnk7lt6qst7p5d0g5607e28k77um7nxwxuqy \
|
||||
wasm1jn34x50hy3my0a2mxwcx8fttgfxu2n5gpvu0ty
|
||||
|
||||
# Configure the validator for single-node operation within a Docker container
|
||||
RUN <<EOF
|
||||
sed -i 's/keyring-backend = "os"/keyring-backend = "test"/g' /root/.wasmd/config/client.toml
|
||||
sed -i 's/enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' /root/.wasmd/config/app.toml
|
||||
sed -i 's/address = \"tcp:\/\/localhost:1317\"/address = \"tcp:\/\/0.0.0.0:1317\"/g' /root/.wasmd/config/app.toml
|
||||
sed -i 's/address = \"localhost:909/address = \"0.0.0.0:909/g' /root/.wasmd/config/app.toml
|
||||
sed -i 's/enable = false/enable = true/g' /root/.wasmd/config/app.toml
|
||||
sed -i 's/rpc-max-body-bytes = 1000000$/rpc-max-body-bytes = 1000000000/g' /root/.wasmd/config/app.toml
|
||||
sed -i 's/laddr = \"tcp:\/\/127.0.0.1:26657\"/laddr = \"tcp:\/\/0.0.0.0:26657\"/g' /root/.wasmd/config/config.toml
|
||||
sed -i 's/cors_allowed_origins = \[\]/cors_allowed_origins = \[\"*\"\]/g' /root/.wasmd/config/config.toml
|
||||
sed -i 's/max_body_bytes = 1000000$/max_body_bytes = 1000000000/g' /root/.wasmd/config/config.toml
|
||||
sed -i 's/max_tx_bytes = 1048576$/max_tx_bytes = 104857600/g' /root/.wasmd/config/config.toml
|
||||
EOF
|
||||
|
||||
CMD ["/opt/run_wasmd.sh"]
|
38
docker/wasmd/Makefile
Normal file
38
docker/wasmd/Makefile
Normal file
|
@ -0,0 +1,38 @@
|
|||
WASMD_VERSION?=v0.44.0
|
||||
ORG?=informaldev
|
||||
IMAGE?=$(ORG)/wasmd
|
||||
.DEFAULT_GOAL := build
|
||||
|
||||
build:
|
||||
docker build \
|
||||
--build-arg="WASMD_VERSION=$(WASMD_VERSION)" \
|
||||
-t $(IMAGE):$(WASMD_VERSION) \
|
||||
.
|
||||
.PHONY: build
|
||||
|
||||
run: build
|
||||
docker run --rm -it \
|
||||
-p 26657:26657 -p 26656:26656 -p 1317:1317 -p 9090:9090 \
|
||||
--mount type=volume,source=wasmd_data,target=/root \
|
||||
--name wasmd \
|
||||
$(ORG)/wasmd:$(WASMD_VERSION)
|
||||
.PHONY: run
|
||||
|
||||
# The create-accounts and delete-accounts commands are exclusively for local use
|
||||
# to refresh the accounts in ./accounts/
|
||||
#
|
||||
# Both targets require that the correct version of wasmd be installed locally.
|
||||
create-accounts:
|
||||
mkdir -p ./accounts
|
||||
wasmd keys add admin > ./accounts/admin.txt 2>&1
|
||||
wasmd keys add alice > ./accounts/alice.txt 2>&1
|
||||
wasmd keys add bob > ./accounts/bob.txt 2>&1
|
||||
wasmd keys add charlie > ./accounts/charlie.txt 2>&1
|
||||
.PHONY: create-accounts
|
||||
|
||||
delete-accounts:
|
||||
wasmd keys delete -y admin
|
||||
wasmd keys delete -y alice
|
||||
wasmd keys delete -y bob
|
||||
wasmd keys delete -y charlie
|
||||
.PHONY: delete-accounts
|
81
docker/wasmd/README.md
Normal file
81
docker/wasmd/README.md
Normal file
|
@ -0,0 +1,81 @@
|
|||
# Quartz app wasmd image
|
||||
|
||||
This folder contains a `Dockerfile` that helps build a single-node [wasmd]
|
||||
validator for use in testing your Quartz application.
|
||||
|
||||
It facilitates the creation of a Docker image with 4 accounts pre-loaded, each
|
||||
having a small amount of `ucosm` preloaded from genesis for experimentation.
|
||||
|
||||
- `admin`
|
||||
- `alice`
|
||||
- `bob`
|
||||
- `charlie`
|
||||
|
||||
These accounts' details are stored in clear text in the [accounts](./accounts/)
|
||||
folder.
|
||||
|
||||
**Note: this image is _not_ intended to be used in production.**
|
||||
|
||||
## Running the image
|
||||
|
||||
From this directory, simply run:
|
||||
|
||||
```bash
|
||||
make run
|
||||
```
|
||||
|
||||
This will implicitly call `make build` to build the Docker image, and then run
|
||||
it, binding to the following ports on the local machine:
|
||||
|
||||
- 1317
|
||||
- 9090
|
||||
- 26656
|
||||
- 26657
|
||||
|
||||
It also implicitly creates a Docker volume called `wasmd_data` such that just
|
||||
the contents of the `/root` directory in the container persist across restarts.
|
||||
To wipe this volume and start from scratch, simply terminate the container and
|
||||
run:
|
||||
|
||||
```bash
|
||||
docker volume rm wasmd_data
|
||||
```
|
||||
|
||||
## Building the image
|
||||
|
||||
To build the image without running it, simply run:
|
||||
|
||||
```bash
|
||||
make
|
||||
```
|
||||
|
||||
This will, by default, build a Docker image tagged `informaldev/wasmd:v0.44.0`.
|
||||
|
||||
## Querying accounts in the container
|
||||
|
||||
To query, for example, the `admin` account's balance, where the `admin`
|
||||
account's address is `wasm1mkrm9m8g0dzv5z73xg8yzlj6srqc72qru5xfv3`, once the
|
||||
Docker container is running, in a separate terminal run:
|
||||
|
||||
```bash
|
||||
# The first "wasmd" indicates the name of the running Docker container, whereas
|
||||
# the second "wasmd" indicates the name of the command to run inside the
|
||||
# container.
|
||||
docker exec -it wasmd \
|
||||
wasmd query bank balances wasm1mkrm9m8g0dzv5z73xg8yzlj6srqc72qru5xfv3
|
||||
```
|
||||
|
||||
You should see output like:
|
||||
|
||||
```bash
|
||||
balances:
|
||||
- amount: "12000000000000"
|
||||
denom: ucosm
|
||||
- amount: "12000000000000"
|
||||
denom: ustake
|
||||
pagination:
|
||||
next_key: null
|
||||
total: "0"
|
||||
```
|
||||
|
||||
[wasmd]: https://github.com/CosmWasm/wasmd
|
11
docker/wasmd/accounts/admin.txt
Normal file
11
docker/wasmd/accounts/admin.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
- address: wasm1mkrm9m8g0dzv5z73xg8yzlj6srqc72qru5xfv3
|
||||
name: admin
|
||||
pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"Ax3A4I9zO4eI9+3YuU4s2wAy7vQZANa7SgdCjvgkE592"}'
|
||||
type: local
|
||||
|
||||
|
||||
**Important** write this mnemonic phrase in a safe place.
|
||||
It is the only way to recover your account if you ever forget your password.
|
||||
|
||||
scrap toss pottery food asset question utility uncle napkin glare sketch poet entire column comfort traffic hurdle person annual quick party crumble slab tissue
|
11
docker/wasmd/accounts/alice.txt
Normal file
11
docker/wasmd/accounts/alice.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
- address: wasm19azg82cx3qx88gar8nl08rz7x0p27amtmadfep
|
||||
name: alice
|
||||
pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AjTyNLPEA3jD6+BUogvEowwjKi9XjVlJ09RDnc4mhlcR"}'
|
||||
type: local
|
||||
|
||||
|
||||
**Important** write this mnemonic phrase in a safe place.
|
||||
It is the only way to recover your account if you ever forget your password.
|
||||
|
||||
grain shoe diamond mix chunk turn odor across reduce room smart napkin scale ghost emotion stove mistake someone account snow country rail boy rescue
|
11
docker/wasmd/accounts/bob.txt
Normal file
11
docker/wasmd/accounts/bob.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
- address: wasm1adcnk7lt6qst7p5d0g5607e28k77um7nxwxuqy
|
||||
name: bob
|
||||
pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A7IHJ0ihzXP/pQqhCQxH7+qsMEvarKWaVsYqzPeblAn+"}'
|
||||
type: local
|
||||
|
||||
|
||||
**Important** write this mnemonic phrase in a safe place.
|
||||
It is the only way to recover your account if you ever forget your password.
|
||||
|
||||
inmate surface cement any mule sweet what hamster rent ridge series equip equal supply plunge mango mystery chase other economy build pool coyote enter
|
11
docker/wasmd/accounts/charlie.txt
Normal file
11
docker/wasmd/accounts/charlie.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
- address: wasm1jn34x50hy3my0a2mxwcx8fttgfxu2n5gpvu0ty
|
||||
name: charlie
|
||||
pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A9LnFBufvSFCF+aRd3eIB9sSLcguFHOsGJZsaN9D/zx7"}'
|
||||
type: local
|
||||
|
||||
|
||||
**Important** write this mnemonic phrase in a safe place.
|
||||
It is the only way to recover your account if you ever forget your password.
|
||||
|
||||
wrestle garage wrist bread woman depart service butter sorry soup tunnel gorilla absurd mansion obtain since security hair okay sense fly keep door inject
|
Loading…
Reference in a new issue