Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Respecting the codebase factor (from 12-factor app manifesto) for a Gradle/Spring app deployed on Cloudfoundry or Heroku

My question relates to the first factor of 12 factor apps manifesto: the codebase. (see http://12factor.net/codebase).

TL;DR:

this factor states there's a one to one relationship between codebases and deploys, so in this case, you're not supposed to use the same codebase (repository) for both applications

My requirement: I have an website Spring application and a batch Spring application both sharing a common code i.e. the domain model (JPA entity classes). I need to be able to share this common code. And both applications need to use the same version of the common code at any one time.

My current setup: I have currently three "top-level" repositories on github:

  • Domain model (JPA entity classes) repo
  • Website application repo
    • Domain model directory/gradle project (included with git subtree pull/push)
  • Batch application repo
    • Domain model directory/gradle project (included with git subtree pull/push)

Please also note that the Domain model repo lives separately (as noted above) but is also nested within both the website and the batch application repos. I use a git subtree pull/push in order to include this Domain model repo as a directory and a gradle project within the other two repos. The reason for this is that Heroku builds the code itself from the repos.

All this is very tedious and error-prone.

Can someone please advise a better solution?

like image 958
balteo Avatar asked Dec 08 '15 13:12

balteo


1 Answers

I would publish the common code to a private Maven repo on Bintray and then add that private repo to the other consumer apps and specify the common module as a dependency. This doesn't guarantee that both will depend on the same version but that could be easily managed through external processes using tools like the Maven Versions Plugin. But you also might want to add a more flexible serialization system to loosely couple the domain models of the two apps.

like image 139
James Ward Avatar answered Sep 30 '22 17:09

James Ward