Example Java Functions: Fn Gradle + FDK for Java
October 23, 2019 ยท View on GitHub
This example shows you how to build a Java function by using a Dockerfile.
Key points:
- Dockerfile - contains the containerized Docker build (based on dockerhub library/gradle images) and image build - this includes the gradle invocation
- The
cacheDepstask inbuild.gradlepulls down dependencies into the container gradle cache to speed up docker builds. - The
copyDepstask inbuild.gradlecopies the functions compile deps. - This uses JDK 11 by default
Step by step
Ensure you have the Fn server running to host your function:
(1) Start the server
$ fn start
(2) Create an app for the function
$ fn create app gradle-build-app
(3) Deploy the function to your app from the gradle-build directory.
fn deploy --app gradle-build-app --local
(4) Invoke the function
fn invoke gradle-build-app gradle_build