Transmode / gradle-docker

A Gradle plugin to build Docker images from the build script.
Apache License 2.0
647 stars 142 forks source link

migrate to java client 2.1.1 and add Save task #63

Closed baptistemesta closed 8 years ago

baptistemesta commented 9 years ago

Needed save command to be available in my build so i updated to docker-java 2.1.1 and added the new save command

baptistemesta commented 9 years ago

I can split the migation to 2.1.1 and the addition of the save command, btw should docker task be splitted in order to split build/push/save/whatever?

stefanleh commented 8 years ago

no merge since begin of october. is this project dead? i need a newer java client version too for my project.

baptistemesta commented 8 years ago

in order to be able to save images to filesystem (not a commom usecase) I created and published my own gradle plugin with up to date java client here https://github.com/baptistemesta/docker-build if you only need build/push (not the integration to distribution plugin) I can add it there and publish it quickly

bjornmagnusson commented 8 years ago

We need a way to continue support older versions of Docker, and not only the latest one. So, in order to merge a newer java-client please add some backward compability to support this. Also, I believe migration to java client 2.1 (with older Dokcer version support) should be a separate pull request.

Suggestion: try to perform your pull request upon dev branch where all new development is done, which is quite a lot of rework done in that one.

mattgruter commented 8 years ago

I updated the java client to version 2.2.0. Thanks for the contribution! I haven't merged the "save image" feature yet. I am considering to break that out into its own Task (e.g. "saveDockerImage"), something I'd want to do with "push" as well. What do you think?

@bjornmagnusson: Concerning backwards compatibility: the new version of the java client requires Docker engine version 1.7 and above. I people need to use this plugin with an older version of the Docker engine I suggest they rely on the native docker client binary. What do you think?

BTW: I merge the dev branch into master and continue development on master from now on. The dev branch was just causing confusion and most PRs are build from master anyway.

bjornmagnusson commented 8 years ago

@mattgruter I was a bit concerned regarding this at first, however since docker pull/push to Docker Hub is disabled for clients with version 1.5 and below I think this requirement is fine. Only version which is neglected is in this case 1.6, which is a very old version in Docker terms, released almost a year ago. As long as we document this clearly we are fine in my opinion.

I agree upon this removal of dev branch for same reasons, it made merging PRs quite tiresome and difficult, so...yay

bjornmagnusson commented 8 years ago

Also, a saveDockerImage task seems like a reasonable way to do it

frvi commented 8 years ago

:+1: getting rid of dev :fist:

baptistemesta commented 8 years ago

Hi! yes the save feature should have been in an other PR anyway An other task should do the trick. Just to have some context because saving an docker image is not really common, my use case was to build a docker image on a CI an deliver it as a binary instead of pushing it to a docker repository.

Since i needed it fast I made my plugin as mentioned before. I don't know if some things can be taken from that but in case here is the link followed by some highlights: https://github.com/baptistemesta/docker-build

The part that were important for me was a minimal configuration of the project using the plugin. Here is a sample configuration:


apply plugin: 'distribution'
apply plugin: 'docker-build'

group = "com.myproject"
version = "1.0.0-SNAPSHOT"

docker {
    serverUrl = System.getProperty("docker.url")
    saveImageTo = new File(buildDir, "docker-image.tar")
}
distributions {
    main {
        contents {
            from { docker.saveImageTo }
        }
    }
}
tasks.distZip.dependsOn(tasks.buildDockerImage)

and to build the image you just have to run on the project

locally gradle distZip or with a remote docker gradle distZip -Ddocker.url=DOCKER_URL

I don't know if something like this can be also done in this plugin since it was more oriented on creating a docker image to run

mattgruter commented 8 years ago

I like that. I don't know how common saving an image to a tarball is but I can definitely see it being used. In my opinion we should add it but probably not in the upcoming 1.3 release (I'm trying to push it out the door soonish so adding new features is not my top prio right now :-) @baptistemesta would you mind opening an issue about that? Like that we could track it more easily. You could just link to this discussion for context.

baptistemesta commented 8 years ago

will do, tanks