Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdevbear committed May 17, 2023
2 parents 9d9c732 + fb254da commit 53e06a3
Show file tree
Hide file tree
Showing 46 changed files with 1,094 additions and 812 deletions.
32 changes: 31 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ name: release

on:
push:
workflow_dispatch:

permissions:
contents: write
packages: write

jobs:
goreleaser:
runs-on: ubuntu-latest
Expand All @@ -16,4 +21,29 @@ jobs:
go-version: 1.20.4
check-latest: true
- name: release dry run
run: make release-dry-run
run: make release-dry-run



# .github/workflows/nightly.yml
name: goreleaser-nightly

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-go@v2
with:
go-version: 1.19
- uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser-pro
version: latest
args: release --clean --nightly
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,7 @@ node_modules
next-env.d.ts
.env
out

dist/

dist/
103 changes: 0 additions & 103 deletions .goreleaser.yml

This file was deleted.

3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ release-dry-run:
--rm \
--privileged \
-e CGO_ENABLED=1 \
-e GORELEASER_KEY=$(GORELEASER_KEY) \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-v ${GOPATH}/pkg:/go/pkg \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--clean --skip-validate --skip-publish --snapshot
--clean --snapshot -f ./cosmos/.goreleaser.yaml

.PHONY: release-dry-run release
2 changes: 1 addition & 1 deletion contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ remappings = [
]

[profile.ci]
fuzz_runs = 8192
fuzz_runs = 8192
6 changes: 4 additions & 2 deletions cosmos/cmd/polard/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ import (
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"

"pkg.berachain.dev/polaris/cosmos/cmd/polard/cmd"
simapp "pkg.berachain.dev/polaris/cosmos/runtime"
runtime "pkg.berachain.dev/polaris/cosmos/runtime"
runtimeconfig "pkg.berachain.dev/polaris/cosmos/runtime/config"
)

func main() {
runtimeconfig.SetupCosmosConfig()
rootCmd := cmd.NewRootCmd()
if err := svrcmd.Execute(rootCmd, "", simapp.DefaultNodeHome); err != nil {
if err := svrcmd.Execute(rootCmd, "", runtime.DefaultNodeHome); err != nil {
log.NewLogger(rootCmd.OutOrStderr()).Error("failure when running app", "err", err)
os.Exit(1)
}
Expand Down
104 changes: 48 additions & 56 deletions cosmos/runtime/localnode/Dockerfile → cosmos/docker/base.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# syntax=docker/dockerfile:1
#
# Copyright (C) 2022, Berachain Foundation. All rights reserved.
# See the file LICENSE for licensing terms.
#
Expand All @@ -14,100 +14,92 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

ARG GO_VERSION
#######################################################
### Stage 0 - Build Arguments ###
#######################################################

ARG GO_VERSION=1.20.4
ARG GOARCH=arm64
ARG GOOS=darwin
ARG GOOS=linux
ARG NAME=polaris-cosmos
ARG APP_NAME=polard
ARG DB_BACKEND=pebbledb
ARG CMD_PATH=./cosmos/cmd/polard
ARG FOUNDRY_DIR=./contracts

#######################################################
### Stage 1 - Build Smart Contracts ###
### Stage 1 - Build Solidity Bindings ###
#######################################################

# Use the latest foundry image
FROM ghcr.io/foundry-rs/foundry as foundry

WORKDIR /polaris
WORKDIR /workdir

# Build and test the source code
ARG PRECOMPILE_CONTRACTS_DIR
COPY ${PRECOMPILE_CONTRACTS_DIR} ${PRECOMPILE_CONTRACTS_DIR}
WORKDIR /polaris/${PRECOMPILE_CONTRACTS_DIR}

RUN forge build
# Copy over all the solidity code.
ARG FOUNDRY_DIR
COPY ${FOUNDRY_DIR} ${FOUNDRY_DIR}
WORKDIR /workdir/${FOUNDRY_DIR}

RUN forge build --extra-output-files bin --extra-output-files abi

# #############################dock##########################
# ### Stage 2 - Build the Application ###
# #######################################################

FROM golang:${GO_VERSION}-alpine as builder

# Setup some alpine stuff that nobody really knows how or why it works.
# Like if ur reading this and u dunno just ask the devops guy or something.
RUN set -eux; \
apk add git linux-headers ca-certificates build-base

# Copy our source code into the container
WORKDIR /polaris
WORKDIR /workdir
COPY . .

# Setup some alpine stuff that nobody really knows why we need other
# than docker geeks cause let's be real, everyone else just googles this stuff
# or asks that one really smart guy on their devops team to fio.
RUN set -eux; apk add --no-cache ca-certificates build-base;
RUN apk add git



# Needed by github.com/zondax/hid
RUN apk add linux-headers

# Copy the forge output
ARG PRECOMPILE_CONTRACTS_DIR
COPY --from=foundry /polaris/${PRECOMPILE_CONTRACTS_DIR}/out /polaris/${PRECOMPILE_CONTRACTS_DIR}/out

# # Copy the go mod and sum files
# COPY go.mod ./
# COPY go.sum ./


# Build berad binary
ARG FOUNDRY_DIR
COPY --from=foundry /workdir/${FOUNDRY_DIR}/out /workdir/${FOUNDRY_DIR}/out

# Build args
ARG NAME
ARG GOARCH
ARG GOOS
ARG APP_NAME
ARG DB_BACKEND
ARG CMD_PATH

# Build Executable
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
VERSION=$(echo $(git describe --tags) | sed 's/^v//') && \
COMMIT=$(git log -1 --format='%H') && \
env GOOS=${GOOS} GOARCH=${GOARCH} && \
env NAME=${NAME} DB_BACKEND=${DB_BACKEND} && \
env APP_NAME=${APP_NAME} && \
go build \
-mod=readonly \
-tags "netgo,ledger,muslc" \
-ldflags "-X github.com/cosmos/cosmos-sdk/version.Name="berachain" \
-X github.com/cosmos/cosmos-sdk/version.AppName="berad" \
-ldflags "-X github.com/cosmos/cosmos-sdk/version.Name=$NAME \
-X github.com/cosmos/cosmos-sdk/version.AppName=$APP_NAME \
-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='netgo,ledger,muslc' \
-X github.com/cosmos/cosmos-sdk/types.DBBackend="pebbledb" \
-X github.com/cosmos/cosmos-sdk/types.DBBackend=$DB_BACKEND \
-w -s -linkmode=external -extldflags '-Wl,-z,muldefs -static'" \
-trimpath \
-o /polaris/bin/ \
./cosmos/cmd/polard
-o /workdir/bin/ \
${CMD_PATH}

#######################################################
### Stage 3 - Prepare the Final Image ###
#######################################################

FROM golang:${GO_VERSION}-alpine

RUN apk add --no-cache bash
RUN apk add --no-cache jq

WORKDIR /polaris

COPY --from=builder /polaris/bin/polard /bin/
COPY --from=builder /polaris/cosmos/runtime/localnode/docker-init.sh /polaris/docker-init.sh
COPY --from=builder /polaris/cosmos/runtime/localnode/config /polaris/config

ENV HOME /polaris
WORKDIR $HOME

# Expose the berad port
EXPOSE 8545
EXPOSE 8546
EXPOSE 26656
EXPOSE 26657
EXPOSE 1317
# Build args
ARG APP_NAME

CMD ["bash", "docker-init.sh"]
# Copy over built executable into a fresh container.
COPY --from=builder /workdir/bin/${APP_NAME} /bin/
41 changes: 41 additions & 0 deletions cosmos/docker/local/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

# syntax=docker/dockerfile:1
# Copyright (C) 2022, Berachain Foundation. All rights reserved.
# See the file LICENSE for licensing terms.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

ARG GO_VERSION
ARG GOARCH=arm64
ARG GOOS=darwin
ARG POLARD_VERSION=v0.0.0

#######################################################
### Stage 1 - Build Smart Contracts ###
#######################################################

# Use the latest foundry image
FROM polard-base:${POLARD_VERSION} as localpolard

RUN apk add --no-cache bash jq

WORKDIR /

# Copy over the local information
COPY ./cosmos/docker/local/docker-init.sh /docker-init.sh
COPY ./cosmos/docker/local/config /config

# Set the hom directory
ENV HOME /
WORKDIR $HOME

CMD ["bash", "docker-init.sh"]
Loading

0 comments on commit 53e06a3

Please sign in to comment.