{"id":15684077,"url":"https://github.com/pmlopes/openfaas-quarkus-native-template","last_synced_at":"2025-05-07T15:10:20.782Z","repository":{"id":48374327,"uuid":"177986297","full_name":"pmlopes/openfaas-quarkus-native-template","owner":"pmlopes","description":"An OpenFAAS template for Quarkus.io serverless native functions","archived":false,"fork":false,"pushed_at":"2021-07-29T09:28:12.000Z","size":135,"stargazers_count":10,"open_issues_count":5,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-31T11:21:10.575Z","etag":null,"topics":["graalvm","native-image","openfaas","quarkus","serverless"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pmlopes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-27T12:07:27.000Z","updated_at":"2022-09-19T23:13:09.000Z","dependencies_parsed_at":"2022-09-19T03:33:00.232Z","dependency_job_id":null,"html_url":"https://github.com/pmlopes/openfaas-quarkus-native-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmlopes%2Fopenfaas-quarkus-native-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmlopes%2Fopenfaas-quarkus-native-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmlopes%2Fopenfaas-quarkus-native-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmlopes%2Fopenfaas-quarkus-native-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pmlopes","download_url":"https://codeload.github.com/pmlopes/openfaas-quarkus-native-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252902614,"owners_count":21822261,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graalvm","native-image","openfaas","quarkus","serverless"],"created_at":"2024-10-03T17:10:47.938Z","updated_at":"2025-05-07T15:10:20.758Z","avatar_url":"https://github.com/pmlopes.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Template: openfaas-quarkus-native-template\n\nThe [Quarkus](https://quarkus.io) template uses maven as a build system.\n\nThe template makes use of the OpenFAAS incubator project [of-watchdog](https://github.com/openfaas-incubator/of-watchdog).\n\nQuarkus is a Kubernetes Native Java stack tailored for GraalVM \u0026 OpenJDK HotSpot, crafted from the best of breed Java libraries and standards. The very nature of the project makes it a perfect fit for serverless too. This template is a barebores quarkus template you would generate from:\n\n```bash\nmvn io.quarkus:quarkus-maven-plugin:0.12.0:create \\\n    -DprojectGroupId=org.acme \\\n    -DprojectArtifactId=function \\\n    -DclassName=\"org.acme.quickstart.GreetingResource\" \\\n    -Dpath=\"/\"\n```\n\nPackaged as a template to quickly be deployed on OpenFAAS. This means that all the official features and extensions can be used out of the box in your functions too.\n\n### Structure\n\nThis a template showcasing the use of Native Quarkus as a viable runtime for Serverless functions.\n\nFunctions are pure `JAX-RS` routes: \n\n```java\n@Path(\"/function\")\npublic class GreetingResource {\n\n    @GET\n    @Produces(MediaType.TEXT_PLAIN)\n    public String hello() {\n        return \"hello OpenFaaS\";\n    }\n}\n```\n\nThis template is not different than a regular Qaurkus application, all features you could use with Quarkus can be used here too.\n\nTo get started with Qaurkus, please read the official [Getting Started Guide](https://quarkus.io/get-started/).\n\n### Using extensions\n\nQuarkus has several [extensions](https://quarkus.io/extensions/) available. They can be used with this template using the standard mechanisms:\n\n```bash\n# See the available extensions\n$ mvn quarkus:list-extensions\n# Add a specific extension\n$ mvn quarkus:add-extension -Dextensions=\"groupId:artifactId\"\n```\n\nTo conclude, using Quarkus for serverless is exactly the same as using quarkus for regular applications. \n\n\n### Trying the template\n\n```\n$ faas template pull https://github.com/pmlopes/openfaas-quarkus-native-template\n$ faas new --lang quarkus-native \u003cfn-name\u003e\n```\n\n### Building\n\nWhen working in development mode, the java application is build as usual:\n\n```\nmvn clean package quarkus:dev\n```\n\nWhen going to OpenFAAS, the build is run inside a Docker container using the provided `Dockerfile`.\n\nThe Dockerfile performs the following actions:\n\n1. Builds the Java code\n2. Generates a native image from the fat jar\n3. Creates a new image and install OpenFAAS of-watchdog\n4. Copies the native image to the new container\n5. Configures the watchdog\n\nYou can also run the Dockerfile locally:\n\n```\ndocker build -t my-quarkus-fn .\ndocker run --rm -p 8080:8080 my-quarkus-fn\n```\n\nYou can observe instant startup times and low memory usage:\n\n```\nForking - function []\n2019/03/27 12:01:45 Started logging stderr from function.\n2019/03/27 12:01:45 Started logging stdout from function.\n2019/03/27 12:01:45 OperationalMode: http\n2019/03/27 12:01:45 Writing lock-file to: /tmp/.lock\n2019/03/27 12:01:45 stdout: 2019-03-27 12:01:45,759 INFO  [io.quarkus] (main) Quarkus 0.12.0 started in 0.003s. Listening on: http://0.0.0.0:8000\n\n2019/03/27 12:01:45 stdout: 2019-03-27 12:01:45,759 INFO  [io.quarkus] (main) Installed features: [cdi, resteasy]\n```\n\n```\ndocker stats\nCONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS\n90b8a84d23a9        suspicious_ganguly   0.00%               5.594MiB / 15.54GiB   0.04%               0B / 0B             0B / 0B             20\n```\n\nRemember that the memory usage in this case accounts for both the vert.x application and the watchdog!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmlopes%2Fopenfaas-quarkus-native-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpmlopes%2Fopenfaas-quarkus-native-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmlopes%2Fopenfaas-quarkus-native-template/lists"}