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

In build.sh derive the organization name, image name, and version from the pom.xml #247

Open
243826 opened this issue Mar 8, 2019 · 9 comments

Comments

@243826
Copy link
Contributor

243826 commented Mar 8, 2019

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.

@stevehu
Copy link
Contributor

stevehu commented Mar 8, 2019

@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.

@243826
Copy link
Contributor Author

243826 commented Mar 8, 2019

@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.

@stevehu
Copy link
Contributor

stevehu commented Mar 8, 2019

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.

@DSchrupert
Copy link
Member

I'm using jib for this purpose for all my internal services and examples.. would recommend it

@stevehu
Copy link
Contributor

stevehu commented Mar 8, 2019

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?

@DSchrupert
Copy link
Member

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..

@243826
Copy link
Contributor Author

243826 commented Mar 8, 2019 via email

@243826
Copy link
Contributor Author

243826 commented Mar 8, 2019

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?

@DSchrupert
Copy link
Member

@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 😊

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

3 participants