CloudBuild unable to deploy angular app

Hello Everyone,

We have a strange issue. The angular app is not getting deployed to app engine using cloudbuild. Manual deployment works fine.

Description of the environment-

There is an angular app which we have built. The app has been deployed to app engine. 

Issue-

Deployment to app engine works fine when it is deployed using the gcloud app deploy command. However, when we try to deploy the app using cloudbuild, it fails to deploy. 

Contents of the app.yaml file are as below -

runtime: nodejs20
instance_class: F2
env_variables:
  BUCKET_NAME: "rcac-frontend"

handlers:

  - url: /
    static_files: dist/app_folder/index.html
    upload: dist/app_folder/index.html

  - url: /(.*\.js)
    static_files: dist/app_folder/\1
    upload: dist/app_folder/(.*\.js)

  - url: /(.*\.less)
    static_files: dist/app_folder/\1
    upload: dist/app_folder/(.*\.less)

  - url: /(.*\.scss)
    static_files: dist/app_folder/\1
    upload: dist/app_folder/(.*\.scss)

  - url: /(.*\.css)
    static_files: dist/app_folder/\1
    upload: dist/app_folder/(.*\.css)

  - url: /(.*\.ico)
    static_files: dist/app_folder/\1
    upload: dist/app_folder/(.*\.ico)

  - url: /(.*)
    static_files: dist/app_folder/index.html
    upload: dist/app_folder/index.html
 
The cloudbuild.yaml file looks as below -
 

steps:

  # Install node packages
  - name: "gcr.io/cloud-builders/npm"
    args: ["install"]
   
   
  # Build production package
  - name: "gcr.io/cloud-builders/npm"
    args: ["run",build", "--prod"]
   

  # Deploy to google cloud app engine
  - name: "gcr.io/cloud-builders/gcloud"
    args: ["app", "deploy", "--version=prod"]
 
Below is the cloubuild error logs which we are getting - 
 
2023-09-26 12:04:57.647 IST
Step #0: npm ERR! code ERESOLVE
 
2023-09-26 12:04:57.649 IST
Step #0: npm ERR! ERESOLVE could not resolve
 
2023-09-26 12:04:57.649 IST
Step #0: npm ERR!
 
2023-09-26 12:04:57.650 IST
Step #0: npm ERR! While resolving: ng2-charts@5.0.3
 
2023-09-26 12:04:57.650 IST
Step #0: npm ERR! Found: @angular/cdk@13.3.9
 
2023-09-26 12:04:57.650 IST
Step #0: npm ERR! node_modules/@angular/cdk
 
2023-09-26 12:04:57.650 IST
Step #0: npm ERR! @angular/cdk@"~13.3.9" from the root project
 
2023-09-26 12:04:57.650 IST
Step #0: npm ERR! peer @angular/cdk@"13.3.9" from @angular/material@13.3.9
 
2023-09-26 12:04:57.650 IST
Step #0: npm ERR! node_modules/@angular/material
 
2023-09-26 12:04:57.650 IST
Step #0: npm ERR! @angular/material@"~13.3.9" from the root project
 
2023-09-26 12:04:57.651 IST
Step #0: npm ERR!
 
2023-09-26 12:04:57.651 IST
Step #0: npm ERR! Could not resolve dependency:
 
2023-09-26 12:04:57.651 IST
Step #0: npm ERR! peer @angular/cdk@">=16.0.0" from ng2-charts@5.0.3
 
2023-09-26 12:04:57.651 IST
Step #0: npm ERR! node_modules/ng2-charts
 
2023-09-26 12:04:57.651 IST
Step #0: npm ERR! ng2-charts@"^5.0.1" from the root project
 
2023-09-26 12:04:57.651 IST
Step #0: npm ERR!
 
2023-09-26 12:04:57.651 IST
Step #0: npm ERR! Conflicting peer dependency: @angular/cdk@16.2.5
 
Any pointers in this regard would be greatly appreciated. In case there is any missing info, please feel free to comment and I can add them.
 
1 2 479
2 REPLIES 2

Hello @digantakoner,

The first thing I noticed with your cloudbuild.yaml is:

args: ["run",build""--prod"]

You seem to be missing a  ( " ) at the start of your build keyword. This could be a reason why it's not deploying through cloudbuild.yaml, but still deploys using the Cloud CLI.

Let me know if it helped, thanks!

Hello @Marramirez , 

I tried with the quotes in place but sadly I am getting the same error as mentioned in the logs in the post.