-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Docker container publish * Add Docker container publish * Add Docker container publish * Remove github actions build step * Remove duplicate dist
- Loading branch information
Showing
8 changed files
with
240 additions
and
699 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Simple usage with a mounted data directory: | ||
# > docker build -t simapp . | ||
## syntax=docker/dockerfile:1 | ||
|
||
ARG GO_VERSION="1.18" | ||
ARG RUNNER_IMAGE="gcr.io/distroless/static" | ||
|
||
# -------------------------------------------------------- | ||
# Builder | ||
# -------------------------------------------------------- | ||
|
||
FROM golang:${GO_VERSION}-alpine as builder | ||
|
||
ARG GIT_VERSION | ||
ARG GIT_COMMIT | ||
|
||
RUN apk add --no-cache \ | ||
ca-certificates \ | ||
build-base \ | ||
linux-headers | ||
|
||
# Download go dependencies | ||
WORKDIR /sonr | ||
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 $(uname -m) | cut -d ' ' -f 1) | ||
|
||
# Copy the remaining files | ||
COPY . . | ||
|
||
# Build sonrd 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="sonr" \ | ||
-X github.com/cosmos/cosmos-sdk/version.AppName="sonrd" \ | ||
-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='netgo,ledger,muslc' \ | ||
-w -s -linkmode=external -extldflags '-Wl,-z,muldefs -static'" \ | ||
-trimpath \ | ||
-o /sonr/build/sonrd \ | ||
/sonr/cmd/sonrd/main.go | ||
|
||
# -------------------------------------------------------- | ||
# Runner | ||
# -------------------------------------------------------- | ||
|
||
FROM ${RUNNER_IMAGE} | ||
|
||
COPY --from=builder /sonr/build/sonrd /bin/sonrd | ||
|
||
ENV HOME /sonr | ||
WORKDIR $HOME | ||
|
||
EXPOSE 26656 | ||
EXPOSE 26657 | ||
EXPOSE 1317 | ||
EXPOSE 9090 | ||
|
||
ENTRYPOINT ["sonrd"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,108 @@ SHELL=/bin/bash | |
# Set this -->[/Users/xxxx/Sonr/]<-- to Folder of Sonr Repos | ||
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) | ||
SCRIPTS_DIR=$(ROOT_DIR)/scripts | ||
PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation') | ||
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation') | ||
export VERSION := $(shell echo $(shell git describe --always --match "v*") | sed 's/^v//') | ||
export TMVERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::') | ||
export COMMIT := $(shell git log -1 --format='%H') | ||
LEDGER_ENABLED ?= false | ||
BINDIR ?= $(GOPATH)/bin | ||
BUILDDIR ?= $(CURDIR)/build | ||
MOCKS_DIR = $(CURDIR)/tests/mocks | ||
HTTPS_GIT := https://github.com/sonr-io/sonr.git | ||
DOCKER := $(shell which docker) | ||
PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git) | ||
# RocksDB is a native dependency, so we don't assume the library is installed. | ||
# Instead, it must be explicitly enabled and we warn when it is not. | ||
ENABLE_ROCKSDB ?= true | ||
|
||
# process build tags | ||
build_tags = netgo | ||
ifeq ($(LEDGER_ENABLED),true) | ||
ifeq ($(OS),Windows_NT) | ||
GCCEXE = $(shell where gcc.exe 2> NUL) | ||
ifeq ($(GCCEXE),) | ||
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false) | ||
else | ||
build_tags += ledger | ||
endif | ||
else | ||
UNAME_S = $(shell uname -s) | ||
ifeq ($(UNAME_S),OpenBSD) | ||
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988)) | ||
else | ||
GCC = $(shell command -v gcc 2> /dev/null) | ||
ifeq ($(GCC),) | ||
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false) | ||
else | ||
build_tags += ledger | ||
endif | ||
endif | ||
endif | ||
endif | ||
|
||
ifeq (secp,$(findstring secp,$(COSMOS_BUILD_OPTIONS))) | ||
build_tags += libsecp256k1_sdk | ||
endif | ||
|
||
whitespace := | ||
whitespace += $(whitespace) | ||
comma := , | ||
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags)) | ||
|
||
# process linker flags | ||
|
||
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=sonr \ | ||
-X github.com/cosmos/cosmos-sdk/version.AppName=sonrd \ | ||
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \ | ||
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \ | ||
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TMVERSION) | ||
|
||
ifeq ($(ENABLE_ROCKSDB),true) | ||
BUILD_TAGS += rocksdb_build | ||
test_tags += rocksdb_build | ||
endif | ||
|
||
# DB backend selection | ||
ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS))) | ||
build_tags += gcc | ||
endif | ||
ifeq (badgerdb,$(findstring badgerdb,$(COSMOS_BUILD_OPTIONS))) | ||
BUILD_TAGS += badgerdb | ||
endif | ||
# handle rocksdb | ||
ifeq (rocksdb,$(findstring rocksdb,$(COSMOS_BUILD_OPTIONS))) | ||
ifneq ($(ENABLE_ROCKSDB),true) | ||
$(error Cannot use RocksDB backend unless ENABLE_ROCKSDB=true) | ||
endif | ||
CGO_ENABLED=1 | ||
BUILD_TAGS += rocksdb | ||
endif | ||
# handle boltdb | ||
ifeq (boltdb,$(findstring boltdb,$(COSMOS_BUILD_OPTIONS))) | ||
BUILD_TAGS += boltdb | ||
endif | ||
|
||
ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS))) | ||
ldflags += -w -s | ||
endif | ||
ldflags += $(LDFLAGS) | ||
ldflags := $(strip $(ldflags)) | ||
|
||
build_tags += $(BUILD_TAGS) | ||
build_tags := $(strip $(build_tags)) | ||
|
||
BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)' | ||
# check for nostrip option | ||
ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS))) | ||
BUILD_FLAGS += -trimpath | ||
endif | ||
|
||
# Check for debug option | ||
ifeq (debug,$(findstring debug,$(COSMOS_BUILD_OPTIONS))) | ||
BUILD_FLAGS += -gcflags "all=-N -l" | ||
endif | ||
|
||
all: Makefile | ||
@echo '' | ||
|
@@ -37,10 +139,51 @@ bind.tar: | |
TAR_COMPRESS=true && sh $(SCRIPTS_DIR)/bind.sh -w | ||
|
||
## build : Builds macos and ubuntu releases for Sonr | ||
build: | ||
env GOOS=linux GOARCH=amd64 go build -o ./build/sonr-linux-amd64 ./cmd/sonrd/main.go | ||
env GOOS=linux GOARCH=arm64 go build -o ./build/sonr-linux-arm64 ./cmd/sonrd/main.go | ||
env GOOS=darwin GOARCH=amd64 go build -o ./build/sonr-darwin-amd64 ./cmd/sonrd/main.go | ||
# build: | ||
# env GOOS=linux GOARCH=amd64 go build -o ./build/sonr-linux-amd64 ./cmd/sonrd/main.go | ||
# env GOOS=linux GOARCH=arm64 go build -o ./build/sonr-linux-arm64 ./cmd/sonrd/main.go | ||
# env GOOS=darwin GOARCH=amd64 go build -o ./build/sonr-darwin-amd64 ./cmd/sonrd/main.go | ||
|
||
BUILD_TARGETS := build install | ||
|
||
build: BUILD_ARGS=-o $(BUILDDIR)/ | ||
|
||
build-linux-amd64: | ||
GOOS=linux GOARCH=amd64 LEDGER_ENABLED=false $(MAKE) build | ||
|
||
build-linux-arm64: | ||
GOOS=linux GOARCH=arm64 LEDGER_ENABLED=false $(MAKE) build | ||
|
||
$(BUILD_TARGETS): go.sum $(BUILDDIR)/ | ||
go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./... | ||
|
||
$(BUILDDIR)/: | ||
mkdir -p $(BUILDDIR)/ | ||
|
||
cosmovisor: | ||
$(MAKE) -C tools/cosmovisor cosmovisor | ||
|
||
.PHONY: build build-linux-amd64 build-linux-arm64 cosmovisor | ||
|
||
|
||
mocks: $(MOCKS_DIR) | ||
@go install github.com/golang/mock/[email protected] | ||
sh ./scripts/mockgen.sh | ||
.PHONY: mocks | ||
|
||
$(MOCKS_DIR): | ||
mkdir -p $(MOCKS_DIR) | ||
|
||
distclean: clean tools-clean | ||
clean: | ||
rm -rf \ | ||
$(BUILDDIR)/ \ | ||
artifacts/ \ | ||
tmp-swagger-gen/ | ||
|
||
.PHONY: distclean clean | ||
|
||
|
||
|
||
## proto : Compiles Go Proto Files and pushes to Buf.Build | ||
proto: proto.go proto.buf | ||
|
@@ -61,10 +204,3 @@ proto.publish: | |
cd $(ROOT_DIR)/proto && buf mod update && buf build | ||
@echo "✅ Pushed Protos to Buf.Build" | ||
cp -r proto/ build/proto/ | ||
|
||
## clean : Clean all artifacts and tidy | ||
clean: | ||
rm -rf ./build | ||
rm -rf ./tmp | ||
rm -rf ./dist | ||
go mod tidy |
Oops, something went wrong.