Skip to content

Instantly share code, notes, and snippets.

@kenichi
Last active Nov 7, 2022
Embed
What would you like to do?
gcloud docker with cli alias for m1
FROM google/cloud-sdk:latest
ARG UID
ARG GID
ARG USERNAME
RUN useradd -u $UID -g $GID $USERNAME
WORKDIR /home/$USERNAME
USER $USERNAME
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)
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