Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame^] | 1 | plugins { |
| 2 | id "com.github.ben-manes.versions" version "0.12.0" |
| 3 | id "de.gesellix.docker" version "2016-05-05T13-15-11" |
| 4 | } |
| 5 | |
| 6 | import de.gesellix.gradle.docker.tasks.* |
| 7 | |
| 8 | import static groovy.json.JsonOutput.prettyPrint |
| 9 | import static groovy.json.JsonOutput.toJson |
| 10 | |
| 11 | allprojects { |
| 12 | apply plugin: 'base' |
| 13 | apply plugin: 'de.gesellix.docker' |
| 14 | docker { |
| 15 | // dockerHost = System.env.DOCKER_HOST ?: 'unix:///var/run/docker.sock' |
| 16 | // dockerHost = System.env.DOCKER_HOST ?: 'https://192.168.99.100:2376' |
| 17 | // certPath = System.getProperty('docker.cert.path') ?: "${System.getProperty('user.home')}/.docker/machine/machines/default" |
| 18 | // authConfigPlain = [ |
| 19 | // "username" : "joe", |
| 20 | // "password" : "some-pw-as-needed", |
| 21 | // "email" : "joe@acme.com", |
| 22 | // "serveraddress" : "https://index.docker.io/v1/" |
| 23 | // ] |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | task ping(type: DockerPingTask) { |
| 28 | doLast { println prettyPrint(toJson(result.content)) } |
| 29 | } |
| 30 | |
| 31 | task info(type: DockerInfoTask) { |
| 32 | doLast { println prettyPrint(toJson(info)) } |
| 33 | } |
| 34 | |
| 35 | task version(type: DockerVersionTask) { |
| 36 | doLast { println prettyPrint(toJson(version)) } |
| 37 | } |
| 38 | |
| 39 | //task publish(type: DockerPublishTask) { |
| 40 | // imageName = 'nginx' |
| 41 | // imageTag = 'cand' |
| 42 | // buildContextDirectory = file('./docker/') |
| 43 | // targetRegistries = [ |
| 44 | // dev: "localhost:5000" |
| 45 | // ] |
| 46 | //} |
| 47 | |
| 48 | task fetch(type: DockerPullTask) { |
| 49 | imageName = 'nginx@sha256:b555f8c64ab4e85405e0d8b03f759b73ce88deb802892a3b155ef55e3e832806' |
| 50 | // tag = 'sha256:b555f8c64ab4e85405e0d8b03f759b73ce88deb802892a3b155ef55e3e832806' |
| 51 | // tag = '1.10.0' |
| 52 | // authConfigPlain = getDockerClient().readDefaultAuthConfig() |
| 53 | } |
| 54 | |
| 55 | task tag(type: DockerTagTask) { |
| 56 | dependsOn fetch |
| 57 | imageId = 'nginx@sha256:b555f8c64ab4e85405e0d8b03f759b73ce88deb802892a3b155ef55e3e832806' |
| 58 | tag = 'nginx:cand' |
| 59 | } |
| 60 | |
| 61 | task publish(type: DockerPushTask) { |
| 62 | dependsOn tag |
| 63 | |
| 64 | repositoryName = 'nginx:cand' |
| 65 | registry = 'localhost:5000' |
| 66 | } |