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

Dockerizing projects at scale with jib-maven-plugin #1616

Closed
lpandzic opened this issue Apr 10, 2019 · 4 comments
Closed

Dockerizing projects at scale with jib-maven-plugin #1616

lpandzic opened this issue Apr 10, 2019 · 4 comments

Comments

@lpandzic
Copy link

lpandzic commented Apr 10, 2019

I'd like to use jib-maven-plugin at a larger scale, namely several hundred projects without copying plugin configuration and/or resources.

We're currently using a from image which has a shell and an entrypoint to a startup script.
Parent maven project has the following configuration:

<plugin>
               <groupId>com.google.cloud.tools</groupId>
               <artifactId>jib-maven-plugin</artifactId>
               <version>${jib-maven-plugin.version}</version>
               <configuration>
                   <from>
                       <image>${docker.fromImage}</image>
                   </from>
                   <to>
                       <image>${docker.toImage}</image>
                   </to>
                   <container>
                       <entrypoint>/app/start.sh</entrypoint>
                   </container>
                   <extraDirectories>
                       <paths>${project.basedir}/docker</paths>
                       <permissions>
                           <permission>
                               <file>/app/start.sh</file>
                               <mode>755</mode>
                           </permission>
                       </permissions>
                   </extraDirectories>
                   <skip>${docker.skip}</skip>
               </configuration>
               <executions>
                   <execution>
                       <phase>package</phase>
                       <goals>
                           <goal>build</goal>
                       </goals>
                   </execution>
               </executions>
           </plugin>

My original idea was to have script.sh in an external dependency but due to nonclasspath external files limitation it has to be in every child project that's to be dockerized.

Ideally I'd like to have everything in one place (parent and optionally an additional dependency) and in child projects I'd put a single property to enable jib (disable default skip property of parent).

@chanseokoh
Copy link
Member

Hi @lpandzic,

Thanks for the feedback, but I actually didn't get what exactly you are asking for. It seems like you already configured Jib in the parent POM and child modules are selectively enabling/disabling Jib with <skip>? Can you explain the details?

@lpandzic
Copy link
Author

Hello @chanseokoh, that's the gist of it.
So for cases where I don't need a new entrypoint with script the mentioned use case is already working and supported:
Jib maven plugin configuration is in parent, there's a skip property that's set to true by default and for child projects where you want to enable the default build you just override this property on pom level. As long as you have everything you need in pom, you're good to go.
The value behind all of this is that you have a great out of the box experience for new projects where you have to only override one property to dockerize your whole project and you also have the flexibility to override the jib configuration if you want to.

The problem arises when you need a resource like a startup script that you want to set for entrypoint. In that case you're basically forced to copy this script around on all projects.
My idea was to create a new project that contains the default script and is declared as a dependency in parent. Problem with that approach is that there's no support for resources on classpath.

@chanseokoh
Copy link
Member

chanseokoh commented Apr 11, 2019

The problem arises when you need a resource like a startup script that you want to set for entrypoint. In that case you're basically forced to copy this script around on all projects.

I haven't tested myself, but can't you do something like https://stackoverflow.com/a/1019431/1701388 and have

  <extraDirectories>
    <paths>${main.basedir}/docker</paths>

so that ${main.basedir}/docker always points to docker in the project directory? The Stack Overflow question has other alternatives too.

@chanseokoh
Copy link
Member

Closing due to inactivity. Hopefully the issue is already resolved with the above suggestion.

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