Skip to content

jeremyary/fis2-mvn-injected-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fis2-mvn-injected-openshift

OpenShift S2I image which eager-fetches Maven dependencies for one or more Red Hat Fuse Integration Services 2.0 Java/Groovy Maven projects and injects a pre-populated 'm2' artifact directory into downstream image containers to expedite builds.

Why

In developing Proof-of-Concept projects (and often throughout the development life cycle), code iteration is inevitable both during and well beyond the point of framework/dependency selection. When working with Maven projects in containerized solutions, the build process necessitates a fetching of project dependencies with each iterative build.

Often times, especially in latter stages of development, iterations are focused on implementation code as the dependency set is well established, thus leading to a lot of time spent in fetching redundant dependency sets. In other cases, such as with microservice architectures, multiple lightweight components often share a great deal of dependencies in common and could benefit from a shareable fetch mechanism that could alleviate the need for dependency resolution with each component build.

What

By using an intermediate image stream between the FIS 2.0 image stream and downstream images, it's possible to have the intermediate image assume the sole responsibility of fetching all needed dependencies for one or more projects and making them available to future builds.

In cases where dependencies are altered, rather than facing a lengthy build time for each potentially affected container, the intermediate image stream can be rebuilt, thereby refetching the shared dependency set one time. Following a successful fetch build, all affected downstream images will then automatically trigger a build that runs in a fraction of the usual time with the newly fetched dependency set already on hand.

In cases where dependencies are not altered but implementation code is changed, the existing dependency set offered by the intermediate image already satisfies the requirements of the new build, so the intermediate image build can be skipped, requiring only a build of downstream image which will, again, run in a fraction of the usual build time since all dependencies have already been made available.

Example build times with containers independently fetching dependencies: Independent Build Times

Example build times utilizing intermediate dependency injection approach: Injected Build Times

How

An example template is provided which accepts the following parameters:

parameters:
- name: IS_TAG
  value: latest
- name: REGISTRY
  value: 172.30.37.138
- name: IS_PULL_NAMESPACE
  value: openshift
- name: GIT_URL
  value: https://github.com/jeremyary/fis2-ecom-services.git

When using the template, The REGISTRY and IS_PULL_NAMESPACE should be overridden to match your OpenShift environment. The GIT_URL parameter should be overridden to point to a single-module or multi-module Maven project on GitHub. The project will be cloned during the intermediate stream build so that the parent directory and any possible submodule subdirectories containing a pom.xml file are identified, wherein the downstream Maven command will be emulated in order to capture all needed dependencies.

Single-module Project Example:

ProjectName
├──  src
│   └── main
│   └──── fabric8
│   └──── java
│   └──── resources
├── pom.xml

Multi-module Project Example:

ProjectName
├──  ModuleName
│   └── src
│   └──── ...
│   └── pom.xml
├──  ModuleName
│   └── src
│   └──── ...
│   └── pom.xml
├──  ModuleName
│   └── src
│   └──── ...
│   └── pom.xml
├── pom.xml

Template Usage for OpenShift 3.5+:

oc process -f https://raw.githubusercontent.com/jeremyary/fis2-mvn-injected-template/master/templates/fis2-mvn-injected-openshift.yaml \
    -p REGISTRY=<registry_ip> -p IS_PULL_NAMESPACE=<namespace> -p GIT_URL=<.git_project_url> | oc create -f -

Template Usage for OpenShift 3.4-:

oc process -f https://raw.githubusercontent.com/jeremyary/fis2-mvn-injected-template/master/templates/fis2-mvn-injected-openshift.yaml \
    -v REGISTRY=<registry_ip> -v IS_PULL_NAMESPACE=<namespace> -v GIT_URL=<.git_project_url> | oc create -f -

Once the ImageStream and BuildConfig is in place, FIS 2.0 project templates can now extend the custom injector image:

from:
  kind: ImageStreamTag
  name: injected-fis-openshift:latest
  namespace: <namespace_provided_earlier>

A full example template for a FIS 2.0 module extending the intermediate injector image can be found here.

Components

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • Red Fedora tip to welshstew for the inspiration

About

OpenShift S2I image for eager-fetching FIS 2.0 Maven project dependencies

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages