Skip to content

Commit

Permalink
Moving to using Container Repository from Artifact Registry (due to n…
Browse files Browse the repository at this point in the history
…umerous errors clients faced with creating AR)

Change-Id: Ida192d76da8bd0c5f1f984d8cd7379f79825172c
  • Loading branch information
evil-shrike committed Aug 9, 2023
1 parent 7b422d3 commit ca9c0e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions gcp/cloudbuild-gcr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
steps:
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/${_IMAGE}', '-f', 'gcp/workload-vm/Dockerfile', '.' ]

images: [ 'gcr.io/$PROJECT_ID/${_IMAGE}' ]
13 changes: 8 additions & 5 deletions gcp/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ deploy_files() {
enable_apis() {
echo "Enabling APIs"
gcloud services enable compute.googleapis.com
gcloud services enable artifactregistry.googleapis.com
#gcloud services enable artifactregistry.googleapis.com
gcloud services enable containerregistry.googleapis.com
gcloud services enable run.googleapis.com
gcloud services enable cloudresourcemanager.googleapis.com
gcloud services enable iamcredentials.googleapis.com
Expand Down Expand Up @@ -93,7 +94,7 @@ build_docker_image() {
build_docker_image_gcr() {
# NOTE: it's an alternative to build_docker_image if you want to use GCR instead of AR
echo "Building and pushing Docker image to Container Registry"
gcloud builds submit --config=cloudbuild-gcr.yaml --substitutions=_IMAGE="workload" ./workload-vm
gcloud builds submit --config=cloudbuild-gcr.yaml --substitutions=_IMAGE="$IMAGE_NAME" ./..
}


Expand Down Expand Up @@ -128,7 +129,8 @@ deploy_cf() {
fi
# initialize env.yaml - environment variables for CF:
# - docker image url
url="$REPOSITORY_LOCATION-docker.pkg.dev/$PROJECT_ID/docker/$IMAGE_NAME"
#url="$REPOSITORY_LOCATION-docker.pkg.dev/$PROJECT_ID/docker/$IMAGE_NAME"
url="gcr.io/$PROJECT_ID/$IMAGE_NAME"
sed -i'.bak' -e "s|#*[[:space:]]*DOCKER_IMAGE[[:space:]]*:[[:space:]]*.*$|DOCKER_IMAGE: $url|" ./cloud-functions/create-vm/env.yaml
# - GCE VM name (base)
instance=$(eval echo $(git config -f $SETTING_FILE compute.name))
Expand Down Expand Up @@ -305,8 +307,9 @@ enable_private_google_access() {
deploy_all() {
enable_apis
set_iam_permissions
create_registry
build_docker_image
#create_registry
#build_docker_image
build_docker_image_gcr
deploy_cf
deploy_files
schedule_run
Expand Down

0 comments on commit ca9c0e9

Please sign in to comment.