Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build image(s) conditionally #1313

Closed
alessiostalla opened this issue Jan 3, 2020 · 4 comments
Closed

Build image(s) conditionally #1313

alessiostalla opened this issue Jan 3, 2020 · 4 comments

Comments

@alessiostalla
Copy link

Description

We would like to have the ability to specify which image(s) to build, or not, using Maven profiles.
Since the configuration is a monolithic XML block or file, it's impossible to build a certain image only if a certain precondition is met (e.g. build the frontend HTTP server only if I'm building the frontend).

Duplicating and splitting the d-m-p configuration over multiple profiles is, of course, possible but suboptimal.

Info

  • d-m-p version : 0.31.1
  • Maven version (mvn -v) : 3.5.2
  • Docker version : 18.09.7
  • If it's a bug, how to reproduce :
  • If it's a feature request, what is your use case :

We have profiles that control whether to build (or not) the frontend and/or that customize the build for specific customers. However, we cannot easily combine those with d-m-p.

@rhuss
Copy link
Collaborator

rhuss commented Jan 8, 2020

I'm afraid I don't have a good answer. Maven profiles' plugin configuration can not easily be combined when multiple profiles are activated. So if you split the image configuration over multiple profiles then you would have to call Maven for each profile separately.

The only way I know how to combine plugin configurations is via inheritance like e.g. described in https://blog.sonatype.com/2011/01/maven-how-to-merging-plugin-configuration-in-complex-projects/

Even here the complex configuration of dmp might not be a good fit here. You can also try to use the other configuration options, like plain Dockerfiles or the property based configuration as described in the documentation.

@alessiostalla
Copy link
Author

Thanks @rhuss . I was thinking that adding a flag to <image>, say, <skip>true|false</skip>, would be enough. d-m-p configuration would still be monolithic, but we could then turn on and off parts of it according to properties set by other profiles. What do you think?

@rhuss
Copy link
Collaborator

rhuss commented Jan 9, 2020

We already have several skip options on various levels, so they might be already achieve what you need ? See https://dmp.fabric8.io/ and look for skip (e.g. in https://dmp.fabric8.io/#build-configuration which is part of )

But probably the new alternative configuration syntax might be useful to you, which allows easy merging of image configuration. This has just been released as part of 0.32.0. See the documentation https://dmp.fabric8.io/#image-configuration, check for imagesMap. Also, the discussion in the PR introducing this feature might be useful to you: #1259

@alessiostalla
Copy link
Author

Oh, great! That's exactly what I needed! Sorry, I had totally not seen that, or maybe it wasn't there when I looked (0.32.0 was not out yet).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants