Zsolt Haraszti | 19592c1 | 2016-09-08 13:52:23 -0700 | [diff] [blame] | 1 | /* |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 2 | * Copyright 2016 the original author or authors. |
Zsolt Haraszti | 19592c1 | 2016-09-08 13:52:23 -0700 | [diff] [blame] | 3 | * |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
Zsolt Haraszti | 19592c1 | 2016-09-08 13:52:23 -0700 | [diff] [blame] | 15 | */ |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 16 | import org.opencord.gradle.rules.* |
| 17 | import org.yaml.snakeyaml.Yaml |
Zsolt Haraszti | 19592c1 | 2016-09-08 13:52:23 -0700 | [diff] [blame] | 18 | |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 19 | allprojects { |
| 20 | apply plugin: 'base' |
| 21 | apply plugin: 'de.gesellix.docker' |
Zsolt Haraszti | 19592c1 | 2016-09-08 13:52:23 -0700 | [diff] [blame] | 22 | |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 23 | docker { |
| 24 | // dockerHost = System.env.DOCKER_HOST ?: 'unix:///var/run/docker.sock' |
| 25 | // dockerHost = System.env.DOCKER_HOST ?: 'https://192.168.99.100:2376' |
| 26 | // certPath = System.getProperty('docker.cert.path') ?: "${System.getProperty('user.home')}/.docker/machine/machines/default" |
| 27 | // authConfigPlain = [ |
| 28 | // "username" : "joe", |
| 29 | // "password" : "some-pw-as-needed", |
| 30 | // "email" : "joe@acme.com", |
| 31 | // "serveraddress" : "https://index.docker.io/v1/" |
| 32 | // ] |
| 33 | } |
Zsolt Haraszti | 19592c1 | 2016-09-08 13:52:23 -0700 | [diff] [blame] | 34 | } |
| 35 | |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 36 | ext { |
Zsolt Haraszti | 19592c1 | 2016-09-08 13:52:23 -0700 | [diff] [blame] | 37 | |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 38 | // Target registry to be used to publish docker images needed for deployment |
| 39 | targetReg = project.hasProperty('targetReg') ? project.getProperty('targetReg') : 'localhost:5000' |
| 40 | |
| 41 | // The tag used to tag the docker images push to the target registry |
| 42 | targetTag = project.hasProperty('targetTag') ? project.getProperty('targetTag') : 'candidate' |
| 43 | |
| 44 | // Deployment target config file (yaml format); this can be overwritten from the command line |
| 45 | // using the -PdeployConfig=<file-path> syntax. |
| 46 | deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml' |
| 47 | |
Zsolt Haraszti | 19592c1 | 2016-09-08 13:52:23 -0700 | [diff] [blame] | 48 | } |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 49 | |
| 50 | // ~~~~~~~~~~~~~~~~~~~ Global tasks ~~~~~~~~~~~~~~~~~~~~~~~ |
| 51 | |
| 52 | // To be used to fetch upstream binaries, clone repos, etc. |
Zsolt Haraszti | b71c2a0 | 2016-09-12 13:12:07 -0700 | [diff] [blame] | 53 | task fetch(type: Exec) { |
| 54 | commandLine "make", "fetch" |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | // To be used to generate all needed binaries that need to be present on the target |
| 58 | // as docker images in the local docker runner. |
| 59 | task buildImages(type: Exec) { |
Zsolt Haraszti | eb56d71 | 2016-09-10 22:20:52 -0700 | [diff] [blame] | 60 | commandLine "make" |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | task tagImage(type: Exec) { |
| 64 | dependsOn buildImages |
Zsolt Haraszti | 57c3dc3 | 2016-09-08 16:21:49 -0700 | [diff] [blame] | 65 | commandLine "docker", 'tag', 'cord/voltha', "$targetReg/cord/voltha:$targetTag" |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | // Publish image(s) built during the build step into targetReg registry using the targetTag |
| 69 | // tag. See maas subproject for examples on how to do this. |
| 70 | task publishImages(type: Exec) { |
| 71 | dependsOn tagImage |
Zsolt Haraszti | 57c3dc3 | 2016-09-08 16:21:49 -0700 | [diff] [blame] | 72 | commandLine "docker", 'push', "$targetReg/cord/voltha:$targetTag" |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | task publish { |
| 76 | dependsOn publishImages |
| 77 | } |