nitrictech / legacy-cli

CLI for the Nitric Framework
Apache License 2.0
6 stars 3 forks source link

Add Project Components / Modules scaffolding support #133

Open medgar-nitric opened 3 years ago

medgar-nitric commented 3 years ago

With FaaS architecture there is often common code shared between functions such as models or utility functions.

Many languages provide support for components or modular builds.

In the Java ecosystem Maven provides a modules concept enabling a project to be composed on multiple modules. An simple example could be a common model class needs to be used by multiple functions. This model would be contained in a common module, while the functions are contained in separate modules.

+customer-project\
|  
+- common\
|  +- src\
|  +- pom.xml
| 
+- func-customer-update\
|   +- src\
|   +- pom.xml
| 
+- func-customer-list\
|   +- src\
|   +- pom.xml
| 
+- nitric.yaml
+- pom.xml

Scaffolding up the modular project structure would provide a useful starting point for developers building FaaS solutions for the first time.

Example Java Microservices Maven Modules https://2much2learn.com/mavengradle-based-multi-module-spring-boot-microservices/

┆Issue is synchronized with this Jira Story by Unito

tjholm commented 3 years ago

This is an interesting one, there are two concepts we need to deal with here when building images:

Handling these mechanisms without some concept of extensibility is a bit of a challenge, as becoming target aware in the scope of a broader build context usually requires some knowledge/intervention (i.e. running specific scripts and copying specific files).

There are a few options available to us to support this, but essentially we would need users to provide us a way of setting both context and target in their service configurations and we can then inject this config into our builds, being able to support this for our existing templates would be preferable.

Could also look at adopting alternatives for image building/layering that could offer more flexibility and composability: e.g. https://buildpacks.io/