Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: readme makefile update #219

Merged
merged 13 commits into from
May 2, 2023
72 changes: 72 additions & 0 deletions Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# syntax=docker/dockerfile:1

ARG GO_VERSION="1.20.0"
ARG RUNNER_IMAGE="gcr.io/distroless/static"

# --------------------------------------------------------
# Builder
# --------------------------------------------------------

FROM golang:${GO_VERSION}-alpine as builder

ARG GIT_VERSION
ARG GIT_COMMIT
ARG BUILD_TAGS
ARG ENABLED_PROPOSALS

RUN apk add --no-cache \
ca-certificates \
build-base \
linux-headers

# Download go dependencies
WORKDIR /neutron
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
go mod download

# Cosmwasm - Download correct libwasmvm version
RUN WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 2) && \
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$(uname -m).a \
-O /lib/libwasmvm_muslc.a && \
# verify checksum
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \
sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$(uname -m) | cut -d ' ' -f 1)

# Copy the remaining files
COPY . .

# Build neutrond binary
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
go build \
-mod=readonly \
-tags "netgo,ledger,muslc" \
-ldflags "-X github.com/cosmos/cosmos-sdk/version.Name="neutron" \
-X github.com/cosmos/cosmos-sdk/version.AppName="neutrond" \
-X github.com/cosmos/cosmos-sdk/version.Version=${GIT_VERSION} \
-X github.com/cosmos/cosmos-sdk/version.Commit=${GIT_COMMIT} \
-X github.com/cosmos/cosmos-sdk/version.BuildTags='${BUILD_TAGS}' \
-X github.com/neutron-org/neutron/app.EnableSpecificProposals=${ENABLED_PROPOSALS} \
-w -s -linkmode=external -extldflags '-Wl,-z,muldefs -static'" \
-trimpath \
-o /neutron/build/neutrond \
/neutron/cmd/neutrond

# --------------------------------------------------------
# Runner
# --------------------------------------------------------

FROM ${RUNNER_IMAGE}

COPY --from=builder /neutron/build/neutrond /bin/neutrond

ENV HOME /neutron
WORKDIR $HOME

EXPOSE 26656
EXPOSE 26657
EXPOSE 1317

ENTRYPOINT ["neutrond"]
23 changes: 22 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ LEDGER_ENABLED ?= true
SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
BINDIR ?= $(GOPATH)/bin
SIMAPP = ./app
ENABLED_PROPOSALS := SudoContract,UpdateAdmin,ClearAdmin,PinCodes,UnpinCodes
GO_VERSION=1.20.0
BUILDDIR ?= $(CURDIR)/build

# for dockerized protobuf tools
DOCKER := $(shell which docker)
Expand Down Expand Up @@ -65,7 +68,7 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=neutron \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \
-X "github.com/neutron-org/neutron/app.EnableSpecificProposals=MigrateContract,SudoContract,UpdateAdmin,ClearAdmin,PinCodes,UnpinCodes"
-X "github.com/neutron-org/neutron/app.EnableSpecificProposals=$(ENABLED_PROPOSALS)"

ifeq ($(WITH_CLEVELDB),yes)
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
Expand Down Expand Up @@ -94,6 +97,24 @@ else
go build -mod=readonly $(BUILD_FLAGS) -o build/neutrond ./cmd/neutrond
endif

build-static-linux-amd64: go.sum $(BUILDDIR)/
$(DOCKER) buildx create --name neutronbuilder || true
$(DOCKER) buildx use neutronbuilder
$(DOCKER) buildx build \
--build-arg GO_VERSION=$(GO_VERSION) \
--build-arg GIT_VERSION=$(VERSION) \
--build-arg GIT_COMMIT=$(COMMIT) \
--build-arg BUILD_TAGS=$(build_tags_comma_sep) \
--build-arg ENABLED_PROPOSALS=$(ENABLED_PROPOSALS) \
--platform linux/amd64 \
-t neutron-amd64 \
--load \
-f Dockerfile.builder .
$(DOCKER) rm -f neutronbinary || true
$(DOCKER) create -ti --name neutronbinary neutron-amd64
$(DOCKER) cp neutronbinary:/bin/neutrond $(BUILDDIR)/neutrond-linux-amd64
$(DOCKER) rm -f neutronbinary

install: check_version go.sum
go install -mod=readonly $(BUILD_FLAGS) ./cmd/neutrond

Expand Down
94 changes: 4 additions & 90 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,99 +1,13 @@
![Neutron](https://github.com/neutron-org/neutron-docs/blob/1db1e92098c915ae8ad4defc0bd30ef549175201/static/img/neutron_wide_logo.png)
# Neutron


**NOTE: current version is a WIP.**

## Requirements
* Go 1.18
* Ignite Cli
* Hermes IBC Relayer

### How to install Ignite CLI

```shell
curl https://get.ignite.com/cli! | bash
```

### How to install Hermes IBC Relayer

For current CCV modules support there is not any suitable version of hermes, so you need to build it by yourself.

```shell
git clone https://github.com/informalsystems/hermes.git
cd hermes
git checkout 7defaf067dbe6f60588518ea1619f228d38ac48d
cargo build --release --bin hermes
```

## Build and Install Neutron Zone

```shell
make install
```

## Run local testnet node instances connected via IBC

### Bootstrap two chains and create an IBC connection

In order to bootstrap two chains it is required to clone gaiad v7.0.3 next to `neutron` repository and install it.

```shell
git clone https://github.com/cosmos/gaia.git
cd gaia
git checkout v7.0.3
make install
```

after that you can turn back into `neutron` directory and run:

```shell
make init
```

### Start relayer

```shell
make start-rly
```

## Generate proto

```shell
ignite generate proto-go
```

## Running with docker

Build the image:
```shell
make build-docker-image
```

After the image is built, you can start/stop with:
```shell
make start-docker-container
make stop-docker-container
```

## Running with docker + relayer

```shell
ssh-add ./.ssh/id_rsa
make start-cosmopark
make stop-cosmopark
```

Make sure you delete node image if you use the whole thing in dev purposes
```shell
@docker rmi neutron-node
```

## Documentation

You can check the documentation here: https://neutron-org.github.io/neutron-docs/
You can check the documentation here: https://docs.neutron.org/

## Build

> Note: we are going to open & deploy the docs soon.
You can check out the build instructions here: https://docs.neutron.org/neutron/build

## Examples

Expand Down