buildpacks icon indicating copy to clipboard operation
buildpacks copied to clipboard

Gcloud Build fails when using a Procfile with custom command names

Open Standaa opened this issue 1 year ago • 2 comments

Describe the bug

Hello, I am building an app containing several workers for Cloud Run Jobs. I followed the steps in the documentation and had a look at some of the examples but could not find a precise answer for the behaviour I am facing.

I am trying to issue the following command: gcloud builds submit --pack image=gcr.io/my-project-id/uploader

I have a Procfile that looks like the following:

workeruploadprofiles: npx tsx src/data-pipeline/uploadProfilesToS3.ts
workeruploadjobs: npx tsx src/data-pipeline/uploadAirtableToS3.ts

When I build I expect my app build to succeed. It does not. It fails with the following error:

Step #1: ERROR: failed to build: executing lifecycle: failed with status code: 51

If I replace the content of my Procfile with just:

worker: npx tsx src/data-pipeline/uploadProfilesToS3.ts

It fails again.

The only way I can get the build to succeed is by setting the following:

web: npx tsx src/data-pipeline/uploadProfilesToS3.ts

This is not only weird (I dont need to open a port, this is not a server).

The documentation is not quite clear imo about web being mandatory in the Procfile. Why is web mandatory? Is it normal behaviour?

Additional context How are you using GCP buildpacks?

  • [x] pack and the gcr.io/buildpacks/builder
  • [ ] Cloud Functions
  • [x] Cloud Run
  • [ ] Cloud Build
  • [ ] App Engine Standard
  • [ ] App Engine Flex

What language is your project primarily written in? Node.js

Standaa avatar May 26 '23 08:05 Standaa

Thank you for the detailed bug report @Standaa . I took a quick look into our Procfile processing code, and it looks like we require a web entry because we want to set something as the default process. I suspect this is because the code was originally written to support HTTP driven products (App Engine, Cloud Run etc).

This should be an easy fix, but I want to think a bit more about the implications of changing it. For now you might be able to add a web entry to your Procfile to get unblocked:

workeruploadprofiles: npx tsx src/data-pipeline/uploadProfilesToS3.ts
workeruploadjobs: npx tsx src/data-pipeline/uploadAirtableToS3.ts
web: node --version

matthewrobertson avatar May 26 '23 16:05 matthewrobertson

Just verified that this suggested workaround will work until a proper fix is rolled out.

smsohan avatar May 26 '23 16:05 smsohan