Open 243826 opened 5 years ago
@243826 I assume you mean the generated build.sh which is the script to build and publish Docker images. How to get the info from the pom.xml? By parsing the pom.xml in the shell script? Thanks.
@stevehu This is what I think:
dockerize --publish --org org_name --name image_name --version version
--file docker_file
And invoke this command from within pom in response to deploy phase and docker profile.
dockerize
is the new name for build.sh
and of course can also be executed
manually from outside of maven.
So no parsing of pom.xml
involved. If you think this adds value, I should
be able to code it up.
Yes. That should work great. I also looked at https://fabric8.io/guide/mavenDockerPush.html before but didn't find any time to get it implemented in the pom.xml file. There is another maven plugin designed for the same purpose.
I'm using jib for this purpose for all my internal services and examples.. would recommend it
jib looks good and we really need a tool that can support both Maven and Gradle. I am thinking to update the light-codegen to let users select Maven or Gradle(with Kotlin DSL) for their build. @NicholasAzar, Do you have any example to share?
Yeah I've been using something similar to this:
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>1.0.1</version>
<configuration>
<from>
<image>openjdk:8-jre-alpine</image>
</from>
<to>
<image>registry.hub.docker.com/org/image</image>
<credHelper>osxkeychain</credHelper>
<tags>
<tag>${project.version}</tag>
<tag>latest</tag>
</tags>
</to>
<container>
<jvmFlags>
<jvmFlag>-XX:+UnlockExperimentalVMOptions</jvmFlag>
<jvmFlag>-XX:+UseCGroupMemoryLimitForHeap</jvmFlag>
<jvmFlag>-XX:MaxRAMFraction=1</jvmFlag>
<jvmFlag>-Dlight-4j-config-dir=/config</jvmFlag>
<jvmFlag>-Dlogback.configurationFile=/config/logback.xml</jvmFlag>
</jvmFlags>
</container>
</configuration>
</plugin>
Then there's no need to have a docker file or to even have docker installed..
I wrote the other script yesterday. But if this is good, we should go this route and I feel that this is better especially since you do not need docker installed and I wanted an easy flag to trigger building the docker container.
I reviewed it and seems to work very well. @NicholasAzar do you want to create a PR or do you want me to create one?
@243826 yeah please feel free to work on this! There's a few items that might need to be thought through, like the default credHelper, image location, and how this would look in your pom.xml (in my case I have 2 copies of that plugin in different 2 profiles with different "to" image repositories so I can decide where I'm pushing the image). Just food for thought 😊
All the information is needed is readily available in the pom file. By using these values, we can avoid the configuration when not needed. But users invoking build.sh can still override that from command line.