update build file

This commit is contained in:
Solovyov1796 2024-05-01 12:25:00 +08:00 committed by 0g-wh
parent c7bb0576d3
commit ae3240e703
4 changed files with 37 additions and 34 deletions

View File

@ -7,7 +7,7 @@ FROM golang:1.21-alpine AS build-env
RUN apk add bash git make libc-dev gcc linux-headers eudev-dev jq curl RUN apk add bash git make libc-dev gcc linux-headers eudev-dev jq curl
# Set working directory for the build # Set working directory for the build
WORKDIR /root/kava WORKDIR /root/0g-chain
# default home directory is /root # default home directory is /root
# Copy dependency files first to facilitate dependency caching # Copy dependency files first to facilitate dependency caching
@ -32,6 +32,6 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
FROM alpine:3.15 FROM alpine:3.15
RUN apk add bash jq curl RUN apk add bash jq curl
COPY --from=build-env /go/bin/kava /bin/kava COPY --from=build-env /go/bin/0gchaind /bin/0gchaind
CMD ["kava"] CMD ["0gchaind"]

View File

@ -1,4 +1,4 @@
FROM golang:1.21-bullseye AS kava-builder FROM golang:1.20-bullseye AS chain-builder
# Set up dependencies # Set up dependencies
RUN apt-get update \ RUN apt-get update \
@ -19,7 +19,7 @@ RUN git clone https://github.com/facebook/rocksdb.git \
&& make -j$(nproc) install-shared \ && make -j$(nproc) install-shared \
&& ldconfig && ldconfig
WORKDIR /root/kava WORKDIR /root/0gchain
# Copy dependency files first to facilitate dependency caching # Copy dependency files first to facilitate dependency caching
COPY ./go.mod ./ COPY ./go.mod ./
COPY ./go.sum ./ COPY ./go.sum ./
@ -32,13 +32,13 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
# Add source files # Add source files
COPY . . COPY . .
ARG kava_database_backend=rocksdb ARG 0gchain_database_backend=rocksdb
ENV KAVA_DATABASE_BACKEND=$kava_database_backend ENV 0GCHAIN_DATABASE_BACKEND=$0gchain_database_backend
# Mount go build and mod caches as container caches, persisted between builder invocations # Mount go build and mod caches as container caches, persisted between builder invocations
RUN --mount=type=cache,target=/root/.cache/go-build \ RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/go/pkg/mod \
make install COSMOS_BUILD_OPTIONS=$KAVA_DATABASE_BACKEND make install COSMOS_BUILD_OPTIONS=$0GCHAIN_DATABASE_BACKEND
FROM ubuntu:22.04 FROM ubuntu:22.04
@ -48,10 +48,10 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# copy rocksdb shared objects # copy rocksdb shared objects
COPY --from=kava-builder /usr/local/lib/ /usr/local/lib/ COPY --from=chain-builder /usr/local/lib/ /usr/local/lib/
RUN ldconfig RUN ldconfig
# copy kava binary # copy 0g-chain binary
COPY --from=kava-builder /go/bin/kava /bin/kava COPY --from=chain-builder /go/bin/0gchaind /bin/0gchaind
CMD ["kava"] CMD ["0gchaind"]

View File

@ -1,8 +1,10 @@
################################################################################ ################################################################################
### Project Info ### ### Project Info ###
################################################################################ ################################################################################
PROJECT_NAME := kava# unique namespace for project PROJECT_NAME := 0g-chain# unique namespace for project
BINARY_NAME := 0gchaind
MAIN_ENTRY := ./cmd/$(BINARY_NAME)
DOCKER_IMAGE_NAME := 0glabs/$(PROJECT_NAME)
GO_BIN ?= go GO_BIN ?= go
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD) GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
@ -37,7 +39,7 @@ print-git-info:
.PHONY: print-version .PHONY: print-version
print-version: print-version:
@echo "kava $(VERSION)\ntendermint $(TENDERMINT_VERSION)\ncosmos $(COSMOS_SDK_VERSION)" @echo "$(BINARY_NAME) $(VERSION)\ntendermint $(TENDERMINT_VERSION)\ncosmos $(COSMOS_SDK_VERSION)"
################################################################################ ################################################################################
### Project Settings ### ### Project Settings ###
@ -142,8 +144,8 @@ build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))
# process linker flags # process linker flags
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=kava \ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=$(PROJECT_NAME) \
-X github.com/cosmos/cosmos-sdk/version.AppName=kava \ -X github.com/cosmos/cosmos-sdk/version.AppName=$(PROJECT_NAME) \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION_NUMBER) \ -X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION_NUMBER) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(GIT_COMMIT) \ -X github.com/cosmos/cosmos-sdk/version.Commit=$(GIT_COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \ -X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \
@ -188,16 +190,16 @@ all: install
build: go.sum build: go.sum
ifeq ($(OS), Windows_NT) ifeq ($(OS), Windows_NT)
$(GO_BIN) build -mod=readonly $(BUILD_FLAGS) -o out/$(shell $(GO_BIN) env GOOS)/kava.exe ./cmd/kava $(GO_BIN) build -mod=readonly $(BUILD_FLAGS) -o out/$(shell $(GO_BIN) env GOOS)/$(BINARY_NAME).exe $(MAIN_ENTRY)
else else
$(GO_BIN) build -mod=readonly $(BUILD_FLAGS) -o out/$(shell $(GO_BIN) env GOOS)/kava ./cmd/kava $(GO_BIN) build -mod=readonly $(BUILD_FLAGS) -o out/$(shell $(GO_BIN) env GOOS)/$(BINARY_NAME) $(MAIN_ENTRY)
endif endif
build-linux: go.sum build-linux: go.sum
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build
install: go.sum install: go.sum
$(GO_BIN) install -mod=readonly $(BUILD_FLAGS) ./cmd/kava $(GO_BIN) install -mod=readonly $(BUILD_FLAGS) $(MAIN_ENTRY)
######################################## ########################################
### Tools & dependencies ### Tools & dependencies
@ -219,6 +221,7 @@ go.sum: go.mod
# Set to exclude riot links as they trigger false positives # Set to exclude riot links as they trigger false positives
link-check: link-check:
@$(GO_BIN) get -u github.com/raviqqe/liche@f57a5d1c5be4856454cb26de155a65a4fd856ee3 @$(GO_BIN) get -u github.com/raviqqe/liche@f57a5d1c5be4856454cb26de155a65a4fd856ee3
# TODO: replace kava in following line with project name
liche -r . --exclude "^http://127.*|^https://riot.im/app*|^http://kava-testnet*|^https://testnet-dex*|^https://kava3.data.kava.io*|^https://ipfs.io*|^https://apps.apple.com*|^https://kava.quicksync.io*" liche -r . --exclude "^http://127.*|^https://riot.im/app*|^http://kava-testnet*|^https://testnet-dex*|^https://kava3.data.kava.io*|^https://ipfs.io*|^https://apps.apple.com*|^https://kava.quicksync.io*"
@ -240,19 +243,19 @@ format:
### Localnet ### ### Localnet ###
############################################################################### ###############################################################################
# Build docker image and tag as kava/kava:local # Build docker image and tag as 0glabs/0g-chain:local
docker-build: docker-build:
DOCKER_BUILDKIT=1 $(DOCKER) build -t kava/kava:local . DOCKER_BUILDKIT=1 $(DOCKER) build -t $(DOCKER_IMAGE_NAME):local .
docker-build-rocksdb: docker-build-rocksdb:
DOCKER_BUILDKIT=1 $(DOCKER) build -f Dockerfile-rocksdb -t kava/kava:local . DOCKER_BUILDKIT=1 $(DOCKER) build -f Dockerfile-rocksdb -t $(DOCKER_IMAGE_NAME):local .
build-docker-local-kava: build-docker-local-0gchain:
@$(MAKE) -C networks/local @$(MAKE) -C networks/local
# Run a 4-node testnet locally # Run a 4-node testnet locally
localnet-start: build-linux localnet-stop localnet-start: build-linux localnet-stop
@if ! [ -f build/node0/kvd/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/kvd:Z kava/kavanode testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi @if ! [ -f build/node0/kvd/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/kvd:Z $(DOCKER_IMAGE_NAME)-node testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi
docker-compose up -d docker-compose up -d
localnet-stop: localnet-stop:
@ -261,7 +264,7 @@ localnet-stop:
# Launch a new single validator chain # Launch a new single validator chain
start: start:
./contrib/devnet/init-new-chain.sh ./contrib/devnet/init-new-chain.sh
kava start $(BINARY_NAME) start
#proto-format: #proto-format:
#@echo "Formatting Protobuf files" #@echo "Formatting Protobuf files"
@ -302,7 +305,7 @@ test:
@$(GO_BIN) test $$($(GO_BIN) list ./... | grep -v 'contrib' | grep -v 'tests/e2e') @$(GO_BIN) test $$($(GO_BIN) list ./... | grep -v 'contrib' | grep -v 'tests/e2e')
test-rocksdb: test-rocksdb:
@go test -tags=rocksdb ./cmd/kava/opendb @go test -tags=rocksdb $(MAIN_ENTRY)/opendb
# Run cli integration tests # Run cli integration tests
# `-p 4` to use 4 cores, `-tags cli_test` to tell $(GO_BIN) not to ignore the cli package # `-p 4` to use 4 cores, `-tags cli_test` to tell $(GO_BIN) not to ignore the cli package
@ -318,15 +321,15 @@ test-migrate:
# This submits an AWS Batch job to run a lot of sims, each within a docker image. Results are uploaded to S3 # This submits an AWS Batch job to run a lot of sims, each within a docker image. Results are uploaded to S3
start-remote-sims: start-remote-sims:
# build the image used for running sims in, and tag it # build the image used for running sims in, and tag it
docker build -f simulations/Dockerfile -t kava/kava-sim:master . docker build -f simulations/Dockerfile -t $(DOCKER_IMAGE_NAME)-sim:master .
# push that image to the hub # push that image to the hub
docker push kava/kava-sim:master docker push $(DOCKER_IMAGE_NAME)-sim:master
# submit an array job on AWS Batch, using 1000 seeds, spot instances # submit an array job on AWS Batch, using 1000 seeds, spot instances
aws batch submit-job \ aws batch submit-job \
-—job-name "master-$(VERSION)" \ -—job-name "master-$(VERSION)" \
-—job-queue “simulation-1-queue-spot" \ -—job-queue “simulation-1-queue-spot" \
-—array-properties size=1000 \ -—array-properties size=1000 \
-—job-definition kava-sim-master \ -—job-definition $(BINARY_NAME)-sim-master \
-—container-override environment=[{SIM_NAME=master-$(VERSION)}] -—container-override environment=[{SIM_NAME=master-$(VERSION)}]
update-kvtool: update-kvtool:

View File

@ -3,7 +3,7 @@ version: '3'
services: services:
kvdnode0: kvdnode0:
container_name: kvdnode0 container_name: kvdnode0
image: "kava/kavanode" image: "0glabs/0g-chain-node"
ports: ports:
- "26656-26657:26656-26657" - "26656-26657:26656-26657"
environment: environment:
@ -17,7 +17,7 @@ services:
kvdnode1: kvdnode1:
container_name: kvdnode1 container_name: kvdnode1
image: "kava/kavanode" image: "0glabs/0g-chain-node"
ports: ports:
- "26659-26660:26656-26657" - "26659-26660:26656-26657"
environment: environment:
@ -31,7 +31,7 @@ services:
kvdnode2: kvdnode2:
container_name: kvdnode2 container_name: kvdnode2
image: "kava/kavanode" image: "0glabs/0g-chain-node"
environment: environment:
- ID=2 - ID=2
- LOG=${LOG:-kvd.log} - LOG=${LOG:-kvd.log}
@ -45,7 +45,7 @@ services:
kvdnode3: kvdnode3:
container_name: kvdnode3 container_name: kvdnode3
image: "kava/kavanode" image: "0glabs/0g-chain-node"
environment: environment:
- ID=3 - ID=3
- LOG=${LOG:-kvd.log} - LOG=${LOG:-kvd.log}