Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error when deploying from gcloud cli with local file dependencies #591

Open
immber opened this issue Feb 10, 2024 · 3 comments
Open
Labels
gcf bug A bug with the product: Cloud Functions P2

Comments

@immber
Copy link

immber commented Feb 10, 2024

Deploying from local source with gcloud functions deploy seems unable to include local file dependencies.

When setting --set-build-env-vars GOOGLE_VENDOR_NPM_DEPENDENCIES=true and package.json is referencing something like "app-common": "file:./localpath" builds fail and throw the following build error:

"Step #2 - "build": panic: runtime error: invalid memory address or nil pointer dereference"

Was expecting this should work:

gcloud functions deploy my-function \
    --entry-point=create \
    --trigger-http \
    --set-build-env-vars GOOGLE_VENDOR_NPM_DEPENDENCIES=true 

But I was able to work around by building a docker image locally and manually pushing:

pack build \
  --builder gcr.io/buildpacks/builder:v1 \
  --env GOOGLE_FUNCTION_SIGNATURE_TYPE=http \
  --env GOOGLE_FUNCTION_TARGET=create \
  --env GOOGLE_VENDOR_NPM_DEPENDENCIES=true \
  my-function

If I try the gcloud functions deploy command minus the build env var, it pushes an image to the cloud function that is missing dependencies. It would be great if this could deploy from local source in one step and have it correctly include dependencies, instead of manually having to build a docker image and push.

@kenneth-rosario
Copy link
Contributor

Hey immber can you share a small reproduction that is similar to your setup.

@immber
Copy link
Author

immber commented Feb 10, 2024

@kenneth-rosario , I pushed up a little example here: https://github.com/immber/gcf-build-err

I've been following the docs at: https://cloud.google.com/functions/docs/writing/specifying-dependencies-nodejs#build_your_function_with_vendored_dependencies

The example is just exporting a string to reproduce the error, but my actual use case is that I'm including a /dist folder that is built by a nested dependency which I'm including at root inside my local source.

I'd love to be able to deploy directly with glcoud function deploy but instead I'm having to build the docker container manually with pack then push that to artifact registry, and then deploy a new revision from CloudRun.

@kenneth-rosario
Copy link
Contributor

@immber Thanks for the reproduction. Will try this out!

@kenneth-rosario kenneth-rosario added P2 gcf bug A bug with the product: Cloud Functions labels Feb 13, 2024
@kenneth-rosario kenneth-rosario removed their assignment Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gcf bug A bug with the product: Cloud Functions P2
Projects
None yet
Development

No branches or pull requests

2 participants