Skip to content

Commit

Permalink
Docker build for running enigma devnet (#1)
Browse files Browse the repository at this point in the history
* docker dev build
  • Loading branch information
levackt authored Apr 8, 2020
1 parent 7182bee commit 168d64f
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 2 deletions.
56 changes: 56 additions & 0 deletions Dockerfile_devnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Simple usage with a mounted data directory:
# > docker build -t enigma .
# > docker run -it -p 26657:26657 -p 26656:26656 -v ~/.enigmad:/root/.enigmad -v ~/.enigmacli:/root/.enigmacli enigma enigmad init
# > docker run -it -p 26657:26657 -p 26656:26656 -v ~/.enigmad:/root/.enigmad -v ~/.enigmacli:/root/.enigmacli enigma enigmad start
FROM rust:1.42-stretch AS build-env-rust

# Set working directory for the build
WORKDIR /go/src/github.com/enigmampc/enigmablockchain

RUN rustup default nightly

# Add source files
COPY go-cosmwasm/ go-cosmwasm/

WORKDIR /go/src/github.com/enigmampc/enigmablockchain/go-cosmwasm
RUN cargo build --release --features backtraces

FROM golang:1.14-stretch AS build-env

# Set up dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
make \
git && \
rm -rf /var/lib/apt/lists/*

# Set working directory for the build
WORKDIR /go/src/github.com/enigmampc/enigmablockchain

# Add source files
COPY . .

COPY --from=build-env-rust /go/src/github.com/enigmampc/enigmablockchain/go-cosmwasm/target/release/libgo_cosmwasm.so go-cosmwasm/api

RUN go mod tidy

RUN make build_local_no_rust

# Final image
FROM ubuntu:18.04

# Install ca-certificates
WORKDIR /root

# Copy over binaries from the build-env
COPY --from=build-env-rust /go/src/github.com/enigmampc/enigmablockchain/go-cosmwasm/target/release/libgo_cosmwasm.so /usr/lib/
COPY --from=build-env /go/src/github.com/enigmampc/enigmablockchain/enigmad /usr/bin/enigmad
COPY --from=build-env /go/src/github.com/enigmampc/enigmablockchain/enigmacli /usr/bin/enigmacli

COPY ./packaging_docker/devnet_init.sh .

RUN chmod +x /usr/bin/enigmad
RUN chmod +x /usr/bin/enigmacli

# Run enigmad by default, omit entrypoint to ease using container with enigmacli
ENTRYPOINT ["/bin/bash", "devnet_init.sh"]
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ xgo_build_enigmad: go.sum
xgo_build_enigmacli: go.sum
xgo --go latest --targets $(XGO_TARGET) $(BUILD_FLAGS) github.com/enigmampc/EnigmaBlockchain/cmd/enigmacli

build_local_no_rust:
@ #this pulls out ELF symbols, 80% size reduction!
go build -mod=readonly $(BUILD_FLAGS) ./cmd/enigmad
go build -mod=readonly $(BUILD_FLAGS) ./cmd/enigmacli

build_local:
cd go-cosmwasm && rustup run nightly cargo build --release --features backtraces
cp go-cosmwasm/target/release/libgo_cosmwasm.so go-cosmwasm/api
Expand Down
17 changes: 15 additions & 2 deletions docs/dev/for-enigma-blockchain-devs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

**Requirement**: Go version needs to be [1.13 or higher](https://golang.org/dl/).

# Developers Quick Start

## Local installation

```bash
git clone https://github.com/enigmampc/EnigmaBlockchain
cd EnigmaBlockchain
go mod tidy
make install # installs enigmad and enigmacli
```

# Developers Quick Start

```bash
enigmacli config chain-id enigma-testnet # now we won't need to type --chain-id enigma-testnet every time
enigmacli config output json
Expand Down Expand Up @@ -41,6 +43,17 @@ enigmad validate-genesis # make sure genesis file is correct
enigmad start --pruning nothing # starts a node
```

## Docker installation

```bash
git clone https://github.com/enigmampc/EnigmaBlockchain
cd EnigmaBlockchain
docker build -t enigmadev -f Dockerfile_devnet .

docker run -d -p 26657:26657 -p 26656:26656 -p 1317:1317 \
--name enigmadev enigmadev
```

# Delegation & Rewards

## `b` is a delegator of `a`
Expand Down
29 changes: 29 additions & 0 deletions packaging_docker/devnet_init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

enigmacli config chain-id enigma-testnet # now we won't need to type --chain-id enigma-testnet every time
enigmacli config output json
enigmacli config indent true
enigmacli config trust-node true # true if you trust the full-node you are connecting to, false otherwise

enigmad init banana --chain-id enigma-testnet # banana==moniker==user-agent of this node
perl -i -pe 's/"stake"/"uscrt"/g' ~/.enigmad/config/genesis.json # change the default staking denom from stake to uscrt

enigmacli keys add a --keyring-backend test
enigmacli keys add b --keyring-backend test

enigmad add-genesis-account $(enigmacli keys show -a a --keyring-backend test) 1000000000000uscrt # 1 SCRT == 10^6 uSCRT
enigmad add-genesis-account $(enigmacli keys show -a b --keyring-backend test) 2000000000000uscrt # 1 SCRT == 10^6 uSCRT

enigmad validate-genesis # make sure genesis file is correct

# `enigmad export` to send genesis.json to validators

enigmad gentx --name a --amount 1000000uscrt --keyring-backend test # generate a genesis transaction - this makes a a validator on genesis which stakes 1000000uscrt (1 SCRT)

enigmad collect-gentxs # input the genTx into the genesis file, so that the chain is aware of the validators

enigmad validate-genesis # make sure genesis file is correct

# `enigmad export` to send genesis.json to validators

enigmad start --pruning nothing # starts a node

0 comments on commit 168d64f

Please sign in to comment.