Giter VIP home page Giter VIP logo

libfnbuildpack's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar ericbottard avatar github-actions[bot] avatar nebhale avatar scothis avatar trisberg avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libfnbuildpack's Issues

Failure running node function after 2nd build using same image name

running locally with Docker for Desktop MacOS Version 2.0.0.0-mac78 (28905)
riff cli: 0.2.0-snapshot (231959f7200148e9800e16c29cdfc6dc4a9537e0)

code

module.exports = x => `${x} squared = ${x ** 2}`;

build and invoke

riff function create square --local-path . --artifact square.js --image dev.local/square-me:v1
$ riff service invoke square --text -- -w '\n' -d 7
7 squared = 49

delete service

riff service delete square

Now redo the function create - the create command succeeds, but the deployment crashes

$ kubectl logs square-00001-deployment-7cf66fc797-kbndb -c user-container
internal/modules/cjs/loader.js:582
    throw err;
    ^

Error: Cannot find module '/workspace/io.projectriff.riff/riff-invoker-node/server.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

Log from 2nd function create

2018/11/20 14:20:34 Pulling builder image 'projectriff/builder' (use --no-pull flag to skip this step)
2018/11/20 14:20:35 Using user provided run image 'packs/run'
2018/11/20 14:20:35 Pulling run image 'packs/run' (use --no-pull flag to skip this step)
*** DETECTING:
2018/11/20 14:20:39 Detected language: "node".
2018/11/20 14:20:39 Group: Cloud Foundry OpenJDK Buildpack: pass | Node.js Buildpack: pass | Cloud Foundry Build System Buildpack: fail | NPM Buildpack: fail | riff Buildpack: pass
*** ANALYZING: Reading information from previous image for possible re-use
*** BUILDING:
-----> Cloud Foundry OpenJDK Buildpack 1.0.0-BUILD-SNAPSHOT

-----> NodeJS 10.12.0: Reusing cached dependency
-----> NodeJS 10.12.0: Reusing cached launch layer

-----> riff Buildpack 1.0.0-BUILD-SNAPSHOT
-----> riff Node Invoker 0.1.0+snapshot: Reusing cached launch layer
       Writing .profile.d/function-uri
-----> Process types:
       web:      node /workspace/io.projectriff.riff/riff-invoker-node/server.js
       function: node /workspace/io.projectriff.riff/riff-invoker-node/server.js

*** EXPORTING:
Step 1/6 : FROM dev.local/square-me:v1 AS prev
---> 963ddc3c7e3f
---> 963ddc3c7e3f
Step 2/6 : FROM packs/run
---> 262a6e446f6c
Step 3/6 : ADD --chown=pack:pack /workspace/app /workspace/app
---> Using cache
---> 74294ef9c186
Step 4/6 : ADD --chown=pack:pack /workspace/config /workspace/config
---> Using cache
---> eeb1bc04970a
Step 5/6 : COPY --from=prev --chown=pack:pack /workspace/org.cloudfoundry.buildpacks.nodejs/node /workspace/org.cloudfoundry.buildpacks.nodejs/node
---> Using cache
---> 53b78a1e711d
Step 6/6 : ADD --chown=pack:pack /workspace/io.projectriff.riff/riff-invoker-node /workspace/io.projectriff.riff/riff-invoker-node
---> Using cache
---> 09307e96cab6
---> 09307e96cab6
Successfully built 09307e96cab6
Successfully tagged dev.local/square-me:v1
Step 1/2 : FROM dev.local/square-me:v1
---> 09307e96cab6
Step 2/2 : LABEL io.buildpacks.lifecycle.metadata='{"app":{"name":"","sha":"sha256:28ee6f19f7db693daa0250760d84261352eff11a7201eb15f70fe720271608e1"},"config":{"sha":"sha256:54d7fe51e5fc17b0467103f8b67af676084af94bf915f93e6034b2e0085ad78d"},"buildpacks":[{"key":"org.cloudfoundry.openjdk","name":""},{"key":"org.cloudfoundry.buildpacks.nodejs","name":"","layers":{"node":{"sha":"sha256:96b3a8dc5ed68877415c3e0dfd6d0e6421de8672042d7ab8535aec5a989bf5fd","data":{"id":"node","name":"NodeJS","sha256":"028deca9b6d55b85753ef13c052a4e9dd718cd8ad3e1ca815138ce16001bcb10","stacks":["org.cloudfoundry.stacks.cflinuxfs3","io.buildpacks.stacks.bionic"],"uri":"https://buildpacks.cloudfoundry.org/dependencies/node/node-10.12.0-linux-x64-cflinuxfs3-028deca9.tgz","version":"10.12.0"}}}},{"key":"io.projectriff.riff","name":"","layers":{"riff-invoker-node":{"sha":"sha256:bf74e9e17a7a8228b2915c7815d772a1c6d92cd79d1b47d0399ff73d6294a7c8","data":{"id":"riff-invoker-node","licenses":[{"type":"Apache-2.0","uri":"https://github.com/projectriff/node-function-invoker/blob/master/LICENSE"}],"name":"riff Node Invoker","sha256":"d0dbef29bd0ddb9c88cf85dd51333226b3dd3393c0ab9d8a836b671499b70dee","stacks":["io.buildpacks.stacks.bionic"],"uri":"https://storage.googleapis.com/projectriff/node-function-invoker/releases/v0.1.0-snapshot/snapshots/node-function-invoker-0.1.0-snapshot-49db1d7a8b32a61bea0d152cbb817a4e0ca171a3.tgz","version":"0.1.0+snapshot"}}}}],"runimage":{"name":"packs/run","sha":"sha256:c83b22d74d49e58c7432e4752fc22c1142572cbc5a8c8187ca5036ecf19acbf3"}}'
---> Running in 5706c111dbdb
---> 9842119d60dc
---> 9842119d60dc
Successfully built 9842119d60dc
Successfully tagged dev.local/square-me:v1

riff function create completed successfully

Log from first function create

$ riff function create square   --local-path .   --artifact square.js   --image dev.local/square-me:v1
2018/11/20 14:18:41 Pulling builder image 'projectriff/builder' (use --no-pull flag to skip this step)
2018/11/20 14:18:42 Using user provided run image 'packs/run'
2018/11/20 14:18:42 Pulling run image 'packs/run' (use --no-pull flag to skip this step)
*** DETECTING:
2018/11/20 14:18:46 Detected language: "node".
2018/11/20 14:18:46 Group: Cloud Foundry OpenJDK Buildpack: pass | Node.js Buildpack: pass | Cloud Foundry Build System Buildpack: fail | NPM Buildpack: fail | riff Buildpack: pass
*** ANALYZING: Reading information from previous image for possible re-use
2018/11/20 14:18:47 WARNING: skipping analyze, image not found
*** BUILDING:
-----> Cloud Foundry OpenJDK Buildpack 1.0.0-BUILD-SNAPSHOT

-----> NodeJS 10.12.0: Reusing cached dependency
-----> NodeJS 10.12.0: Contributing to launch
       Reusing cached download
       Expanding to /workspace/org.cloudfoundry.buildpacks.nodejs/node
       Writing profile.d/NODE_HOME
       Writing profile.d/NODE_ENV
       Writing profile.d/NODE_MODULES_CACHE
       Writing profile.d/NODE_VERBOSE
       Writing profile.d/NPM_CONFIG_PRODUCTION
       Writing profile.d/NPM_CONFIG_LOGLEVEL
       Writing profile.d/WEB_MEMORY
       Writing profile.d/WEB_CONCURRENCY

-----> riff Buildpack 1.0.0-BUILD-SNAPSHOT
-----> riff Node Invoker 0.1.0+snapshot: Contributing to launch
       Reusing cached download from buildpack
       Expanding to /workspace/io.projectriff.riff/riff-invoker-node
       npm-installing the node invoker
added 76 packages from 60 contributors and audited 524 packages in 4.265s
found 0 vulnerabilities

       Writing .profile.d/host
       Writing .profile.d/http-port
       Writing .profile.d/function-uri
-----> Process types:
       web:      node /workspace/io.projectriff.riff/riff-invoker-node/server.js
       function: node /workspace/io.projectriff.riff/riff-invoker-node/server.js

*** EXPORTING:
Step 1/5 : FROM packs/run
---> 262a6e446f6c
Step 2/5 : ADD --chown=pack:pack /workspace/app /workspace/app
---> Using cache
---> 74294ef9c186
Step 3/5 : ADD --chown=pack:pack /workspace/config /workspace/config
---> Using cache
---> eeb1bc04970a
Step 4/5 : ADD --chown=pack:pack /workspace/org.cloudfoundry.buildpacks.nodejs/node /workspace/org.cloudfoundry.buildpacks.nodejs/node
---> Using cache
---> 91491a1d907a
Step 5/5 : ADD --chown=pack:pack /workspace/io.projectriff.riff/riff-invoker-node /workspace/io.projectriff.riff/riff-invoker-node
---> Using cache
---> 11b1768e7270
---> 11b1768e7270
Successfully built 11b1768e7270
Successfully tagged dev.local/square-me:v1
Step 1/2 : FROM dev.local/square-me:v1
---> 11b1768e7270
Step 2/2 : LABEL io.buildpacks.lifecycle.metadata='{"app":{"name":"","sha":"sha256:28ee6f19f7db693daa0250760d84261352eff11a7201eb15f70fe720271608e1"},"config":{"sha":"sha256:54d7fe51e5fc17b0467103f8b67af676084af94bf915f93e6034b2e0085ad78d"},"buildpacks":[{"key":"org.cloudfoundry.openjdk","name":""},{"key":"org.cloudfoundry.buildpacks.nodejs","name":"","layers":{"node":{"sha":"sha256:fcbe93ba097e79090e473e3ef4ae1eeb1fcbf4479b71869a90e1b664ffdcba96","data":{"id":"node","name":"NodeJS","sha256":"028deca9b6d55b85753ef13c052a4e9dd718cd8ad3e1ca815138ce16001bcb10","stacks":["org.cloudfoundry.stacks.cflinuxfs3","io.buildpacks.stacks.bionic"],"uri":"https://buildpacks.cloudfoundry.org/dependencies/node/node-10.12.0-linux-x64-cflinuxfs3-028deca9.tgz","version":"10.12.0"}}}},{"key":"io.projectriff.riff","name":"","layers":{"riff-invoker-node":{"sha":"sha256:387804dd51d75fb7683de757d87fdaad7c32471ae372661bd272a9d574556953","data":{"id":"riff-invoker-node","licenses":[{"type":"Apache-2.0","uri":"https://github.com/projectriff/node-function-invoker/blob/master/LICENSE"}],"name":"riff Node Invoker","sha256":"d0dbef29bd0ddb9c88cf85dd51333226b3dd3393c0ab9d8a836b671499b70dee","stacks":["io.buildpacks.stacks.bionic"],"uri":"https://storage.googleapis.com/projectriff/node-function-invoker/releases/v0.1.0-snapshot/snapshots/node-function-invoker-0.1.0-snapshot-49db1d7a8b32a61bea0d152cbb817a4e0ca171a3.tgz","version":"0.1.0+snapshot"}}}}],"runimage":{"name":"packs/run","sha":"sha256:c83b22d74d49e58c7432e4752fc22c1142572cbc5a8c8187ca5036ecf19acbf3"}}'
---> Using cache
---> 963ddc3c7e3f
---> 963ddc3c7e3f
Successfully built 963ddc3c7e3f
Successfully tagged dev.local/square-me:v1

riff function create completed successfully
Issue `riff service status square` to see the status of the function

improve readme

describe

  • how this component fits into riff
  • what developers need to know/do to use it (contents/format of riff.toml)
  • what it does during a build
  • how it depends on / interacts with other buildpacks

Don't pass empty handler to Java function

The buildpack should not set the handler argument if handler is empty. This causes an NPE:

Caused by: java.lang.NullPointerException
	at org.springframework.cloud.function.deployer.FunctionCreatorConfiguration$BeanCreator.getFunctionNames(FunctionCreatorConfiguration.java:392)
	at org.springframework.cloud.function.deployer.FunctionCreatorConfiguration.functionNames(FunctionCreatorConfiguration.java:138)
	at org.springframework.cloud.function.deployer.FunctionCreatorConfiguration.init(FunctionCreatorConfiguration.java:119)
	... 24 more

Instead of passing in --function.uri='file:///workspace/app?handler=' it would be better to pass in --function.uri='file:///workspace/app'

Debug logs to Info

Currently, the buildpack logs to info as part of detection. Idiomatically, detect should be quiet be default and can have logging enabled with $BP_DEBUG.

Buildpack export step fails to read existing images

Error:

default/uppercase-00001-mzj67[build-step-export]: 2018/09/21 03:38:37 Error: failed to : find metadata: unexpected end of JSON input

Workaround is to remove the existing images for that repository:tag and build again.

I can reproduce this by running:

export GCP_PROJECT=$(gcloud config get-value core/project)
riff function create jar uppercase \
  --git-repo https://github.com/trisberg/uppercase.git \
  --git-revision jar \
  --artifact uppercase-0.0.1-SNAPSHOT.jar \
  --handler uppercase \
  --image gcr.io/$GCP_PROJECT/uppercase-function \
  --verbose

followed by:

riff service delete uppercase
riff function create java uppercase \
  --git-repo https://github.com/trisberg/uppercase.git \
  --image gcr.io/$GCP_PROJECT/uppercase-function \
  --verbose

Support "simple" artifact based node functions

d091974 transformed the "node" support to "npm" support, but both should be supported.

Or, considering this from another angle: npm should be supported as a way to "install" the function, if package.json is present. And we should always honor the artifact (even if empty, which then delegates to the main entry of package.json)

Add support for `command` invoker

As an exercise in understanding the overall architecture and collaboration mechanism with other buildpacks, and as a blueprint for later expansion to other languages (eg node, etc), add support for a second, non-java, language.

A good first candidate that doesn't require too much contribution from "complicated" buildpacks is the command language

Explode invoker jar

Spring Boot apps (all JVM apps actually) start faster from an exploded jar. The invoker jar should be exploded in the final function container for decreased latency.

Use FUNCTION_URI env var for Java applications

In the spirit of symmetry, the Java riff Invoker should use the same technique to set the function URI invoker. It should use the FUNCTION_URI environment variable rather than an argument on the command line.

Should respect the `--no-color` option when run via pack

Using --no-color flag or setting color.NoColor = true before running the build should suppress the colors from the log output. At the moment the riff builder part still omits colored log output while the rest of the output show no colors.

Use an extra layer instead of inline ENV VAR

a938104 was a rightful fix to avoid a problem with layer caching. Yet, it re-introduces setting the environment variable directly in the command definition, which can make debugging painful when attaching to a new container (which would then not have the full environment)

The correct solution is to create a dedicated layer for things that can change per-function (currently just the FUNCTION_URI variable)

Unable to build Java functions

The build-step-export step fails with:

2018/10/24 19:30:12 Error: failed to parse arguments map[narg:0x4d91d0 runImage: launchDir:/workspace]

Unable to build the project

Using go 1.11.4 and getting the following error running make:

./bin/package scratch 				&& \
mkdir scratch/io/projectriff/riff/io.projectriff.riff/latest 					&& \
tar -C scratch/io/projectriff/riff/io.projectriff.riff/latest -xzf scratch/io/projectriff/riff/io.projectriff.riff/*/*.tgz
-----> Packaging riff Buildpack 0.2.0-BUILD-SNAPSHOT
-----> Pre-Package with ci/build.sh
go build golang_org/x/crypto/cryptobyte/asn1: open /snap/go/3095/pkg/linux_amd64/vendor/golang_org/x/crypto/cryptobyte/asn1.a: read-only file system
go build golang_org/x/crypto/curve25519: open /snap/go/3095/pkg/linux_amd64/vendor/golang_org/x/crypto/curve25519.a: read-only file system
go build golang_org/x/net/dns/dnsmessage: open /snap/go/3095/pkg/linux_amd64/vendor/golang_org/x/net/dns/dnsmessage.a: read-only file system
go build runtime/cgo: open /snap/go/3095/pkg/linux_amd64/runtime/cgo.a: read-only file system
go build golang_org/x/crypto/internal/chacha20: open /snap/go/3095/pkg/linux_amd64/vendor/golang_org/x/crypto/internal/chacha20.a: read-only file system
go build golang_org/x/crypto/poly1305: open /snap/go/3095/pkg/linux_amd64/vendor/golang_org/x/crypto/poly1305.a: read-only file system
go build golang_org/x/text/transform: open /snap/go/3095/pkg/linux_amd64/vendor/golang_org/x/text/transform.a: read-only file system
go build golang_org/x/net/http2/hpack: open /snap/go/3095/pkg/linux_amd64/vendor/golang_org/x/net/http2/hpack.a: read-only file system
go build golang_org/x/text/unicode/bidi: open /snap/go/3095/pkg/linux_amd64/vendor/golang_org/x/text/unicode/bidi.a: read-only file system
exit status 1
Makefile:12: recipe for target 'scratch/io/projectriff/riff/io.projectriff.riff' failed
make: *** [scratch/io/projectriff/riff/io.projectriff.riff] Error 102

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.