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 | */ |
| 16 | |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 17 | allprojects { |
| 18 | apply plugin: 'base' |
Zsolt Haraszti | 19592c1 | 2016-09-08 13:52:23 -0700 | [diff] [blame] | 19 | } |
| 20 | |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 21 | ext { |
David K. Bainbridge | 57828bd | 2016-11-15 17:20:41 -0800 | [diff] [blame] | 22 | // Deployment target config file (yaml format); this can be overwritten from the command line |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 23 | // using the -PdeployConfig=<file-path> syntax. |
| 24 | deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml' |
| 25 | |
David K. Bainbridge | 57828bd | 2016-11-15 17:20:41 -0800 | [diff] [blame] | 26 | println "Using deployment config: $deployConfig" |
| 27 | File configFile = new File(deployConfig) |
| 28 | def yaml = new Yaml() |
| 29 | config = yaml.load(configFile.newReader()) |
| 30 | |
| 31 | // Upstream registry to simplify filling out the comps table below |
| 32 | upstreamReg = project.hasProperty('upstreamReg') ? project.getProperty('upstreamReg') : 'docker.io' |
| 33 | |
| 34 | // Target registry to be used to publish docker images needed for deployment |
| 35 | targetReg = project.hasProperty('targetReg') |
| 36 | ? project.getProperty('targetReg') |
| 37 | : config.docker && config.docker.registry |
| 38 | ? config.docker.registry |
| 39 | : config.seedServer.ip |
| 40 | ? config.seedServer.ip + ":5000" |
| 41 | : 'localhost:5000' |
| 42 | |
| 43 | // The tag used to tag the docker images push to the target registry |
| 44 | targetTag = project.hasProperty('targetTag') |
| 45 | ? project.getProperty('targetTag') |
| 46 | : config.docker && config.docker.imageVersion |
| 47 | ? config.docker.imageVersion |
| 48 | : 'candidate' |
Zsolt Haraszti | 19592c1 | 2016-09-08 13:52:23 -0700 | [diff] [blame] | 49 | } |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 50 | |
| 51 | // ~~~~~~~~~~~~~~~~~~~ Global tasks ~~~~~~~~~~~~~~~~~~~~~~~ |
| 52 | |
| 53 | // To be used to fetch upstream binaries, clone repos, etc. |
Zsolt Haraszti | b71c2a0 | 2016-09-12 13:12:07 -0700 | [diff] [blame] | 54 | task fetch(type: Exec) { |
Zsolt Haraszti | 4ca1ef7 | 2016-09-27 13:57:26 -0700 | [diff] [blame] | 55 | commandLine ".", "env.sh", "&&", "make", "fetch" |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | // To be used to generate all needed binaries that need to be present on the target |
| 59 | // as docker images in the local docker runner. |
| 60 | task buildImages(type: Exec) { |
Zsolt Haraszti | 4ca1ef7 | 2016-09-27 13:57:26 -0700 | [diff] [blame] | 61 | commandLine ".", "env.sh", "&&", "make" |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | task tagImage(type: Exec) { |
| 65 | dependsOn buildImages |
Zsolt Haraszti | 57c3dc3 | 2016-09-08 16:21:49 -0700 | [diff] [blame] | 66 | commandLine "docker", 'tag', 'cord/voltha', "$targetReg/cord/voltha:$targetTag" |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | // Publish image(s) built during the build step into targetReg registry using the targetTag |
| 70 | // tag. See maas subproject for examples on how to do this. |
| 71 | task publishImages(type: Exec) { |
| 72 | dependsOn tagImage |
Zsolt Haraszti | 57c3dc3 | 2016-09-08 16:21:49 -0700 | [diff] [blame] | 73 | commandLine "docker", 'push', "$targetReg/cord/voltha:$targetTag" |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | task publish { |
| 77 | dependsOn publishImages |
| 78 | } |