Reputation: 1548
I have a node.js website that runs fine when I run it locally with node server.js
. I'm trying to deploy it online with GCP. I created a project, enabled app engine API, and gave my '@cloudbuild.gserviceaccount.com' account app engine deployer role permissions.
I also added a cloudbuild.yaml file to my repo:
steps:
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy"]
Now If I run gcloud app deploy
, my build gets triggered, but appears to me causing an infinite loop of builds? For example, starting out my build log looks like this (nothing currently running):
i run gcloud app deploy
and it begins a new build (1a19d9ba):
But something with this build keeps triggering new builds? in my local computer terminal, the output I get for running gcloud app deploy
keeps triggering new builds:
$ gcloud app deploy
Services to deploy:
descriptor: [/mnt/c/Users/marti/Documents/projects/martinbarker/app.yaml]
source: [/mnt/c/Users/marti/Documents/projects/martinbarker]
target project: [martinbarker2]
target service: [default]
target version: [20201003t165547]
target url: [https://martinbarker2.wl.r.appspot.com]
Do you want to continue (Y/n)? y
Beginning deployment of service [default]...
Building and pushing image for service [default]
Started cloud build [1a19dxxxxx627d].
To see logs in the Cloud Console: https://console.cloud.google.com/cloud-build/builds/1axxx
------------------------------------------------- REMOTE BUILD OUTPUT --------------------------------------------------starting build "1a19xxxxxx27d"
FETCHSOURCE
Fetching storage object: gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.20xxx47:latest#160xxx288
Copying gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.202xxx547:latest#16xxx88...
| [1 files][117.7 MiB/117.7 MiB]
Operation completed over 1 objects/117.7 MiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
Services to deploy:
descriptor: [/workspace/app.yaml]
source: [/workspace]
target project: [martinbarker2]
target service: [default]
target version: [20201003t235749]
target url: [https://martinbarker2.wl.r.appspot.com]
Do you want to continue (Y/n)?
WARNING: Unable to verify that the Appengine Flexible API is enabled for project [martinbarker2]. You may not have permission to list enabled services on this project. If it is not enabled, this may cause problems in running your deployment. Please ask the project owner to ensure that the Appengine Flexible API has been enabled and that this account has permission to list enabled APIs.
Beginning deployment of service [default]...
Building and pushing image for service [default]
Started cloud build [d0d0xxx9a987].
To see logs in the Cloud Console: https://console.cloud.google.com/cloud-build/builds/d0d0xxx987?project=114941087848
----------------------------- REMOTE BUILD OUTPUT ------------------------------
starting build "d0d0dxxx987"
FETCHSOURCE
Fetching storage object: gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.20201xxx49:latest#160176947xx11
Copying gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.20xxx:latest#16xxx548211...
\ [1 files][117.7 MiB/117.7 MiB]
Operation completed over 1 objects/117.7 MiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
Services to deploy:
descriptor: [/workspace/app.yaml]
source: [/workspace]
target project: [martinbarker2]
target service: [default]
target version: [20201003t235818]
target url: [https://martinbarker2.wl.r.appspot.com]
Do you want to continue (Y/n)?
WARNING: Unable to verify that the Appengine Flexible API is enabled for project [martinbarker2]. You may not have permission to list enabled services on this project. If it is not enabled, this may cause problems in running your deployment. Please ask the project owner to ensure that the Appengine Flexible API has been enabled and that this account has permission to list enabled APIs.
Beginning deployment of service [default]...
Building and pushing image for service [default]
Started cloud build [683bb8cxxx0368f36].
To see logs in the Cloud Console: https://console.cloud.google.com/cloud-build/builds/683bxxxf36?project=114xx48
----------------------------- REMOTE BUILD OUTPUT ------------------------------
starting build "683bb8xx368f36"
FETCHSOURCE
Fetching storage object: gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.2020xxx18:latest#16xxx376
Copying gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.202xxx18:latest#16xx376...
| [1 files][117.7 MiB/117.7 MiB]
Operation completed over 1 objects/117.7 MiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
Services to deploy:
descriptor: [/workspace/app.yaml]
source: [/workspace]
target project: [martinbarker2]
target service: [default]
target version: [20201003t235843]
target url: [https://martinbarker2.wl.r.appspot.com]
Do you want to continue (Y/n)?
WARNING: Unable to verify that the Appengine Flexible API is enabled for project [martinbarker2]. You may not have permission to list enabled services on this project. If it is not enabled, this may cause problems in running your deployment. Please ask the project owner to ensure that the Appengine Flexible API has been enabled and that this account has permission to list enabled APIs.
Beginning deployment of service [default]...
Building and pushing image for service [default]
Started cloud build [feecxxx3cd86].
To see logs in the Cloud Console: https://console.cloud.google.com/cloud-build/builds/feexxx87848
----------------------------- REMOTE BUILD OUTPUT ------------------------------
starting build "feec9xxxx3cd86"
FETCHSOURCE
Fetching storage object: gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.2020100xxx082
Copying gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.202xxx82...
- [1 files][117.7 MiB/117.7 MiB]
Operation completed over 1 objects/117.7 MiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
Services to deploy:
descriptor: [/workspace/app.yaml]
source: [/workspace]
target project: [martinbarker2]
target service: [default]
target version: [20201003t235909]
target url: [https://martinbarker2.wl.r.appspot.com]
Do you want to continue (Y/n)?
This goes on, and now I have many more builds:
My app.yaml:
runtime: custom
env: flex
manual_scaling:
instances: 2
is it something with my cloudbuild.yaml file? I dont have a dockerfile in my folder
Upvotes: 1
Views: 1107
Reputation: 75810
"It's not a bug; it's a feature!" But it's not documented, or I didn't find where! Actually, with App Engine Flex custom runtime, you will create a container. You can define either a cloudbuild.yaml
file or a Dockerfile
to describe the container creation. And this container is created with Cloud Build.
For information, if you set a specific language runtime, Buildpack is used to create the container, still on Cloud Build; however a Dockerfile is no longer required
So, in your case, as you describe, you have a cloudbuild.yaml
file that deploys an App Engine flex custom runtime, that call a Cloud Build to build the container, with the cloudbuild.yaml
file in parameters that deploys..... (loop!)
Ok, now, how to fix this? 2 solutions
cloudbuild.yaml
file to not match this default naming (cloudbuild-noloop.yaml
for example). Set this name in the trigger configuration or in the gcloud builds submit --config=cloudbuild-noloop.yaml
commandcloudbuild.yaml
deploy step like thissteps:
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy","--ignore-file=cloudbuild.yaml"]
Upvotes: 3