gradle-docker
gradle-docker copied to clipboard
Have a save image on FS feature
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
Refer to the discussion in PR #63 for some more information. I would like to add this feature but probably not in upcoming 1.3 release.