2

We have an Angular 18 app that uses Git submodules:

.gitmodules file:

[submodule "projects/shared-lib/src/whatever-lib"]
    path = projects/shared-lib/src/whatever-lib
    url = https://source.developers.google.com/p/whatever-project/r/angular-lib
    branch = whatever-branch

We're using Firebase App Hosting to deploy our app. We configured App Hosting according to the documentation for a basic example.

The problem: Cloud build is not downloading the submodules, so it fails with a lot of errors related to not finding references:

Error: ✘ [ERROR] TS2307: Cannot find module '@common/api-server' or its corresponding type declarations. [plugin angular-compiler]\n\n projects/shared-lib/src/lib/client/client-db.service.ts:6:47

(@common points to projects/shared-lib/src)

Submodules are hosted in Cloud Source Repositories on the same project. Just in case, we explicitly added the App Hosting service account (firebase-app-hosting-compute@whatever-project.iam.gserviceaccount.com) to the repository users with Cloud Build Service Account role.

By the Cloud Build logs, it doesn't even seem to be trying to download the submodules before building.

What we found: We've found similar issues here and here of people having the same problem with Cloud Build and Git submodules. The difference is that they're using Cloud Build directly (instead of using App Hosting from Firebase), so they can add a step 0 to their cloudbuild.yaml to download the submodules. We don't have that file.

What we tried:

  • Adding cloudbuild.yaml to the root of the project with that single step, doesn't seem to have any effects.
  • We added prebuild: "echo ON_PREBUILD && git submodule update --init" to our package.json, but build fails. I don't really understand the error shown:

2024-06-30 11:41:00.659 CEST Step #2: reject(new Error(Process exited with error code ${code}. Output: ${buildOutput}));
2024-06-30 11:41:00.659 CEST Step #2: ^
2024-06-30 11:41:00.659 CEST Step #2:
2024-06-30 11:41:00.659 CEST Step #2: Error: Process exited with error code 1. Output:
2024-06-30 11:41:00.659 CEST Step #2: > [email protected] prebuild. 2024-06-30 11:41:00.659 CEST Step #2: > echo ON_PREBUILD && git submodule update --init. 2024-06-30 11:41:00.659 CEST Step #2:
2024-06-30 11:41:00.659 CEST Step #2: ON_PREBUILD
2024-06-30 11:41:00.659 CEST Step #2:
2024-06-30 11:41:00.659 CEST Step #2: at ChildProcess. (file:///layers/google.nodejs.firebaseangular/npm_modules/node_modules/@apphosting/adapter-angular/dist/utils.js:104:20)
2024-06-30 11:41:00.659 CEST Step #2: at ChildProcess.emit (node:events:517:28)
2024-06-30 11:41:00.659 CEST Step #2: at ChildProcess._handle.onexit (node:internal/child_process:292:12)
2024-06-30 11:41:00.659 CEST Step #2:
2024-06-30 11:41:00.659 CEST Step #2: Node.js v18.20.3
2024-06-30 11:41:00.659 CEST Step #2: --------------------------------------------------------------------------------
2024-06-30 11:41:00.659 CEST Step #2: Sorry your project couldn't be built.
2024-06-30 11:41:00.659 CEST Step #2: Our documentation explains ways to configure Buildpacks to better recognise your project:
2024-06-30 11:41:00.659 CEST Step #2: -> https://cloud.google.com/docs/buildpacks/overview.

Any ideas how to make Cloud Build download Git submodules when using Firebase App Hosting?

3
  • Same problem, for reference adding build steps to the apphosting.yaml seems to have no effect either. Following.
    – polar
    Commented Jul 1 at 0:04
  • did you find a solution?
    – polar
    Commented Jul 19 at 0:51
  • @polar Nop. We're back to using regular Hosting instead of App Hosting until this evolves a bit more. Looking forward to it.
    – maganap
    Commented Jul 20 at 10:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.