Last active
November 7, 2022 21:08
-
-
Save kenichi/0176d37ed6f66222446f2abf94682823 to your computer and use it in GitHub Desktop.
gcloud docker with cli alias for m1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM google/cloud-sdk:latest | |
ARG UID | |
ARG GID | |
ARG USERNAME | |
RUN useradd -u $UID -g $GID $USERNAME | |
WORKDIR /home/$USERNAME | |
USER $USERNAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UID := $(shell id -u) | |
GID := $(shell id -g) | |
USERNAME := $(shell id -u -n) | |
IMAGE := google/cloud-sdk:latest | |
.PHONY: build pull | |
build: pull | |
@docker build \ | |
--build-arg UID=$(UID) \ | |
--build-arg GID=$(GID) \ | |
--build-arg USERNAME=$(USERNAME) \ | |
-t $(USERNAME)/gcloud \ | |
. | |
pull: | |
@docker pull $(IMAGE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias gcloud="docker run --rm -it --user 501:20 \ | |
-v ~/.gcp/config:/home/${USER}/.config \ | |
-v ~/.gcp/kube:/home/${USER}/.kube \ | |
-v ~/.gcp/ssh:/home/${USER}/.ssh \ | |
--platform linux/amd64 ${USER}/gcloud gcloud" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment