🦔

Dockerfileでgcloud CLIをインストール

2024/04/22に公開

手順

Dockerfileに下記を記述

RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list \
    && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg \
    && apt-get update -y \
    && apt-get install google-cloud-sdk -y

ENV CLOUDSDK_CORE_PROJECT = YOUR_PROJECT_NAME

Dockerを立ち上げたあとDockerの中で

gcloud auth application-default login

を実行

参考

https://cloud.google.com/sdk/docs/install?hl=ja#deb

https://cloud.google.com/docs/authentication/application-default-credentials?hl=ja#personal

https://cloud.google.com/sdk/docs/properties?hl=ja#setting_properties_using_environment_variables

Discussion