Skip to content

Commit

Permalink
Reliable project and region on GCE
Browse files Browse the repository at this point in the history
  • Loading branch information
thalassemia committed Nov 20, 2024
1 parent 293f61d commit 1a485af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 7 additions & 2 deletions runscripts/container/build-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ if [ "$RUN_LOCAL" = true ]; then
echo "=== Locally building WCM runtime Docker Image: ${RUNTIME_IMAGE} ==="
docker build -f runscripts/container/runtime/Dockerfile -t "${WCM_RUNTIME}" .
else
PROJECT="$(gcloud config get-value core/project)"
REGION=$(gcloud config get compute/region)
PROJECT=$(curl -H "Metadata-Flavor: Google" \
"http://metadata.google.internal/computeMetadata/v1/project/project-id" |
cut '-d/' -f4)
REGION=$(curl -H "Metadata-Flavor: Google" \
"http://metadata.google.internal/computeMetadata/v1/instance/zone" |
awk -F'/' '{print $NF}' |
sed 's/-[a-z]$//')
TAG="${REGION}-docker.pkg.dev/${PROJECT}/vecoli/${RUNTIME_IMAGE}"
echo "=== Cloud-building WCM runtime Docker Image: ${TAG} ==="
echo $TAG
Expand Down
6 changes: 4 additions & 2 deletions runscripts/container/build-wcm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ if [ "$RUN_LOCAL" = true ]; then
else
echo "=== Cloud-building WCM code Docker Image ${WCM_IMAGE} on ${RUNTIME_IMAGE} ==="
echo "=== git hash ${GIT_HASH}, git branch ${GIT_BRANCH} ==="
PROJECT_ID=$(gcloud config get project)
REGION=$(gcloud config get compute/region)
REGION=$(curl -H "Metadata-Flavor: Google" \
"http://metadata.google.internal/computeMetadata/v1/instance/zone" |
awk -F'/' '{print $NF}' |
sed 's/-[a-z]$//')
# This needs a config file to identify the project files to upload and the
# Dockerfile to run.
gcloud builds submit --timeout=15m --config runscripts/container/cloud_build.json \
Expand Down

0 comments on commit 1a485af

Please sign in to comment.