Trying to find a Gradle plugin that pushes Docker images via the "new" publishing mechanism

We are using the Gradle Artifactory Plugin to publish artifacts into our Artifactory server (see also these instructions).

Now we have added tasks into our Gradle scripts to build Docker images and we want to push these images into our Artifactory (which we have configured as a Docker repository).

I’ve managed to do this using custom tasks but I would really like to plug this into our current workflow so that gradle artifactoryPublish does this at the same time that it uploads our other artifacts into the repository. The main benefit of doing this would be that the publishing mechanism makes sure that all modules build successfully before pushing and I would like to tap into that.

In other words, I’m looking for a Docker plugin that supports pushing to a Docker repository via the “new” publishing mechanism in Gradle.

Disclaimer: I asked this question already on stackoverflow.com if someone want’s good karma there you can answer the question there of course.

You should be able to use the task DockerPushImage of the Gradle Docker plugin to push your image to Docker. The publishing plugins won’t help here as they are not inter-operable with Docker.

Thanks. I’m actually in the process right now of trying out your plugin. My general lack of gradle awesomeness is holding be back a bit but I’m struggling though it.

I’m not quite sure I understand you comment about publishing plugins not being able to help? I thought that the publishing mechanism was an abstract concept and not really tied to any one method of publishing, instead there is a publishing plugin for maven/gradle and possibly other ones for other types of repositories (such as Docker). Is that not correct?

But I haven’t had any other responses to my question so I guess that at the very least, such a “docker publishing plugin” does not exist so I’ll just give up on that idea… no biggie.

But since I’ve made contact with you I might as well ask a more specific question about your plugin. I’m trying to build a docker container in our gradle build file. We’re using the distribution plugin and I would like to copy the contents of our distTar artifact into the container to a specific location. I can see that there is some discussion about this in your java-application plugin but I don’t think that’s going to work for us (it’s a bit too opinionated) so I’m just using the docker-remote-api plugin and trying to build the container by hand. Can you point me toward any example that actually takes the contents of distTar and expands that into the docker container being created with your plugin?

Currently, there’s only a publishing plugin for Ivy and Maven repositories though the protocol can be changed e.g. SFTP. Other types of repositories are not supported.

You could possibly reconfigure the defaults of the docker-java-application plugin. It depends on your needs. If that doesn’t work, you can build your on plugin on top of the docker-remote-api plugin. Could you please open a discussion on the plugin’s GitHub page.