My project has an application server and a C++ library. The library is not dependent on the application server. The vendor has a Docker image for the application server. I need to deploy a C++ library that needs to be accessible from each of the application server nodes/pods.
I've written a Dockerfile that builds on the vendors image, compiling and copying the libraries into place. It works, however, every time there's a new version of the application server I need to build my C++ library again from scratch. Given the lack of dependencies these doesn't seem optimal.
Naively, what I was expecting was to be able to build the C++ library into an "empty" image and mount that (like a filesystem) in each pod. That way the server and the library are maintained separately.
Is building on the vendor Dockerfile the "right" way to architect this? Or is there a solution more like my "idealised" vision?
I expect the answer is obvious and I just need the right terminology to search for... pointers very much appreciated.
Using Kubernetes you have at least two options to manage the library separately from container image:
Init container
to download it and put inside the application server's pod file system.As you said you can build the C++ library into an "empty" image. And for all the deployments you can use this as base image. This way you can avoid building library for every deployment.
Ex: Build image with C++ Library. Lets call this lib-img. When vendor is building image, vendor can use lib-img as base image, you can also add additional dependencies to lib-img which are needed by vendor.
You can also use init containers to pull the library on the pods.