Reducing OpenFaaS Clojure Template Build Times
Posted on February 9, 2019
Last updated on May 3, 2021
This article is now obsolete. The features described in this article were added to the OpenFaaS Clojure Template on May 2, 2021.
One of my concerns about the OpenFaaS Clojure Template has been that it takes a very long time to build and package a function. This is largely due to the fact that none of the Clojure project dependencies are cached between builds. The template downloads a fresh copy of each dependency for every build.
I created a Docker image called the OpenFaaS Clojure Builder (GitHub, Docker Hub) to address this concern. The image contains the Clojure CLI tools and a Maven cache preloaded with all of the dependencies required by the OpenFaaS Clojure Template as well as some popular libraries including compojure, clj-http, and cheshire. Since the image contains a preloaded Maven cache the template does not have to download those dependencies on every build, resulting in significantly reduced build times.
The OpenFaaS Clojure Builder is now the starting image for the OpenFaaS Clojure Template build step.
If you are already using the OpenFaaS Clojure template, you can update to the latest version with the following command:
faas template pull --overwrite https://github.com/tessellator/openfaas-clojure-template
If you have other common dependencies you would like to see added to the image please let me know, and PRs are welcome.