Skip to content

Commit 4c51c6a

Browse files
authored
feat: adding gcloud CLI to ubi9 and ubi10 (#253)
Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
1 parent 803319c commit 4c51c6a

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

universal/ubi10/Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,41 @@ fi
476476
RUN curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-${TARGETARCH} && \
477477
install skaffold /usr/local/bin/
478478

479+
## Google Cloud CLI
480+
RUN <<EOF
481+
set -euf -o pipefail
482+
TEMP_DIR="$(mktemp -d)"
483+
cd "${TEMP_DIR}"
484+
485+
GCLOUD_VERSION="565.0.0"
486+
487+
case "$TARGETARCH" in
488+
amd64)
489+
GCLOUD_ARCH="x86_64"
490+
;;
491+
arm64)
492+
GCLOUD_ARCH="arm"
493+
;;
494+
*)
495+
echo "Skipping gcloud installation for unsupported architecture: $TARGETARCH"
496+
exit 0
497+
;;
498+
esac
499+
500+
GCLOUD_TGZ="google-cloud-cli-${GCLOUD_VERSION}-linux-${GCLOUD_ARCH}.tar.gz"
501+
GCLOUD_TGZ_URL="https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/${GCLOUD_TGZ}"
502+
503+
curl -sSLO "${GCLOUD_TGZ_URL}"
504+
tar -xzf "${GCLOUD_TGZ}"
505+
./google-cloud-sdk/install.sh --usage-reporting=false --path-update=false --quiet
506+
mv google-cloud-sdk /usr/local/
507+
508+
cd -
509+
rm -rf "${TEMP_DIR}"
510+
EOF
511+
512+
ENV PATH="/usr/local/google-cloud-sdk/bin:${PATH}"
513+
479514
# e2fsprogs setup
480515
# Since e2fsprogs-static package has removed RHEL 8 distribution, it is not possible to install from the repository
481516
# https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/considerations_in_adopting_rhel_8/index#removed-packages_changes-to-packages
@@ -524,6 +559,9 @@ oc completion bash > /usr/share/bash-completion/completions/oc
524559
tkn completion bash > /usr/share/bash-completion/completions/tkn
525560
kubectl completion bash > /usr/share/bash-completion/completions/kubectl
526561
cat ${NVM_DIR}/bash_completion > /usr/share/bash-completion/completions/nvm
562+
if [ -f /usr/local/google-cloud-sdk/completion.bash.inc ]; then
563+
cat /usr/local/google-cloud-sdk/completion.bash.inc > /usr/share/bash-completion/completions/gcloud
564+
fi
527565
EOF
528566

529567
## Add sdkman's init script launcher to the end of ${PROFILE_EXT} since we are not adding it on sdkman install

universal/ubi9/Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,41 @@ fi
440440
RUN curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-${TARGETARCH} && \
441441
install skaffold /usr/local/bin/
442442

443+
## Google Cloud CLI
444+
RUN <<EOF
445+
set -euf -o pipefail
446+
TEMP_DIR="$(mktemp -d)"
447+
cd "${TEMP_DIR}"
448+
449+
GCLOUD_VERSION="565.0.0"
450+
451+
case "$TARGETARCH" in
452+
amd64)
453+
GCLOUD_ARCH="x86_64"
454+
;;
455+
arm64)
456+
GCLOUD_ARCH="arm"
457+
;;
458+
*)
459+
echo "Skipping gcloud installation for unsupported architecture: $TARGETARCH"
460+
exit 0
461+
;;
462+
esac
463+
464+
GCLOUD_TGZ="google-cloud-cli-${GCLOUD_VERSION}-linux-${GCLOUD_ARCH}.tar.gz"
465+
GCLOUD_TGZ_URL="https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/${GCLOUD_TGZ}"
466+
467+
curl -sSLO "${GCLOUD_TGZ_URL}"
468+
tar -xzf "${GCLOUD_TGZ}"
469+
./google-cloud-sdk/install.sh --usage-reporting=false --path-update=false --quiet
470+
mv google-cloud-sdk /usr/local/
471+
472+
cd -
473+
rm -rf "${TEMP_DIR}"
474+
EOF
475+
476+
ENV PATH="/usr/local/google-cloud-sdk/bin:${PATH}"
477+
443478
# e2fsprogs setup
444479
# Since e2fsprogs-static package has removed RHEL 8 distribution, it is not possible to install from the repository
445480
# https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/considerations_in_adopting_rhel_8/index#removed-packages_changes-to-packages
@@ -488,6 +523,9 @@ oc completion bash > /usr/share/bash-completion/completions/oc
488523
tkn completion bash > /usr/share/bash-completion/completions/tkn
489524
kubectl completion bash > /usr/share/bash-completion/completions/kubectl
490525
cat ${NVM_DIR}/bash_completion > /usr/share/bash-completion/completions/nvm
526+
if [ -f /usr/local/google-cloud-sdk/completion.bash.inc ]; then
527+
cat /usr/local/google-cloud-sdk/completion.bash.inc > /usr/share/bash-completion/completions/gcloud
528+
fi
491529
EOF
492530

493531
## Add sdkman's init script launcher to the end of ${PROFILE_EXT} since we are not adding it on sdkman install

0 commit comments

Comments
 (0)