cloudfoundry / java-buildpack

Cloud Foundry buildpack for running Java applications
Apache License 2.0
437 stars 2.58k forks source link

Access to network filesystem during application staging #1049

Closed debargharoy closed 9 months ago

debargharoy commented 9 months ago

I am customizing the buildpack to add our custom agent. The agent utilizes configuration files that it expects to be on the filesystem.

The configuration can be specific to individual teams and thus will be dynamic. To tackle this issue, I was thinking if it's possible to host the configuration files on a network filesystem (that's configured as a NFS v3/v4 service in TAS). If possible, how do we go about mounting the filesystem to access the same?

dmikusa commented 9 months ago

You would get access to a network-mounted file system in CloudFoundry via a bound volume service. I do not believe that will be mounted at build time. My understanding is that it only happens at run time. To be clear, the binding itself will exist and the buildpack can see that a volume service is bound, we use this information to make decisions, but I do not believe that the actual file system will be mounted during the build.

The agent utilizes configuration files that it expects to be on the filesystem.

There are two ways that we handle this with other agents and servers.

  1. Auto-generate the configuration. As the buildpack runs, it is possible for it to generate configuration files, either from scratch or from templates.
  2. If you can't generate them, then you can put resources into the buildpack. Those resources can then be overlayed with external configuration, see Tomcat as an example.

There are pros and cons to both approaches. I think 1.) is more flexible. The configuration can be easily adapted to configuration settings and dynamically generated. The second approach is better for static configuration, things that don't change often, because it's more difficult for end users to override that configuration.

Hope that helps!

debargharoy commented 9 months ago

Thanks for the confirmation @dmikusa. Our use-case is, the configuration may change frequently in the development phase and stabilize for production.

I am working towards a variation of approach (1) you described where we get the specific configuration from a user-defined TAS service and generate the config files while app staging.