Own build cache server/backend


(Stefan M.) #1

This topic is a follow up of this twitter conversation: https://twitter.com/StefMa91/status/925066928015794176?s=03

I was trying to build my own build cache server. Unfortunately there a no/limited documentation for

  • What gradle will send (e.g. Header, HTTP-Type, format of artifacts)
  • What gradle want to receive (e.g. Header, Type, Status-Code)

Which means I have really no idea (beside of “HTTP backend”) what I have to implement on the server side.

Thanks to this GitHub example I found a very basic implementation of a nginx-server.
Later on this example got new commits which says I should use the “official” gradle Docker image.
Unfortunately there is no single documentation how (or even if) to customize it. Something like

  • How to change the HTML output?
  • Can I change the storage location?
  • Can I add other auth options (beside of Basic Auth)?
    etc.

To sumarize:
My goal is to build a gradle build cache server from scratch. Which is totally under my control. To don’t break something in the future I would like to implement it according to some “specifications”/“apis” which can I trust. But such specs or apis aren’t available… So any implementation of a build cache server may (or may not) break in the future…


(Stefan Wolf) #2

Hi Stefan,

thanks for opening the forum discussion. As you see from the example you found, the current protocol is GET/PUT without any other logic. This may change in the future.
The official Gradle docker image supports basic auth and the documentation how to customize it can be found in the Gradle Enterprise documentation.
The storage location can be changed.
Adding other auth options apart from basic auth doesn’t make much sense since the Gradle client (i.e. the Gradle process running the build) only supports basic auth.
I do not understand what you mean by “change the HTML output”. Can you elaborate?
If you really want to build your own custom backend (which I do not recommend, since the provided one works pretty well), then you may also want to implement your own client as a Gradle plugin. This is described in the userguide.

Cheers,
Stefan


(Stefan M.) #3

Hi Stefan :upside_down_face:

thank you for the fast response.
I haven’t known the Enterprise documentation. Thanks for the link :+1:

I don’t want to only change the location of the artifacts inside a node/disk. I want to change the location like Google Cloud Storage or something…

Of course, I can :slight_smile:
I mean simply changing the “UI”. Currently the :whale: image used something like that:


But maybe I want to change the the text, the colors or even the whole site…
Do you know what I mean? :slight_smile:

Thanks and regards,

Stefan


(Yaroslav Stavnichiy) #4

I’ve written simple in-memory build cache server for Gradle using Undertow + Spring MVC + Spring Security + Caffeine Cache. You can find full source code here: https://github.com/yarosla/mem-build-cache

Hope it is easy to learn and customize to your needs.