blob: dbe3ac53e8c796e1219992b6f91fddfd8e11ae72 [file] [log] [blame]
Zsolt Haraszti19592c12016-09-08 13:52:23 -07001/*
Zsolt Haraszti3d163532016-09-08 15:57:32 -07002 * Copyright 2016 the original author or authors.
Zsolt Haraszti19592c12016-09-08 13:52:23 -07003 *
Zsolt Haraszti3d163532016-09-08 15:57:32 -07004 * 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 Haraszti19592c12016-09-08 13:52:23 -070015 */
16
Zsolt Haraszti3d163532016-09-08 15:57:32 -070017allprojects {
18 apply plugin: 'base'
Zsolt Haraszti19592c12016-09-08 13:52:23 -070019}
20
Zsolt Haraszti3d163532016-09-08 15:57:32 -070021ext {
David K. Bainbridge57828bd2016-11-15 17:20:41 -080022 // Deployment target config file (yaml format); this can be overwritten from the command line
Zsolt Haraszti3d163532016-09-08 15:57:32 -070023 // using the -PdeployConfig=<file-path> syntax.
24 deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml'
25
David K. Bainbridge57828bd2016-11-15 17:20:41 -080026 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 Haraszti19592c12016-09-08 13:52:23 -070049}
Zsolt Haraszti3d163532016-09-08 15:57:32 -070050
51// ~~~~~~~~~~~~~~~~~~~ Global tasks ~~~~~~~~~~~~~~~~~~~~~~~
52
53// To be used to fetch upstream binaries, clone repos, etc.
Zsolt Harasztib71c2a02016-09-12 13:12:07 -070054task fetch(type: Exec) {
Zsolt Haraszti4ca1ef72016-09-27 13:57:26 -070055 commandLine ".", "env.sh", "&&", "make", "fetch"
Zsolt Haraszti3d163532016-09-08 15:57:32 -070056}
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.
60task buildImages(type: Exec) {
Zsolt Haraszti4ca1ef72016-09-27 13:57:26 -070061 commandLine ".", "env.sh", "&&", "make"
Zsolt Haraszti3d163532016-09-08 15:57:32 -070062}
63
64task tagImage(type: Exec) {
65 dependsOn buildImages
Zsolt Haraszti57c3dc32016-09-08 16:21:49 -070066 commandLine "docker", 'tag', 'cord/voltha', "$targetReg/cord/voltha:$targetTag"
Zsolt Haraszti3d163532016-09-08 15:57:32 -070067}
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.
71task publishImages(type: Exec) {
72 dependsOn tagImage
Zsolt Haraszti57c3dc32016-09-08 16:21:49 -070073 commandLine "docker", 'push', "$targetReg/cord/voltha:$targetTag"
Zsolt Haraszti3d163532016-09-08 15:57:32 -070074}
75
76task publish {
77 dependsOn publishImages
78}