Skip to content

Commit

Permalink
build: add docker static build for v20 (#3331)
Browse files Browse the repository at this point in the history
* build: add docker static build for v20

* update makefile

* update goreleaser

* update makefile
  • Loading branch information
MSalopek authored Sep 13, 2024
1 parent 8b33a5b commit 835352f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 76 deletions.
68 changes: 0 additions & 68 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,72 +76,6 @@ builds:
- -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,static_wasm
- -X github.com/cometbft/cometbft/version.TMCoreSemVer={{ .Env.TM_VERSION }}

- id: gaiad-linux-amd64
main: ./cmd/gaiad
binary: gaiad
hooks:
pre:
- wget https://github.com/CosmWasm/wasmvm/releases/download/{{ .Env.COSMWASM_VERSION }}/libwasmvm_muslc.x86_64.a -O /lib/libwasmvm_muslc.x86_64.a
goos:
- linux
goarch:
- amd64
env:
- CC=x86_64-linux-gnu-gcc
flags:
- -mod=readonly
- -trimpath
ldflags:
- -X main.commit={{.Commit}}
- -X main.date={{ .CommitDate }}
- -X github.com/cosmos/cosmos-sdk/version.Name=gaia
- -X github.com/cosmos/cosmos-sdk/version.AppName=gaiad
- -X github.com/cosmos/cosmos-sdk/version.Version=v{{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }}
- -X github.com/cometbft/cometbft/version.TMCoreSemVer={{ .Env.TM_VERSION }}
- -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,muslc,osusergo
- -w -s
- -linkmode=external
- -extldflags '-Wl,-z,muldefs -static -lm'
tags:
- netgo
- ledger
- muslc
- osusergo

- id: gaiad-linux-arm64
main: ./cmd/gaiad
binary: gaiad
hooks:
pre:
- wget https://github.com/CosmWasm/wasmvm/releases/download/{{ .Env.COSMWASM_VERSION }}/libwasmvm_muslc.aarch64.a -O /lib/libwasmvm_muslc.aarch64.a
goos:
- linux
goarch:
- arm64
env:
- CC=aarch64-linux-gnu-gcc
flags:
- -mod=readonly
- -trimpath
ldflags:
- -s -w
- -linkmode=external
- -X main.commit={{.Commit}}
- -X main.date={{ .CommitDate }}
- -X github.com/cosmos/cosmos-sdk/version.Name=gaia
- -X github.com/cosmos/cosmos-sdk/version.AppName=gaiad
- -X github.com/cosmos/cosmos-sdk/version.Version=v{{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }}
- -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger
- -X github.com/cometbft/cometbft/version.TMCoreSemVer={{ .Env.TM_VERSION }}
- -extldflags '-Wl,-z,muldefs -static -lm'
tags:
- netgo
- ledger
- muslc
- osusergo


universal_binaries:
- id: gaiad-darwin-universal
Expand All @@ -168,8 +102,6 @@ archives:
builds:
- gaiad-darwin-arm64
- gaiad-darwin-amd64
- gaiad-linux-amd64
- gaiad-linux-arm64
wrap_in_directory: false
files:
- none*
Expand Down
29 changes: 21 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ vulncheck: $(BUILDDIR)/
GOBIN=$(BUILDDIR) go install golang.org/x/vuln/cmd/govulncheck@latest
$(BUILDDIR)/govulncheck ./...

build-linux: go.sum
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build

go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
@echo "--> Ensure dependencies have not been modified unless suppressed by SKIP_MOD_VERIFY"
Expand Down Expand Up @@ -184,9 +181,27 @@ else
@echo "--> No tag specified, skipping tag release"
endif


# uses goreleaser to create static binaries for linux an darwin on local machine
# platform is set because not setting it results in broken builds for linux-amd64
# Build static binaries for linux/amd64 using docker buildx
# Pulled from neutron-org/neutron: https://github.com/neutron-org/neutron/blob/v4.2.2/Makefile#L107
build-static-linux-amd64: go.sum $(BUILDDIR)/
$(DOCKER) buildx create --name gaiabuilder || true
$(DOCKER) buildx use gaiabuilder
$(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),muslc \
--platform linux/amd64 \
-t gaiad-static-amd64 \
-f Dockerfile . \
--load
$(DOCKER) rm -f gaiabinary || true
$(DOCKER) create -ti --name gaiabinary gaiad-static-amd64
$(DOCKER) cp gaiabinary:/usr/local/bin/ $(BUILDDIR)/gaiad-linux-amd64
$(DOCKER) rm -f gaiabinary


# uses goreleaser to create static binaries for darwin on local machine
goreleaser-build-local:
docker run \
--rm \
Expand All @@ -195,7 +210,6 @@ goreleaser-build-local:
-e COSMWASM_VERSION=$(COSMWASM_VERSION) \
-v `pwd`:/go/src/gaiad \
-w /go/src/gaiad \
--platform=linux/amd64 \
$(GORELEASER_IMAGE) \
release \
--snapshot \
Expand All @@ -216,7 +230,6 @@ ci-release:
-e COSMWASM_VERSION=$(COSMWASM_VERSION) \
-v `pwd`:/go/src/gaiad \
-w /go/src/gaiad \
--platform=linux/amd64 \
$(GORELEASER_IMAGE) \
release \
--release-notes ./RELEASE_NOTES.md \
Expand Down

0 comments on commit 835352f

Please sign in to comment.