Skip to content

Commit 91e6e72

Browse files
committed
feat: adding gcloud CLI to ubi9 and ubi10
Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
1 parent 1909a73 commit 91e6e72

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
@@ -472,6 +472,41 @@ fi
472472
RUN curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-${TARGETARCH} && \
473473
install skaffold /usr/local/bin/
474474

475+
## Google Cloud CLI
476+
RUN <<EOF
477+
set -euf -o pipefail
478+
TEMP_DIR="$(mktemp -d)"
479+
cd "${TEMP_DIR}"
480+
481+
GCLOUD_VERSION="512.0.0"
482+
483+
case "$TARGETARCH" in
484+
amd64)
485+
GCLOUD_ARCH="x86_64"
486+
;;
487+
arm64)
488+
GCLOUD_ARCH="arm"
489+
;;
490+
*)
491+
echo "Skipping gcloud installation for unsupported architecture: $TARGETARCH"
492+
exit 0
493+
;;
494+
esac
495+
496+
GCLOUD_TGZ="google-cloud-cli-${GCLOUD_VERSION}-linux-${GCLOUD_ARCH}.tar.gz"
497+
GCLOUD_TGZ_URL="https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/${GCLOUD_TGZ}"
498+
499+
curl -sSLO "${GCLOUD_TGZ_URL}"
500+
tar -xzf "${GCLOUD_TGZ}"
501+
./google-cloud-sdk/install.sh --usage-reporting=false --path-update=false --quiet
502+
mv google-cloud-sdk /usr/local/
503+
504+
cd -
505+
rm -rf "${TEMP_DIR}"
506+
EOF
507+
508+
ENV PATH="/usr/local/google-cloud-sdk/bin:${PATH}"
509+
475510
# e2fsprogs setup
476511
# Since e2fsprogs-static package has removed RHEL 8 distribution, it is not possible to install from the repository
477512
# 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
@@ -520,6 +555,9 @@ oc completion bash > /usr/share/bash-completion/completions/oc
520555
tkn completion bash > /usr/share/bash-completion/completions/tkn
521556
kubectl completion bash > /usr/share/bash-completion/completions/kubectl
522557
cat ${NVM_DIR}/bash_completion > /usr/share/bash-completion/completions/nvm
558+
if [ -f /usr/local/google-cloud-sdk/completion.bash.inc ]; then
559+
cat /usr/local/google-cloud-sdk/completion.bash.inc > /usr/share/bash-completion/completions/gcloud
560+
fi
523561
EOF
524562

525563
## 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="512.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)