From 76b45a0f7a44425cd6df9dbb76d8d8226ecbebfd Mon Sep 17 00:00:00 2001 From: Nim Jayawardena Date: Mon, 18 Dec 2023 12:39:52 -0500 Subject: [PATCH] fix: Build Docker contains using gcloud for releases (#2306) --- docs/releasing/README.md | 4 +++- docs/releasing/make-docker-images.sh | 8 +++----- docs/releasing/make-release.sh | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/releasing/README.md b/docs/releasing/README.md index 126936a071d..fa766a9022a 100755 --- a/docs/releasing/README.md +++ b/docs/releasing/README.md @@ -14,12 +14,14 @@ This document walks through the process of creating a new release of Online Bout - `TAG` - This is the new version (e.g., `v0.3.5`). - `REPO_PREFIX` - This is the Docker repository. + - `PROJECT_ID` - This is the Google Cloud project in which Google Cloud Build will be used to remotely build microservice Docker images. **Example:** - + ``` export TAG=v0.3.5 export REPO_PREFIX=gcr.io/google-samples/microservices-demo + export PROJECT_ID=google-samples ``` 5. Run `./docs/releasing/make-release.sh`. diff --git a/docs/releasing/make-docker-images.sh b/docs/releasing/make-docker-images.sh index 4f360276a5b..f7fa5cd4fe4 100755 --- a/docs/releasing/make-docker-images.sh +++ b/docs/releasing/make-docker-images.sh @@ -24,6 +24,7 @@ log() { echo "$1" >&2; } TAG="${TAG:?TAG env variable must be specified}" REPO_PREFIX="${REPO_PREFIX:?REPO_PREFIX env variable must be specified}" +PROJECT_ID="${PROJECT_ID:?PROJECT_ID env variable must be specified e.g. google-samples}" while IFS= read -d $'\0' -r dir; do # build image @@ -37,11 +38,8 @@ while IFS= read -d $'\0' -r dir; do image="${REPO_PREFIX}/$svcname:$TAG" ( cd "${builddir}" - log "Building: ${image}" - docker build --pull -t "${image}" . - - log "Pushing: ${image}" - docker push "${image}" + log "Building (and pushing) image on Google Cloud Build: ${image}" + gcloud builds submit --project=${PROJECT_ID} --tag=${image} ) done < <(find "${REPO_ROOT}/src" -mindepth 1 -maxdepth 1 -type d -print0) diff --git a/docs/releasing/make-release.sh b/docs/releasing/make-release.sh index 6110ad4f138..457685c6f81 100755 --- a/docs/releasing/make-release.sh +++ b/docs/releasing/make-release.sh @@ -30,6 +30,7 @@ fail() { log "$1"; exit 1; } TAG="${TAG:?TAG env variable must be specified}" REPO_PREFIX="${REPO_PREFIX:?REPO_PREFIX env variable must be specified e.g. gcr.io\/google-samples\/microservices-demo}" +PROJECT_ID="${PROJECT_ID:?PROJECT_ID env variable must be specified e.g. google-samples}" if [[ "$TAG" != v* ]]; then fail "\$TAG must start with 'v', e.g. v0.1.0 (got: $TAG)"