From 44e35680d823c21165983cf92645df0468f7c647 Mon Sep 17 00:00:00 2001 From: Josh Kneubuhl Date: Mon, 28 Nov 2022 13:59:05 -0500 Subject: [PATCH] Publish multi-arch docker images and binaries for arm64, amd64 Signed-off-by: Josh Kneubuhl --- .github/workflows/release.yml | 135 +++++++++++++++++++--------- Makefile | 15 ++-- ci/scripts/create_binary_package.sh | 6 +- ci/scripts/publish_docker.sh | 17 ---- docker-env.mk | 3 +- images/orderer/Dockerfile | 5 +- images/peer/Dockerfile | 15 ++-- images/tools/Dockerfile | 4 +- release_notes/v2.5.0-alpha1.md | 106 ++++++++++++++++++++++ scripts/bootstrap.sh | 27 ++++-- scripts/install-fabric.sh | 27 ++++-- 11 files changed, 269 insertions(+), 91 deletions(-) delete mode 100755 ci/scripts/publish_docker.sh create mode 100644 release_notes/v2.5.0-alpha1.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 00f0bfc780d..d48bfe928d5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,24 +3,16 @@ # SPDX-License-Identifier: Apache-2.0 name: Release + on: - workflow_dispatch: - inputs: - release: - description: 'Fabric Release, e.g. 2.4.7' - required: true - type: string - two_digit_release: - description: 'Fabric Two Digit Release, e.g. 2.4' - required: true - type: string - commit_hash: - description: 'Commit hash, e.g. df9c661a192f8cf11376d9d643a0021f1a76c34b' - required: true - type: string + push: + tags: [ v2.* ] env: GO_VER: 1.18.7 + ALPINE_VER: 3.16 + FABRIC_VER: ${{ github.ref_name }} + DOCKER_REGISTRY: ghcr.io permissions: contents: read @@ -34,9 +26,15 @@ jobs: - image: ubuntu-20.04 target: linux arch: amd64 + - image: ubuntu-20.04 + target: linux + arch: arm64 - image: macos-11 target: darwin arch: amd64 + - image: macos-11 + target: darwin + arch: arm64 - image: windows-2022 target: windows arch: amd64 @@ -52,38 +50,95 @@ jobs: run: ./ci/scripts/create_binary_package.sh env: TARGET: ${{ matrix.target }}-${{ matrix.arch }} - RELEASE: ${{ inputs.release }} + RELEASE: ${{ env.FABRIC_VER }} + - name: Publish Release Artifact uses: actions/upload-artifact@v3 with: - name: hyperledger-fabric-${{ matrix.target }}-${{ matrix.arch }}-${{ inputs.release }}.tar.gz - path: release/${{ matrix.target }}-${{ matrix.arch }}/hyperledger-fabric-${{ matrix.target }}-${{ matrix.arch }}-${{ inputs.release }}.tar.gz + # of the artifact must not collide between platform/arch builds + name: release-${{ matrix.target }}-${{ matrix.arch }} + # of the artifact may include multiple files. + path: release/${{ matrix.target }}-${{ matrix.arch }}/*.tar.gz + build-and-push-docker-images: - name: Build and Push Fabric Docker Images + name: Build and Push runs-on: ubuntu-20.04 + + permissions: + contents: read + packages: write + + strategy: + matrix: + include: + - COMPONENT: baseos + CONTEXT: images/baseos + - COMPONENT: ccenv + CONTEXT: images/ccenv + - COMPONENT: peer + CONTEXT: . + - COMPONENT: orderer + CONTEXT: . + - COMPONENT: tools + CONTEXT: . + steps: - - name: Run APT Clean - run: sudo apt clean - - name: Run Apt Update - run: sudo apt update - - name: Install Dependencies - run: sudo apt install -y gcc haveged libtool make - - name: Install Go - uses: actions/setup-go@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 with: - go-version: ${{ env.GO_VER }} - - name: Checkout Fabric Code + buildkitd-flags: --debug + config-inline: | + [worker.oci] + max-parallelism = 1 + + - name: Checkout uses: actions/checkout@v3 - - name: Publish Docker Images - run: ./ci/scripts/publish_docker.sh - env: - RELEASE: ${{ inputs.release }} - TWO_DIGIT_RELEASE: ${{ inputs.two_digit_release }} - DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} - DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + + - name: Login to the GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.DOCKER_REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # For the docker hub registry: + # username: ${{ secrets.DOCKERHUB_USERNAME }} + # password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository_owner }}/fabric-${{ matrix.COMPONENT }} + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}}.{{minor}}.{{patch}} + + - name: Build and push ${{ matrix.COMPONENT }} Image + id: push + uses: docker/build-push-action@v3 + with: + context: ${{ matrix.CONTEXT }} + file: images/${{ matrix.COMPONENT }}/Dockerfile + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + push: ${{ github.event_name != 'pull_request' }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + FABRIC_VER=${{ env.FABRIC_VER }} + ALPINE_VER=${{ env.ALPINE_VER }} + GO_VER=${{ env.GO_VER }} + GO_TAGS= + create-release: name: Create GitHub Release - needs: [ build-binaries, build-and-push-docker-images ] + needs: + - build-binaries + - build-and-push-docker-images runs-on: ubuntu-20.04 permissions: contents: write @@ -96,8 +151,8 @@ jobs: - name: Release Fabric Version uses: ncipollo/release-action@v1 with: - artifacts: "*.tar.gz/*.tar.gz" - bodyFile: release_notes/v${{ inputs.release }}.md - commit: ${{ inputs.commit_hash }} - tag: v${{ inputs.release }} + allowUpdates: "true" + artifacts: "release-*-*/*.tar.gz" + bodyFile: release_notes/${{ env.FABRIC_VER }}.md + tag: ${{ env.FABRIC_VER }} token: ${{ secrets.GITHUB_TOKEN }} diff --git a/Makefile b/Makefile index 3ff5a116df0..818634cf426 100644 --- a/Makefile +++ b/Makefile @@ -60,18 +60,20 @@ MAKEFLAGS += --no-builtin-rules BUILD_DIR ?= build EXTRA_VERSION ?= $(shell git rev-parse --short HEAD) -PROJECT_VERSION=$(BASE_VERSION)-snapshot-$(EXTRA_VERSION) +PROJECT_VERSION=$(FABRIC_VER)-snapshot-$(EXTRA_VERSION) # TWO_DIGIT_VERSION is derived, e.g. "2.0", especially useful as a local tag # for two digit references to most recent baseos and ccenv patch releases -TWO_DIGIT_VERSION = $(shell echo $(BASE_VERSION) | cut -d '.' -f 1,2) +# TWO_DIGIT_VERSION removes the (optional) semrev 'v' character from the git +# tag triggering a Fabric release. +TWO_DIGIT_VERSION = $(shell echo $(FABRIC_VER) | sed -e 's/^v\(.*\)/\1/' | cut -d '.' -f 1,2) PKGNAME = github.com/hyperledger/fabric ARCH=$(shell go env GOARCH) MARCH=$(shell go env GOOS)-$(shell go env GOARCH) # defined in common/metadata/metadata.go -METADATA_VAR = Version=$(BASE_VERSION) +METADATA_VAR = Version=$(FABRIC_VER) METADATA_VAR += CommitSHA=$(EXTRA_VERSION) METADATA_VAR += BaseDockerLabel=$(BASE_DOCKER_LABEL) METADATA_VAR += DockerNamespace=$(DOCKER_NS) @@ -81,7 +83,7 @@ GO_TAGS ?= RELEASE_EXES = orderer $(TOOLS_EXES) RELEASE_IMAGES = baseos ccenv orderer peer tools -RELEASE_PLATFORMS = darwin-amd64 linux-amd64 windows-amd64 +RELEASE_PLATFORMS = darwin-amd64 darwin-arm64 linux-amd64 linux-arm64 windows-amd64 TOOLS_EXES = configtxgen configtxlator cryptogen discover ledgerutil osnadmin peer pkgmap.configtxgen := $(PKGNAME)/cmd/configtxgen @@ -219,6 +221,7 @@ tools: $(TOOLS_EXES) $(RELEASE_EXES): %: $(BUILD_DIR)/bin/% $(BUILD_DIR)/bin/%: GO_LDFLAGS = $(METADATA_VAR:%=-X $(PKGNAME)/common/metadata.%) +$(BUILD_DIR)/bin/%: GO_LDFLAGS += -w -extldflags '-static' $(BUILD_DIR)/bin/%: @echo "Building $@" @mkdir -p $(@D) @@ -243,11 +246,9 @@ $(BUILD_DIR)/images/%/$(DUMMY): $(DBUILD) -f images/$*/Dockerfile \ --build-arg GO_VER=$(GO_VER) \ --build-arg ALPINE_VER=$(ALPINE_VER) \ + --build-arg FABRIC_VER=$(FABRIC_VER) \ $(BUILD_ARGS) \ -t $(DOCKER_NS)/fabric-$* ./$(BUILD_CONTEXT) - docker tag $(DOCKER_NS)/fabric-$* $(DOCKER_NS)/fabric-$*:$(BASE_VERSION) - docker tag $(DOCKER_NS)/fabric-$* $(DOCKER_NS)/fabric-$*:$(TWO_DIGIT_VERSION) - docker tag $(DOCKER_NS)/fabric-$* $(DOCKER_NS)/fabric-$*:$(DOCKER_TAG) @touch $@ # builds release packages for the host platform diff --git a/ci/scripts/create_binary_package.sh b/ci/scripts/create_binary_package.sh index 3c6ce7dbf9e..4e74775063a 100755 --- a/ci/scripts/create_binary_package.sh +++ b/ci/scripts/create_binary_package.sh @@ -14,4 +14,8 @@ cd "release/${TARGET}" if [ "$TARGET" == "windows-amd64" ]; then for FILE in bin/*; do mv $FILE $FILE.exe; done fi -tar -czvf "hyperledger-fabric-${TARGET}-${RELEASE}.tar.gz" bin config builders + +# Trim the semrev 'v' from the start of the RELEASE attribute +VERSION=$(echo $RELEASE | sed -e 's/^v\(.*\)/\1/') + +tar -czvf "hyperledger-fabric-${TARGET}-${VERSION}.tar.gz" bin config builders diff --git a/ci/scripts/publish_docker.sh b/ci/scripts/publish_docker.sh deleted file mode 100755 index a46c6537785..00000000000 --- a/ci/scripts/publish_docker.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -set -euo pipefail - -make docker - -docker login --username "${DOCKER_USERNAME}" --password "${DOCKER_PASSWORD}" -for image in baseos peer orderer ccenv tools; do - for release in ${RELEASE} ${TWO_DIGIT_RELEASE}; do - docker tag "hyperledger/fabric-${image}" "hyperledger/fabric-${image}:amd64-${release}" - docker tag "hyperledger/fabric-${image}" "hyperledger/fabric-${image}:${release}" - docker push "hyperledger/fabric-${image}:amd64-${release}" - docker push "hyperledger/fabric-${image}:${release}" - done -done diff --git a/docker-env.mk b/docker-env.mk index 28229e0b8b3..50c2d15ae3c 100644 --- a/docker-env.mk +++ b/docker-env.mk @@ -21,7 +21,8 @@ ifneq ($(NO_PROXY),) DOCKER_BUILD_FLAGS+=--build-arg 'NO_PROXY=$(NO_PROXY)' endif -DBUILD = docker build --force-rm --platform=linux/$(ARCH) $(DOCKER_BUILD_FLAGS) +DOCKER_BUILD ?= docker build --force-rm +DBUILD = $(DOCKER_BUILD) $(DOCKER_BUILD_FLAGS) DOCKER_NS ?= hyperledger DOCKER_TAG=$(ARCH)-$(PROJECT_VERSION) diff --git a/images/orderer/Dockerfile b/images/orderer/Dockerfile index 528e84b6784..b483f5567ea 100644 --- a/images/orderer/Dockerfile +++ b/images/orderer/Dockerfile @@ -4,6 +4,7 @@ ARG GO_VER ARG ALPINE_VER + FROM alpine:${ALPINE_VER} as base RUN apk add --no-cache tzdata # set up nsswitch.conf for Go's "netgo" implementation @@ -24,7 +25,9 @@ WORKDIR $GOPATH/src/github.com/hyperledger/fabric FROM golang as orderer ARG GO_TAGS -RUN CGO_ENABLED=0 make orderer GO_TAGS=${GO_TAGS} +ARG FABRIC_VER +ENV FABRIC_VER ${FABRIC_VER} +RUN make orderer GO_TAGS=${GO_TAGS} FROM base ENV FABRIC_CFG_PATH /etc/hyperledger/fabric diff --git a/images/peer/Dockerfile b/images/peer/Dockerfile index d7ec7a66f14..f4f699210ab 100644 --- a/images/peer/Dockerfile +++ b/images/peer/Dockerfile @@ -4,7 +4,6 @@ ARG GO_VER ARG ALPINE_VER - FROM alpine:${ALPINE_VER} as peer-base RUN apk add --no-cache tzdata # set up nsswitch.conf for Go's "netgo" implementation @@ -25,20 +24,20 @@ WORKDIR $GOPATH/src/github.com/hyperledger/fabric FROM golang as peer ARG GO_TAGS -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/. +ARG FABRIC_VER +ENV FABRIC_VER ${FABRIC_VER} +RUN make peer GO_TAGS=${GO_TAGS} +RUN make ccaasbuilder FROM peer-base +ARG TARGETARCH +ARG TARGETOS ENV FABRIC_CFG_PATH /etc/hyperledger/fabric VOLUME /etc/hyperledger/fabric 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-platform/builders/ccaas/bin/ /opt/hyperledger/ccaas_builder/bin/ +COPY --from=peer /go/src/github.com/hyperledger/fabric/release/${TARGETOS}-${TARGETARCH}/builders/ccaas/bin/ /opt/hyperledger/ccaas_builder/bin/ EXPOSE 7051 CMD ["peer","node","start"] diff --git a/images/tools/Dockerfile b/images/tools/Dockerfile index 93e9e660fa5..92e9a14ece5 100644 --- a/images/tools/Dockerfile +++ b/images/tools/Dockerfile @@ -19,7 +19,9 @@ WORKDIR $GOPATH/src/github.com/hyperledger/fabric FROM golang as tools ARG GO_TAGS -RUN CGO_ENABLED=0 make tools GO_TAGS=${GO_TAGS} +ARG FABRIC_VER +ENV FABRIC_VER ${FABRIC_VER} +RUN make tools GO_TAGS=${GO_TAGS} FROM golang:${GO_VER}-alpine${ALPINE_VER} # git is required to support `go list -m` diff --git a/release_notes/v2.5.0-alpha1.md b/release_notes/v2.5.0-alpha1.md new file mode 100644 index 00000000000..410d41dc13f --- /dev/null +++ b/release_notes/v2.5.0-alpha1.md @@ -0,0 +1,106 @@ +v2.5.0-alpha1 Release Notes - 6 Dec 2022 +================================= + + +Improvements +------------ + +- Prepares multi-arch Docker images for linux/arm64 and linux/amd64 + + +Fixes +----- + + + + +Dependencies +------------ +Fabric v2.5.0-alpha has been tested with the following dependencies: +* Go 1.18.7 +* CouchDB v3.1.1 + +Fabric docker images on dockerhub utilize Alpine 3.16. + + +Deprecations (existing) +----------------------- + +**Ordering service system channel is deprecated** + +v2.3 introduced the ability to manage an ordering service without a system channel. +Managing an ordering service without a system channel has privacy, scalability, +and operational benefits. The use of a system channel is deprecated and may be removed in a future release. +For information about removal of the system channel, see the [Create a channel without system channel documentation](https://hyperledger-fabric.readthedocs.io/en/release-2.3/create_channel/create_channel_participation.html). + +**FAB-15754: The 'Solo' consensus type is deprecated.** + +The 'Solo' consensus type has always been marked non-production and should be in +use only in test environments; however, for compatibility it is still available, +but may be removed entirely in a future release. + +**FAB-16408: The 'Kafka' consensus type is deprecated.** + +The 'Raft' consensus type was introduced in v1.4.1 and has become the preferred +production consensus type. There is a documented and tested migration path from +Kafka to Raft, and existing users should migrate to the newer Raft consensus type. +For compatibility with existing deployments, Kafka is still supported, +but may be removed entirely in a future release. +Additionally, the fabric-kafka and fabric-zookeeper docker images are no longer updated, maintained, or published. + +**Fabric CouchDB image is deprecated** + +v2.2.0 added support for CouchDB 3.1.0 as the recommended and tested version of CouchDB. +If prior versions are utilized, a Warning will appear in the peer log. +Note that CouchDB 3.1.0 requires that an admin username and password be set, +while this was optional in CouchDB v2.x. See the +[Fabric CouchDB documentation](https://hyperledger-fabric.readthedocs.io/en/v2.2.0/couchdb_as_state_database.html#couchdb-configuration) +for configuration details. +Also note that CouchDB 3.1.0 default max_document_size is reduced to 8MB. Set a higher value if needed in your environment. +Finally, the fabric-couchdb docker image will not be updated to v3.1.0 and will no longer be updated, maintained, or published. +Users can utilize the official CouchDB docker image maintained by the Apache CouchDB project instead. + +**FAB-7559: Support for specifying orderer endpoints at the global level in channel configuration is deprecated.** + +Utilize the new 'OrdererEndpoints' stanza within the channel configuration of an organization instead. +Configuring orderer endpoints at the organization level accommodates +scenarios where orderers are run by different organizations. Using +this configuration ensures that only the TLS CA certificates of that organization +are used for orderer communications; in contrast to the global channel level endpoints which +would cause an aggregation of all orderer TLS CA certificates across +all orderer organizations to be used for orderer communications. + +**FAB-17428: Support for configtxgen flag `--outputAnchorPeersUpdate` is deprecated.** + +The `--outputAnchorPeersUpdate` mechanism for updating anchor peers has always had +limitations (for instance, it only works the first time anchor peers are updated). +Instead, anchor peer updates should be performed through channel configuration updates. + +**FAB-15406: The fabric-tools docker image is deprecated** + +The fabric-tools docker image will not be published in future Fabric releases. +Instead of using the fabric-tools docker image, users should utilize the +published Fabric binaries. The Fabric binaries can be used to make client calls +to Fabric runtime components, regardless of where the Fabric components are running. + +**FAB-15317: Block dissemination via gossip is deprecated** + +Block dissemination via gossip is deprecated and may be removed in a future release. +Fabric peers can be configured to receive blocks directly from an ordering service +node, and not gossip blocks, by using the following configuration: +``` +peer.gossip.orgLeader: true +peer.gossip.useLeaderElection: false +peer.gossip.state.enabled: false +peer.deliveryclient.blockGossipEnabled: false +``` + +**FAB-15061: Legacy chaincode lifecycle is deprecated** + +The legacy chaincode lifecycle from v1.x is deprecated and will be removed +in a future release. To prepare for the eventual removal, utilize the v2.x +chaincode lifecycle instead, by enabling V2_0 application capability on all +channels, and redeploying all chaincodes using the v2.x lifecycle. The new +chaincode lifecycle provides a more flexible and robust governance model +for chaincodes. For more details see the +[documentation for enabling the new lifecycle](https://hyperledger-fabric.readthedocs.io/en/release-2.2/enable_cc_lifecycle.html). diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index ef17a0c2b99..b8e90bbae17 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -9,8 +9,16 @@ VERSION=2.4.7 # if ca version not passed in, default to latest released version CA_VERSION=1.5.5 -ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m |sed 's/x86_64/amd64/g')" |sed 's/darwin-arm64/darwin-amd64/g') + +REGISTRY=${FABRIC_DOCKER_REGISTRY:-docker.io/hyperledger} + +OS=$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/') +ARCH=$(uname -m | sed 's/x86_64/amd64/g' | sed 's/aarch64/arm64/g') +PLATFORM=${OS}-${ARCH} + +# Fabric < 1.2 uses uname -m for architecture. MARCH=$(uname -m) + : ${CONTAINER_CLI:="docker"} printHelp() { @@ -39,10 +47,10 @@ dockerPull() { while [[ $# -gt 0 ]] do image_name="$1" - echo "====> hyperledger/fabric-$image_name:$three_digit_image_tag" - ${CONTAINER_CLI} pull "hyperledger/fabric-$image_name:$three_digit_image_tag" - ${CONTAINER_CLI} tag "hyperledger/fabric-$image_name:$three_digit_image_tag" "hyperledger/fabric-$image_name" - ${CONTAINER_CLI} tag "hyperledger/fabric-$image_name:$three_digit_image_tag" "hyperledger/fabric-$image_name:$two_digit_image_tag" + echo "====> ${REGISTRY}/fabric-$image_name:$three_digit_image_tag" + ${CONTAINER_CLI} pull "${REGISTRY}/fabric-$image_name:$three_digit_image_tag" + ${CONTAINER_CLI} tag "${REGISTRY}/fabric-$image_name:$three_digit_image_tag" "${REGISTRY}/fabric-$image_name" + ${CONTAINER_CLI} tag "${REGISTRY}/fabric-$image_name:$three_digit_image_tag" "${REGISTRY}/fabric-$image_name:$two_digit_image_tag" shift done } @@ -160,8 +168,13 @@ else : "${THIRDPARTY_TAG:="$THIRDPARTY_IMAGE_VERSION"}" fi -BINARY_FILE=hyperledger-fabric-${ARCH}-${VERSION}.tar.gz -CA_BINARY_FILE=hyperledger-fabric-ca-${ARCH}-${CA_VERSION}.tar.gz +# Prior to fabric 2.5, use amd64 binaries on darwin-arm64 +if [[ $VERSION =~ ^2\.[0-4]\.* ]]; then + PLATFORM=$(echo $PLATFORM | sed 's/darwin-arm64/darwin-amd64/g') +fi + +BINARY_FILE=hyperledger-fabric-${PLATFORM}-${VERSION}.tar.gz +CA_BINARY_FILE=hyperledger-fabric-ca-${PLATFORM}-${CA_VERSION}.tar.gz # then parse opts while getopts "h?dsb" opt; do diff --git a/scripts/install-fabric.sh b/scripts/install-fabric.sh index 66c80ca128b..53517e00110 100755 --- a/scripts/install-fabric.sh +++ b/scripts/install-fabric.sh @@ -24,9 +24,16 @@ _arg_comp=('' ) _arg_fabric_version="2.4.7" _arg_ca_version="1.5.5" -ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m |sed 's/x86_64/amd64/g')" |sed 's/darwin-arm64/darwin-amd64/g') +REGISTRY=${FABRIC_DOCKER_REGISTRY:-docker.io/hyperledger} + +OS=$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/') +ARCH=$(uname -m | sed 's/x86_64/amd64/g' | sed 's/aarch64/arm64/g') +PLATFORM=${OS}-${ARCH} + +# Fabric < 1.2 uses uname -m for architecture. MARCH=$(uname -m) + die() { local _ret="${2:-1}" @@ -44,7 +51,6 @@ begins_with_short_option() } - print_help() { printf 'Usage: %s [-f|--fabric-version ] [-c|--ca-version ] [] ... [] ...\n' "$0" @@ -143,10 +149,10 @@ singleImagePull() { while [[ $# -gt 0 ]] do image_name="$1" - echo "====> hyperledger/fabric-$image_name:$three_digit_image_tag" - ${CONTAINER_CLI} pull "hyperledger/fabric-$image_name:$three_digit_image_tag" - ${CONTAINER_CLI} tag "hyperledger/fabric-$image_name:$three_digit_image_tag" "hyperledger/fabric-$image_name" - ${CONTAINER_CLI} tag "hyperledger/fabric-$image_name:$three_digit_image_tag" "hyperledger/fabric-$image_name:$two_digit_image_tag" + echo "====> ${REGISTRY}/fabric-$image_name:$three_digit_image_tag" + ${CONTAINER_CLI} pull "${REGISTRY}/fabric-$image_name:$three_digit_image_tag" + ${CONTAINER_CLI} tag "${REGISTRY}/fabric-$image_name:$three_digit_image_tag" "${REGISTRY}/fabric-$image_name" + ${CONTAINER_CLI} tag "${REGISTRY}/fabric-$image_name:$three_digit_image_tag" "${REGISTRY}/fabric-$image_name:$two_digit_image_tag" shift done } @@ -262,8 +268,13 @@ else : "${FABRIC_TAG:="$VERSION"}" fi -BINARY_FILE=hyperledger-fabric-${ARCH}-${VERSION}.tar.gz -CA_BINARY_FILE=hyperledger-fabric-ca-${ARCH}-${CA_VERSION}.tar.gz +# Prior to fabric 2.5, use amd64 binaries on darwin-arm64 +if [[ $VERSION =~ ^2\.[0-4]\.* ]]; then + PLATFORM=$(echo $PLATFORM | sed 's/darwin-arm64/darwin-amd64/g') +fi + +BINARY_FILE=hyperledger-fabric-${PLATFORM}-${VERSION}.tar.gz +CA_BINARY_FILE=hyperledger-fabric-ca-${PLATFORM}-${CA_VERSION}.tar.gz # if nothing has been specified, assume everything if [[ ${_arg_comp[@]} =~ ^$ ]]; then