gcloud-go -- a fast & lightweight rest client for deployment to Firebase Hosting, Google Cloud Storage and other APIs
For VM images, containers & cloud functions that have demanding iops, vcpu or time requirements, gcloud-go will avoid unnecessary resources
docker image | size | savings |
---|---|---|
firebase-tools | 245mb | n/a |
gcloud-go | 19mb | 92% |
docker image | deploy time for 7500 files | savings |
---|---|---|
firebase-tools | 16.5s | n/a |
gcloud-go | 8.8s | 45% |
Google Docs on Application Default Credentials explains the environment variables & configuration files that are used to find credentials
See releases page for the latest builds
To install inside your terminal, download and copy to your path.
# download
$ curl -LO https://github.com/tonymet/gcloud-go/releases/download/2024-10-18-d5dc06a/gcloud-go-2024-10-18-d5dc06a-linux-x86_64.tar.gz
# un-tar
$ tar -zxf *tar.gz
# run the binary
$ ./gcloud-go
See Google Artifact Registry (similar to Docker Hub) for docker images.
# run inside GCE using metadata-based credentials
$ docker run -v $(pwd)/test-output-small:/content \
gcloud-go deploy -source /content -site $SITE_NAME
# run outside GCE with APPL
$ docker run -eGOOGLE_APPLICATION_CREDENTIALS=$GOOGLE_APPLICATION_CREDENTIALS \
-v$HOME/public:/content -v$(pwd):/src \
us-west1-docker.pkg.dev/tonym-us/gcloud-lite/gcloud-go \
deploy -source /content -site $SITE_NAME;
For use inside docker images, copy the pre-built binary using the command COPY --from=
You can run the command inside your scripts by calling /gcloud-go
FROM alpine AS app-env
RUN apk update && apk add --no-cache zsh bind-tools envsubst tzdata
COPY --from=us-west1-docker.pkg.dev/tonym-us/gcloud-lite/gcloud-go /gcloud-go /gcloud-go
COPY . /app
WORKDIR /app
CMD ["zsh", "build.sh"]
$ gcloud-go deploy -site dev-isgithubipv6 -source content
usage: ./gcloud-go COMMAND [options]
deploy:
-connections int
number of connections (default 8)
-site string
Name of site (not project) (default "default")
-source string
Source directory for content (default "content")
-temp string
temp directory for staging files prior to upload (default "/tmp")
storage:
-bucket string
GCS Bucket
-prefix string
GCS Object Prefix (default "/")
-target string
Target Directory for download (default ".")
$ make bin
mkdir -p build/bin
go build -o build/bin/gcloud-go -ldflags="-extldflags=-static" .
It's preferred to always run the utility as a service account. To avoid risky service key creation, you can use impersonation
This will log in as a priviledged user, but authorize the utility as a service account. The temporary credential will
be written to $HOME/.config/gcloud/application_default_credentials.json
e.g.
PROJECT=your-project-1234
gcloud auth application-default login --impersonate-service-account dev-gcloud-go@${PROJECT}.iam.gserviceaccount.com