Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: rearrange Dockerfile and Makefile commands #237

Merged
merged 11 commits into from
Jul 18, 2023
2 changes: 1 addition & 1 deletion .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:

- name: Compile finschia
run: |
make build-reproducible-${{ matrix.arch }}
make build-reproducible ARCH=${{ matrix.arch }}
cd ./build
mv fnsad-linux-${{ matrix.arch }} fnsad-${{ env.ID }}

Expand Down
39 changes: 10 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ OST_VERSION := $(shell go list -m github.com/Finschia/ostracon | sed 's:.* ::')
DOCKER := $(shell which docker)
BUILDDIR ?= $(CURDIR)/build
CGO_ENABLED ?= 1
ARCH ?= x86_64
ARCH ?= amd64
TARGET_PLATFORM ?= linux/amd64
TARGET_ARCH ?= x86_64
0Tech marked this conversation as resolved.
Show resolved Hide resolved

export GO111MODULE = on

ifeq ($(ARCH), aarch64)
ifeq ($(ARCH), arm64)
TARGET_PLATFORM=linux/arm64
TARGET_ARCH = aarch64
endif

# process build tags
Expand Down Expand Up @@ -141,7 +143,7 @@ ifeq (darwin, $(shell go env GOOS))
LIBWASMVM ?= libwasmvm.dylib
else
ifeq (linux, $(shell go env GOOS))
LIBWASMVM ?= libwasmvm.$(ARCH).so
LIBWASMVM ?= libwasmvm.$(TARGET_ARCH).so
else
echo "ERROR: unsupported platform: $(shell go env GOOS)"
exit 1
Expand Down Expand Up @@ -202,28 +204,7 @@ else
dbbackend:
endif

build-reproducible: build-reproducible-amd64 build-reproducible-arm64

build-reproducible-amd64: go.sum
mkdir -p $(BUILDDIR)
$(DOCKER) buildx create --name finschiabuilder || true
$(DOCKER) buildx use finschiabuilder
$(DOCKER) buildx build \
--build-arg GO_VERSION=$(GO_VERSION) \
--build-arg GIT_VERSION=$(VERSION) \
--build-arg GIT_COMMIT=$(COMMIT) \
--build-arg OST_VERSION=$(OST_VERSION) \
--build-arg RUNNER_IMAGE=alpine:3.17 \
--platform linux/amd64 \
-t finschia/finschianode:local-amd64 \
--load \
-f Dockerfile .
$(DOCKER) rm -f finschiabinary || true
$(DOCKER) create -ti --name finschiabinary finschia/finschianode:local-amd64
$(DOCKER) cp finschiabinary:/usr/bin/fnsad $(BUILDDIR)/fnsad-linux-amd64
$(DOCKER) rm -f finschiabinary

build-reproducible-arm64: go.sum
build-reproducible: go.sum
mkdir -p $(BUILDDIR)
$(DOCKER) buildx create --name finschiabuilder || true
$(DOCKER) buildx use finschiabuilder
Expand All @@ -233,13 +214,13 @@ build-reproducible-arm64: go.sum
--build-arg GIT_COMMIT=$(COMMIT) \
--build-arg OST_VERSION=$(OST_VERSION) \
--build-arg RUNNER_IMAGE=alpine:3.17 \
--platform linux/arm64 \
-t finschia/finschianode:local-arm64 \
--platform $(TARGET_PLATFORM) \
-t finschia/finschianode:local-$(ARCH) \
--load \
-f Dockerfile .
$(DOCKER) rm -f finschiabinary || true
$(DOCKER) create -ti --name finschiabinary finschia/finschianode:local-arm64
$(DOCKER) cp finschiabinary:/usr/bin/fnsad $(BUILDDIR)/fnsad-linux-arm64
$(DOCKER) create -ti --name finschiabinary finschia/finschianode:local-$(ARCH)
$(DOCKER) cp finschiabinary:/usr/bin/fnsad $(BUILDDIR)/fnsad-linux-$(ARCH)
$(DOCKER) rm -f finschiabinary

go-mod-cache: go.sum
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ _Note1_

If you are using M1 mac, you need to specify build args like this:
```
make docker-build ARCH=aarch64
make docker-build ARCH=arm64
```

**Configure**
Expand Down
2 changes: 1 addition & 1 deletion networks/local/finschianode/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This Dockerfile is used for localnet multinode testing.
# Simple usage with a mounted data directory:
# > docker build --platform="linux/amd64" -t finschia/finschianode:localnet -f networks/local/finschianode . --build-arg ARCH=x86_64
# > docker build --platform="linux/amd64" -t finschia/finschianode:localnet -f networks/local/finschianode . --build-arg ARCH=amd64
# > docker run -it -p 26656:26656 -p 26657:26657 -v ~/.finschia:/root/.finschia -v networks/local/finschianode fnsad init
# > docker run -it -p 26656:26656 -p 26657:26657 -v ~/.finschia:/root/.finschia -v networks/local/finschianode fnsad start --rpc.laddr=tcp://0.0.0.0:26657 --p2p.laddr=tcp://0.0.0.0:26656

Expand Down