Skip to content

Commit

Permalink
Merge pull request #148 from CosmWasm/update-to-0.9
Browse files Browse the repository at this point in the history
Update to 0.9
  • Loading branch information
ethanfrey authored Jun 22, 2020
2 parents a603001 + 1915bb0 commit 8cf06b9
Show file tree
Hide file tree
Showing 17 changed files with 157 additions and 102 deletions.
19 changes: 12 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ jobs:
- checkout
- setup_remote_docker
- run:
name: Build Docker artifact - demo
command: docker build --pull -t "cosmwasm/wasmd-demo:${CIRCLE_SHA1}" .
name: Build Docker artifact
command: docker build --pull -t "cosmwasm/wasmd:${CIRCLE_SHA1}" .
- run:
name: Push application Docker image to docker hub
command: |
if [ "${CIRCLE_BRANCH}" = "master" ]; then
docker tag "cosmwasm/wasmd-demo:${CIRCLE_SHA1}" cosmwasm/wasmd-demo:latest
docker tag "cosmwasm/wasmd:${CIRCLE_SHA1}" cosmwasm/wasmd:latest
docker login --password-stdin -u "$DOCKER_USER" \<<<"$DOCKER_PASS"
docker push cosmwasm/wasmd-demo:latest
docker push cosmwasm/wasmd:latest
docker logout
fi
Expand All @@ -209,13 +209,13 @@ jobs:
- checkout
- setup_remote_docker
- run:
name: Build Docker artifact - demo
command: docker build --pull -t "cosmwasm/wasmd-demo:${CIRCLE_TAG}" .
name: Build Docker artifact
command: docker build --pull -t "cosmwasm/wasmd:${CIRCLE_TAG}" .
- run:
name: Push application Docker image to docker hub
command: |
docker login --password-stdin -u "$DOCKER_USER" \<<<"$DOCKER_PASS"
docker push "cosmwasm/wasmd-demo:${CIRCLE_TAG}"
docker push "cosmwasm/wasmd:${CIRCLE_TAG}"
docker logout
reproducible-builds:
Expand Down Expand Up @@ -261,9 +261,14 @@ workflows:
version: 2
test-suite:
jobs:
# this is now a slow process... let's only run on master
- docker-image:
requires:
- setup-dependencies
filters:
branches:
only:
- master
- docker-tagged:
filters:
tags:
Expand Down
63 changes: 37 additions & 26 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,39 @@
# Simple usage with a mounted data directory:
# > docker build -t gaia .
# > docker run -it -p 46657:46657 -p 46656:46656 -v ~/.wasmd:/root/.wasmd -v ~/.wasmcli:/root/.wasmcli gaia wasmd init
# > docker run -it -p 46657:46657 -p 46656:46656 -v ~/.wasmd:/root/.wasmd -v ~/.wasmcli:/root/.wasmcli gaia wasmd start
FROM golang:1.13-buster AS build-env

# Install minimum necessary dependencies, build Cosmos SDK, remove packages
RUN apt update
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
WORKDIR /go/src/github.com/CosmWasm/wasmd

# Add source files
COPY . .
#
RUN make tools
RUN make install

# Install libgo_cosmwasm.so to a shared directory where it is readable by all users
# See https://github.com/CosmWasm/wasmd/issues/43#issuecomment-608366314
# Note that CosmWasm gets turned into !cosm!wasm in the pkg/mod cache
RUN cp /go/pkg/mod/github.com/\!cosm\!wasm/go-cosmwasm@v*/api/libgo_cosmwasm.so /lib/x86_64-linux-gnu
# docker build . -t cosmwasm/wasm:latest
# docker run --rm -it cosmwasm/wasm:latest /bin/sh
FROM cosmwasm/go-ext-builder:0.8.2-alpine AS builder

RUN apk add git
# without this, build with LEDGER_ENABLED=false
RUN apk add libusb-dev linux-headers

# copy all code into /code
WORKDIR /code
COPY . /code

# download all deps
RUN go mod download
# TODO: how to use this instead of hardcoding GO_COSMWASM
RUN basename $(ls -d /go/pkg/mod/github.com/\!cosm\!wasm/go-cosmwasm@v*)

ENV GO_COSMWASM="v0.9.0-alpha2"

# build go-cosmwasm *.a and install it
WORKDIR /go/pkg/mod/github.com/\!cosm\!wasm/go-cosmwasm@${GO_COSMWASM}
RUN cargo build --release --features backtraces --example muslc
RUN mv /go/pkg/mod/github.com/\!cosm\!wasm/go-cosmwasm@${GO_COSMWASM}/target/release/examples/libmuslc.a /lib/libgo_cosmwasm_muslc.a
# I got errors from go mod verify (called from make build) if I didn't clean this up
RUN rm -rf /go/pkg/mod/github.com/\!cosm\!wasm/go-cosmwasm@${GO_COSMWASM}/target

# build the go wasm binary
WORKDIR /code

# force it to use static lib (from above) not standard libgo_cosmwasm.so file
RUN BUILD_TAGS=muslc make build

FROM alpine:3.12

COPY --from=builder /code/build/wasmd /usr/bin/wasmd
COPY --from=builder /code/build/wasmcli /usr/bin/wasmcli

COPY docker/* /opt/
RUN chmod +x /opt/*.sh
Expand All @@ -36,4 +47,4 @@ EXPOSE 26656
# tendermint rpc
EXPOSE 26657

CMD ["wasmd"]
CMD ["/usr/bin/wasmd version"]
39 changes: 39 additions & 0 deletions Dockerfile.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Simple usage with a mounted data directory:
# > docker build -t gaia .
# > docker run -it -p 46657:46657 -p 46656:46656 -v ~/.wasmd:/root/.wasmd -v ~/.wasmcli:/root/.wasmcli gaia wasmd init
# > docker run -it -p 46657:46657 -p 46656:46656 -v ~/.wasmd:/root/.wasmd -v ~/.wasmcli:/root/.wasmcli gaia wasmd start
FROM golang:1.13-buster AS build-env

# Install minimum necessary dependencies, build Cosmos SDK, remove packages
RUN apt update
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
WORKDIR /go/src/github.com/cosmwasm/wasmd

# Add source files
COPY . .
#
RUN make tools
RUN make install

# Install libgo_cosmwasm.so to a shared directory where it is readable by all users
# See https://github.com/CosmWasm/wasmd/issues/43#issuecomment-608366314
# Note that CosmWasm gets turned into !cosm!wasm in the pkg/mod cache
RUN cp /go/pkg/mod/github.com/\!cosm\!wasm/go-cosmwasm@v*/api/libgo_cosmwasm.so /lib/x86_64-linux-gnu

COPY docker/* /opt/
RUN chmod +x /opt/*.sh

WORKDIR /opt

# rest server
EXPOSE 1317
# tendermint p2p
EXPOSE 26656
# tendermint rpc
EXPOSE 26657

CMD ["wasmd"]
15 changes: 10 additions & 5 deletions INTEGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ hardware it runs on.
| v0.7 | v0.38 |
| v0.8 | v0.38 |

We currently only support Intel/AMD64 CPUs and OSX or Linux (with glibc - not muslc like alpine).
This limit comes from the Rust dll we use to run the wasm code. There are open issues
for adding [ARM support](https://github.com/CosmWasm/go-cosmwasm/issues/53),
adding [Windows support](https://github.com/CosmWasm/go-cosmwasm/issues/28),
and [compiling static binaries](https://github.com/CosmWasm/go-cosmwasm/issues/45), so it works on both glibc and muslc systems.
We currently only support Intel/AMD64 CPUs and OSX or Linux. For Linux, the standard build
commands work for `glibc` systems (Ubuntu, Debian, CentOS, etc). If you wish to compile
for a `muslc` based system (like alpine), you need to compile a static library go-cosmwasm locally
and compile go with the `muslc` build tag. Or just use the [Dockerfile](./Dockerfile),
which builds a static go binary in an alpine system.

This limit comes from the Rust dll we use to run the wasm code, which comes
from [`go-cosmwasm`](https://github.com/CosmWasm/go-cosmwasm). There are open issues
for adding [ARM support](https://github.com/CosmWasm/go-cosmwasm/issues/53), and
adding [Windows support](https://github.com/CosmWasm/go-cosmwasm/issues/28).
However, these issues are not high on the roadmap and unless you are championing
them, please count on the current limits for the near future.

Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ If you want to deploy a whole cluster, [look at the network scripts](./networks/

We provide a docker image to help with test setups. There are two modes to use it

Build: `docker build -t cosmwasm/wasmd:manual .` or pull from dockerhub
Build: `docker build -t cosmwasm/wasmd:latest .` 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 these scripts in production.
Very likely you will assign tokens to accounts whose mnemonics are public on github.

```sh
docker volume rm -f wasmd_data
Expand All @@ -65,17 +66,17 @@ docker volume rm -f wasmd_data
docker run --rm -it \
-e PASSWORD=xxxxxxxxx \
--mount type=volume,source=wasmd_data,target=/root \
cosmwasm/wasmd-demo:latest ./setup.sh cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6
cosmwasm/wasmd:latest ./setup.sh cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6

# 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 \
--mount type=volume,source=wasmd_data,target=/root \
cosmwasm/wasmd-demo:latest ./run_all.sh
cosmwasm/wasmd:latest ./run_all.sh

# view wasmd logs in another shell
docker run --rm -it \
--mount type=volume,source=wasmd_data,target=/root,readonly \
cosmwasm/wasmd-demo:latest ./logs.sh
cosmwasm/wasmd:latest ./logs.sh
```

### CI
Expand All @@ -88,7 +89,7 @@ rm -rf ./template && mkdir ./template
docker run --rm -it \
-e PASSWORD=xxxxxxxxx \
--mount type=bind,source=$(pwd)/template,target=/root \
cosmwasm/wasmd-demo:latest ./setup.sh cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6
cosmwasm/wasmd:latest ./setup.sh cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6

sudo chown -R $(id -u):$(id -g) ./template

Expand All @@ -99,17 +100,17 @@ 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 \
cosmwasm/wasmd-demo:latest ./run_all.sh /template
cosmwasm/wasmd:latest ./run_all.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 \
cosmwasm/wasmd-demo:latest ./run_all.sh
cosmwasm/wasmd:latest ./run_all.sh

# view wasmd logs in another shell
docker run --rm -it \
--mount type=volume,source=wasmd_data,target=/root,readonly \
cosmwasm/wasmd-demo:latest ./logs.sh
cosmwasm/wasmd:latest ./logs.sh
```

## Contributors
Expand Down
2 changes: 1 addition & 1 deletion docker/logs.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
#!/bin/sh

tail -f /root/log/wasmd.log
8 changes: 4 additions & 4 deletions docker/run_all.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash
set -euo pipefail
#!/bin/sh
#set -euo pipefail

mkdir -p /root/log
touch /root/log/wasmd.log
./run_wasmd.sh >> /root/log/wasmd.log &
./run_wasmd.sh $1 >> /root/log/wasmd.log &

sleep 4
echo Starting Rest Server...

./run_wasmcli.sh
./run_rest_server.sh
4 changes: 2 additions & 2 deletions docker/run_rest_server.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
set -euo pipefail
#!/bin/sh
#set -euo pipefail

wasmcli rest-server --laddr tcp://0.0.0.0:1317 --trust-node --cors
2 changes: 1 addition & 1 deletion docker/run_wasmd.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

if test -n "$1"; then
# need -R not -r to copy hidden files
Expand Down
4 changes: 2 additions & 2 deletions docker/setup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail
#!/bin/sh
#set -o errexit -o nounset -o pipefail

PASSWORD=${PASSWORD:-1234567890}
STAKE=${STAKE_TOKEN:-ustake}
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module github.com/CosmWasm/wasmd
go 1.14

require (
github.com/CosmWasm/go-cosmwasm v0.8.2-0.20200608192602-082a8c18f964
// Note: update ENV GO_COSMWASM in Dockerfile when updating this
github.com/CosmWasm/go-cosmwasm v0.9.0-alpha2
github.com/cosmos/cosmos-sdk v0.34.4-0.20200530180557-ba70f4d4dc2e
github.com/gogo/protobuf v1.3.1
github.com/gorilla/mux v1.7.4
Expand Down
Loading

0 comments on commit 8cf06b9

Please sign in to comment.