Skip to content

Commit

Permalink
Enable compilation on linux/arm64 platforms (#3557)
Browse files Browse the repository at this point in the history
* Add -buildvcs=false for ccaasbuilder

After #3315 was merged, the -buildvcs=false flag was mistakenly removed,
this commit fixes the change and adds it back.

Signed-off-by: Artem Barger <artem@bargr.net>

* Enable compilation on linux/arm64 platforms

While building the peer docker image the location of the ccaasbuilder
binaries was hardcoded into the Dockerfile, though the output directory
is platform dependent. Therefore this commit suggest two changes:

1. Prepare binary location based on the architecture and copy them into
   the temporal location, hence it will become possible to generalize
   file location inside Dockerfile

2. Suggest static binaries compilation, to include all dependent
   libraries in compile time, turns out there are different set of
   libraries between alpine:${ALPINE_VER} and
   golang:${GO_VER}-alpine${ALPINE_VER} docker images which cause peer
   to segfault on ARM64 based platforms.

Signed-off-by: Artem Barger <artem@bargr.net>
  • Loading branch information
C0rWin authored Aug 1, 2022
1 parent dcaf2b2 commit ac31c57
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docker-env.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ifneq ($(NO_PROXY),)
DOCKER_BUILD_FLAGS+=--build-arg 'NO_PROXY=$(NO_PROXY)'
endif

DBUILD = docker build --force-rm $(DOCKER_BUILD_FLAGS)
DBUILD = docker build --force-rm --platform=linux/$(ARCH) $(DOCKER_BUILD_FLAGS)

DOCKER_NS ?= hyperledger
DOCKER_TAG=$(ARCH)-$(PROJECT_VERSION)
Expand Down
2 changes: 1 addition & 1 deletion images/orderer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ WORKDIR $GOPATH/src/github.com/hyperledger/fabric

FROM golang as orderer
ARG GO_TAGS
RUN make orderer GO_TAGS=${GO_TAGS}
RUN CGO_ENABLED=0 make orderer GO_TAGS=${GO_TAGS}

FROM base
ENV FABRIC_CFG_PATH /etc/hyperledger/fabric
Expand Down
10 changes: 7 additions & 3 deletions images/peer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ WORKDIR $GOPATH/src/github.com/hyperledger/fabric

FROM golang as peer
ARG GO_TAGS
RUN make peer GO_TAGS=${GO_TAGS}
RUN make ccaasbuilder
RUN CGO_ENABLED=0 make peer GO_TAGS=${GO_TAGS}
RUN CGO_ENABLED=0 make ccaasbuilder
RUN \
export MARCH=$(go env GOOS)-$(go env GOARCH) && \
mkdir -p release/linux-platform && \
cp -r release/${MARCH}/builders release/linux-platform/.

FROM peer-base
ENV FABRIC_CFG_PATH /etc/hyperledger/fabric
Expand All @@ -35,6 +39,6 @@ VOLUME /var/hyperledger
COPY --from=peer /go/src/github.com/hyperledger/fabric/build/bin /usr/local/bin
COPY --from=peer /go/src/github.com/hyperledger/fabric/sampleconfig/msp ${FABRIC_CFG_PATH}/msp
COPY --from=peer /go/src/github.com/hyperledger/fabric/sampleconfig/core.yaml ${FABRIC_CFG_PATH}/core.yaml
COPY --from=peer /go/src/github.com/hyperledger/fabric/release/linux-amd64/builders/ccaas/bin/ /opt/hyperledger/ccaas_builder/bin/
COPY --from=peer /go/src/github.com/hyperledger/fabric/release/linux-platform/builders/ccaas/bin/ /opt/hyperledger/ccaas_builder/bin/
EXPOSE 7051
CMD ["peer","node","start"]
2 changes: 1 addition & 1 deletion images/tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ WORKDIR $GOPATH/src/github.com/hyperledger/fabric

FROM golang as tools
ARG GO_TAGS
RUN make tools GO_TAGS=${GO_TAGS}
RUN CGO_ENABLED=0 make tools GO_TAGS=${GO_TAGS}

FROM golang:${GO_VER}-alpine${ALPINE_VER}
# git is required to support `go list -m`
Expand Down

0 comments on commit ac31c57

Please sign in to comment.