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

Google Cloud CLI override bundled Python (use OS Python) #21

Merged
merged 2 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
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
32 changes: 21 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ ENV LANG="C.UTF-8" \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_ROOT_USER_ACTION="ignore" \
PYTHONUNBUFFERED="True" \
# https://cloud.google.com/sdk/gcloud/reference/topic/startup
PATH="/usr/bin/google-cloud-sdk/bin:$PATH" \
CLOUDSDK_PYTHON="/usr/bin/python3" \
# https://github.com/sgarciac/fuego/releases
FUEGO_VERSION="0.35.0" \
# https://github.com/GoogleCloudPlatform/gcr-cleaner/releases
Expand All @@ -47,6 +50,7 @@ FROM base AS amd64
# Download URLs for AMD64 (X86/64)
ENV AWS_CLI_URL="https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" \
FUEGO_URL="https://github.com/sgarciac/fuego/archive/refs/tags/${FUEGO_VERSION}.tar.gz" \
GCLOUD_URL="https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-linux-x86_64.tar.gz" \
GCR_CLEANER_URL="https://github.com/GoogleCloudPlatform/gcr-cleaner/releases/download/v${GCR_CLEANER_VERSION}/gcr-cleaner-cli_${GCR_CLEANER_VERSION}_linux_amd64.tar.gz" \
OPA_URL="https://github.com/open-policy-agent/opa/releases/latest/download/opa_linux_amd64_static" \
TERRAGRUNT_URL="https://github.com/gruntwork-io/terragrunt/releases/latest/download/terragrunt_linux_amd64" \
Expand All @@ -58,6 +62,7 @@ FROM base AS arm64
# Download URLs for ARM64
ENV AWS_CLI_URL="https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" \
FUEGO_URL="https://github.com/sgarciac/fuego/archive/refs/tags/${FUEGO_VERSION}.tar.gz" \
GCLOUD_URL="https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-linux-arm.tar.gz" \
GCR_CLEANER_URL="https://github.com/GoogleCloudPlatform/gcr-cleaner/releases/download/v${GCR_CLEANER_VERSION}/gcr-cleaner-cli_${GCR_CLEANER_VERSION}_linux_arm64.tar.gz" \
OPA_URL="https://github.com/open-policy-agent/opa/releases/latest/download/opa_linux_arm64_static" \
TERRAGRUNT_URL="https://github.com/gruntwork-io/terragrunt/releases/latest/download/terragrunt_linux_arm64" \
Expand Down Expand Up @@ -88,6 +93,7 @@ RUN uname -m && \
npm \
openssh-client \
python3-crcmod \
python3-openssl \
python3-pip \
python3-venv \
shellcheck \
Expand Down Expand Up @@ -115,12 +121,6 @@ RUN uname -m && \
packer \
terraform \
vault && \
# Install Google Cloud CLI without Anthos
apt-get install -yqq --no-install-recommends \
google-cloud-cli \
# https://issuetracker.google.com/issues/383568269
#google-cloud-cli=502.0.0-0 \
google-cloud-sdk-gke-gcloud-auth-plugin && \
# Fix "vault: Operation not permitted" error
# https://github.com/hashicorp/vault/issues/10924
setcap -r "/usr/bin/vault" && \
Expand All @@ -142,6 +142,21 @@ RUN uname -m && \
mv "fuego" "/usr/bin/fuego" && \
cd "../" && \
rm -rf fuego* && \
# Google Cloud CLI (https://cloud.google.com/sdk/docs/install#linux)
echo "Google Cloud CLI URL: '$GCLOUD_URL'" && \
curl -L "$GCLOUD_URL" -o "gcloud.tar.gz" && \
tar -C "/usr/bin/" -xf "gcloud.tar.gz" "google-cloud-sdk" && \
rm "gcloud.tar.gz" && \
if [ -d "/usr/bin/google-cloud-sdk/platform/bundledpythonunix" ]; then \
rm -rf "/usr/bin/google-cloud-sdk/platform/bundledpythonunix"; \
fi && \
if [ -d "/usr/bin/google-cloud-sdkgoogle-cloud-sdk/.install" ]; then \
rm -rf "/usr/bin/google-cloud-sdkgoogle-cloud-sdk/.install"; \
fi && \
gcloud components install -q "gke-gcloud-auth-plugin" && \
gcloud config set "component_manager/disable_update_check" "true" && \
gcloud config set "core/disable_usage_reporting" "true" && \
gcloud config set "survey/disable_prompts" "true" && \
# GCR Cleaner (https://github.com/GoogleCloudPlatform/gcr-cleaner)
echo "GCR Cleaner URL: '$GCR_CLEANER_URL'" && \
curl -L "$GCR_CLEANER_URL" -o "gcr-cleaner-cli.tar.gz" && \
Expand Down Expand Up @@ -180,11 +195,6 @@ RUN uname -m && \
# Firebase CLI (https://github.com/firebase/firebase-tools)
echo "Install Firebase..." && \
npm install --global "firebase-tools" && \
# Google Cloud CLI config
gcloud config set "component_manager/disable_update_check" "true" && \
gcloud config set "core/disable_usage_reporting" "true" && \
gcloud config set "metrics/environment" "docker_image_latest" && \
gcloud config set "survey/disable_prompts" "true" && \
# Delete caches
echo "Clean up..." && \
apt-get clean && \
Expand Down
22 changes: 18 additions & 4 deletions devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ FROM mcr.microsoft.com/devcontainers/base:ubuntu-24.04 AS base
ENV LANG="C.UTF-8" \
DEBIAN_FRONTEND="noninteractive" \
NONINTERACTIVE=1 \
# https://cloud.google.com/sdk/gcloud/reference/topic/startup
PATH="/usr/bin/google-cloud-sdk/bin:$PATH" \
CLOUDSDK_PYTHON="/usr/bin/python3" \
# https://github.com/sgarciac/fuego/releases
FUEGO_VERSION="0.35.0" \
# https://github.com/GoogleCloudPlatform/gcr-cleaner/releases
Expand All @@ -41,6 +44,7 @@ FROM base AS amd64
# Download URLs for AMD64 (X86/64)
ENV AWS_CLI_URL="https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" \
FUEGO_URL="https://github.com/sgarciac/fuego/archive/refs/tags/${FUEGO_VERSION}.tar.gz" \
GCLOUD_URL="https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-linux-x86_64.tar.gz" \
GCR_CLEANER_URL="https://github.com/GoogleCloudPlatform/gcr-cleaner/releases/download/v${GCR_CLEANER_VERSION}/gcr-cleaner-cli_${GCR_CLEANER_VERSION}_linux_amd64.tar.gz" \
OPA_URL="https://github.com/open-policy-agent/opa/releases/latest/download/opa_linux_amd64_static" \
TERRAGRUNT_URL="https://github.com/gruntwork-io/terragrunt/releases/latest/download/terragrunt_linux_amd64" \
Expand All @@ -52,6 +56,7 @@ FROM base AS arm64
# Download URLs for ARM64
ENV AWS_CLI_URL="https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" \
FUEGO_URL="https://github.com/sgarciac/fuego/archive/refs/tags/${FUEGO_VERSION}.tar.gz" \
GCLOUD_URL="https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-linux-arm.tar.gz" \
GCR_CLEANER_URL="https://github.com/GoogleCloudPlatform/gcr-cleaner/releases/download/v${GCR_CLEANER_VERSION}/gcr-cleaner-cli_${GCR_CLEANER_VERSION}_linux_arm64.tar.gz" \
OPA_URL="https://github.com/open-policy-agent/opa/releases/latest/download/opa_linux_arm64_static" \
TERRAGRUNT_URL="https://github.com/gruntwork-io/terragrunt/releases/latest/download/terragrunt_linux_arm64" \
Expand Down Expand Up @@ -93,6 +98,7 @@ RUN uname -m && \
nyancat \
openssh-client \
python3-crcmod \
python3-openssl \
python3-pip \
python3-venv \
screen \
Expand Down Expand Up @@ -125,10 +131,6 @@ RUN uname -m && \
packer \
terraform \
vault && \
# Install Google Cloud CLI without Anthos
apt-get install -yqq --no-install-recommends \
google-cloud-cli \
google-cloud-sdk-gke-gcloud-auth-plugin && \
# Fix "vault: Operation not permitted" error
# https://github.com/hashicorp/vault/issues/10924
setcap -r "/usr/bin/vault" && \
Expand All @@ -149,6 +151,18 @@ RUN uname -m && \
mv "fuego" "/usr/bin/fuego" && \
cd "../" && \
rm -rf fuego* && \
# Google Cloud CLI (https://cloud.google.com/sdk/docs/install#linux)
echo "Google Cloud CLI URL: '$GCLOUD_URL'" && \
curl -L "$GCLOUD_URL" -o "gcloud.tar.gz" && \
tar -C "/usr/bin/" -xf "gcloud.tar.gz" "google-cloud-sdk" && \
rm "gcloud.tar.gz" && \
if [ -d "/usr/bin/google-cloud-sdk/platform/bundledpythonunix" ]; then \
rm -rf "/usr/bin/google-cloud-sdk/platform/bundledpythonunix"; \
fi && \
if [ -d "/usr/bin/google-cloud-sdkgoogle-cloud-sdk/.install" ]; then \
rm -rf "/usr/bin/google-cloud-sdkgoogle-cloud-sdk/.install"; \
fi && \
gcloud components install -q "gke-gcloud-auth-plugin" && \
# GCR Cleaner (https://github.com/GoogleCloudPlatform/gcr-cleaner)
curl -L "$GCR_CLEANER_URL" -o "gcr-cleaner-cli.tar.gz" && \
tar -xf "gcr-cleaner-cli.tar.gz" "gcr-cleaner-cli" && \
Expand Down
1 change: 1 addition & 0 deletions workstations/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ RUN uname -m && \
nyancat \
openssh-client \
python3-crcmod \
python3-openssl \
python3-pip \
python3-venv \
screen \
Expand Down