Skip to content

Commit

Permalink
(docker) enable cross platform build using docker buildx (\tendermint…
Browse files Browse the repository at this point in the history
  • Loading branch information
highercomve committed Aug 3, 2022
1 parent ea271c5 commit bccee81
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
### IMPROVEMENTS

### BUG FIXES

[docker] \#9073 enable cross platform build using docker buildx
4 changes: 2 additions & 2 deletions DOCKER/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# stage 1 Generate Tendermint Binary
FROM golang:1.15-alpine as builder
FROM --platform=$BUILDPLATFORM golang:1.15-alpine as builder
RUN apk update && \
apk upgrade && \
apk --no-cache add make
COPY / /tendermint
WORKDIR /tendermint
RUN make build-linux
RUN TARGETPLATFORM=$TARGETPLATFORM make build-linux

# stage 2
FROM golang:1.15-alpine
Expand Down
63 changes: 62 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,67 @@ endif
# allow users to pass additional flags via the conventional LDFLAGS variable
LD_FLAGS += $(LDFLAGS)

# Process Docker environment varible TARGETPLATFORM
# in order to build binary with correspondent ARCH
# by default will always build for linux/amd64
TARGETPLATFORM ?=
GOOS ?= linux
GOARCH ?= amd64
GOARM ?=

ifeq (linux/arm,$(findstring linux/arm,$(TARGETPLATFORM)))
GOOS=linux
GOARCH=arm
GOARM=7
endif

ifeq (linux/arm/v6,$(findstring linux/arm/v6,$(TARGETPLATFORM)))
GOOS=linux
GOARCH=arm
GOARM=6
endif

ifeq (linux/arm64,$(findstring linux/arm64,$(TARGETPLATFORM)))
GOOS=linux
GOARCH=arm64
GOARM=7
endif

ifeq (linux/386,$(findstring linux/386,$(TARGETPLATFORM)))
GOOS=linux
GOARCH=386
endif

ifeq (linux/amd64,$(findstring linux/amd64,$(TARGETPLATFORM)))
GOOS=linux
GOARCH=amd64
endif

ifeq (linux/mips,$(findstring linux/mips,$(TARGETPLATFORM)))
GOOS=linux
GOARCH=mips
endif

ifeq (linux/mipsle,$(findstring linux/mipsle,$(TARGETPLATFORM)))
GOOS=linux
GOARCH=mipsle
endif

ifeq (linux/mips64,$(findstring linux/mips64,$(TARGETPLATFORM)))
GOOS=linux
GOARCH=mips64
endif

ifeq (linux/mips64le,$(findstring linux/mips64le,$(TARGETPLATFORM)))
GOOS=linux
GOARCH=mips64le
endif

ifeq (linux/riscv64,$(findstring linux/riscv64,$(TARGETPLATFORM)))
GOOS=linux
GOARCH=riscv64
endif

all: check build test install
.PHONY: all

Expand Down Expand Up @@ -244,7 +305,7 @@ build-docker: build-linux

# Build linux binary on other platforms
build-linux:
GOOS=linux GOARCH=amd64 $(MAKE) build
GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) $(MAKE) build
.PHONY: build-linux

build-docker-localnode:
Expand Down

0 comments on commit bccee81

Please sign in to comment.