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

Default to GHCR instead of DockerHub for install #5146

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 67 additions & 10 deletions scripts/install-fabric.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ _arg_comp=('' )
_arg_fabric_version="2.5.11"
_arg_ca_version="1.5.15"

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)

HYPERLEDGER_NAMESPACE=hyperledger
DOCKER_NAMESPACE="${FABRIC_DOCKER_REGISTRY:-${HYPERLEDGER_NAMESPACE}}"


die()
{
Expand Down Expand Up @@ -142,21 +143,77 @@ assign_positional_args()

singleImagePull() {
#three_digit_image_tag is passed in, e.g. "1.4.7"
three_digit_image_tag=$1
local three_digit_image_tag=$1
shift
#two_digit_image_tag is derived, e.g. "1.4", especially useful as a local tag for two digit references
local two_digit_image_tag
two_digit_image_tag=$(echo "$three_digit_image_tag" | cut -d'.' -f1,2)
while [[ $# -gt 0 ]]
do
image_name="$1"
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"


while [[ $# -gt 0 ]]; do
local component_name="$1"
local registry
registry="$(dockerComponentRegistry "${component_name}" "${three_digit_image_tag}")"
local image_name="${registry}/fabric-${component_name}:${three_digit_image_tag}"

echo "====> ${image_name}"
${CONTAINER_CLI} pull "${image_name}"


${CONTAINER_CLI} tag "${image_name}" "${DOCKER_NAMESPACE}/fabric-${component_name}"
${CONTAINER_CLI} tag "${image_name}" "${DOCKER_NAMESPACE}/fabric-${component_name}:${two_digit_image_tag}"
# Re-tag 3-digit version to ensure there is a tag without registry prefix
${CONTAINER_CLI} tag "${image_name}" "${DOCKER_NAMESPACE}/fabric-${component_name}:${three_digit_image_tag}"

shift
done
}

dockerComponentRegistry() {
if [[ -n ${FABRIC_DOCKER_REGISTRY} ]]; then
echo -n "${FABRIC_DOCKER_REGISTRY}"
return
fi

local component="$1"
local image_version="$2"

case "${component}" in
ca)
echo -n "$(dockerCARegistry "${image_version}")/${HYPERLEDGER_NAMESPACE}"
;;
*)
echo -n "$(dockerFabricRegistry "${image_version}")/${HYPERLEDGER_NAMESPACE}"
;;
esac
}

dockerCARegistry() {
local version="$1"

case "${version}" in
1.[0-4].*|1.5.[0-9]|1.5.1[0-4])
echo -n 'docker.io'
;;
*)
echo -n 'ghcr.io'
;;
esac
}

dockerFabricRegistry() {
local version="$1"

case "${version}" in
1.*|2.[0-4].*|2.5.[0-9]|2.5.10|3.0.0)
echo -n 'docker.io'
;;
*)
echo -n 'ghcr.io'
;;
esac
}

cloneSamplesRepo() {
# clone (if needed) hyperledger/fabric-samples and checkout corresponding
# version to the binaries and docker images to be downloaded
Expand Down