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 { |
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 | // Target registry to be used to publish docker images needed for deployment |
| 24 | targetReg = project.hasProperty('targetReg') ? project.getProperty('targetReg') : 'localhost:5000' |
| 25 | |
| 26 | // The tag used to tag the docker images push to the target registry |
| 27 | targetTag = project.hasProperty('targetTag') ? project.getProperty('targetTag') : 'candidate' |
| 28 | |
| 29 | // Deployment target config file (yaml format); this can be overwritten from the command line |
| 30 | // using the -PdeployConfig=<file-path> syntax. |
| 31 | deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml' |
| 32 | |
Zsolt Haraszti | 19592c1 | 2016-09-08 13:52:23 -0700 | [diff] [blame] | 33 | } |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 34 | |
| 35 | // ~~~~~~~~~~~~~~~~~~~ Global tasks ~~~~~~~~~~~~~~~~~~~~~~~ |
| 36 | |
| 37 | // To be used to fetch upstream binaries, clone repos, etc. |
Zsolt Haraszti | b71c2a0 | 2016-09-12 13:12:07 -0700 | [diff] [blame] | 38 | task fetch(type: Exec) { |
Zsolt Haraszti | 4ca1ef7 | 2016-09-27 13:57:26 -0700 | [diff] [blame] | 39 | commandLine ".", "env.sh", "&&", "make", "fetch" |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | // To be used to generate all needed binaries that need to be present on the target |
| 43 | // as docker images in the local docker runner. |
| 44 | task buildImages(type: Exec) { |
Zsolt Haraszti | 4ca1ef7 | 2016-09-27 13:57:26 -0700 | [diff] [blame] | 45 | commandLine ".", "env.sh", "&&", "make" |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | task tagImage(type: Exec) { |
| 49 | dependsOn buildImages |
Zsolt Haraszti | 57c3dc3 | 2016-09-08 16:21:49 -0700 | [diff] [blame] | 50 | commandLine "docker", 'tag', 'cord/voltha', "$targetReg/cord/voltha:$targetTag" |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | // Publish image(s) built during the build step into targetReg registry using the targetTag |
| 54 | // tag. See maas subproject for examples on how to do this. |
| 55 | task publishImages(type: Exec) { |
| 56 | dependsOn tagImage |
Zsolt Haraszti | 57c3dc3 | 2016-09-08 16:21:49 -0700 | [diff] [blame] | 57 | commandLine "docker", 'push', "$targetReg/cord/voltha:$targetTag" |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | task publish { |
| 61 | dependsOn publishImages |
| 62 | } |