Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 the original author or authors. |
| 3 | * |
| 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. |
| 15 | */ |
| 16 | |
Zsolt Haraszti | 0b790aa | 2016-05-12 22:33:14 -0700 | [diff] [blame] | 17 | import org.opencord.gradle.rules.* |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 18 | import org.yaml.snakeyaml.Yaml |
| 19 | |
alshabib | 11b8e5c | 2016-08-29 15:36:36 -0700 | [diff] [blame] | 20 | buildscript { |
| 21 | repositories { |
| 22 | maven { |
| 23 | url "https://plugins.gradle.org/m2/" |
| 24 | } |
| 25 | } |
| 26 | dependencies { |
| 27 | classpath "gradle.plugin.com.dorongold.plugins:task-tree:1.2.1" |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | apply plugin: "com.dorongold.task-tree" |
| 32 | |
| 33 | evaluationDependsOn(':maas') |
| 34 | evaluationDependsOn(':platform-install') |
| 35 | evaluationDependsOn(':onos-apps') |
| 36 | |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 37 | allprojects { |
| 38 | apply plugin: 'base' |
| 39 | apply plugin: 'de.gesellix.docker' |
| 40 | //apply plugin: 'com.tmiyamon.config' |
| 41 | |
| 42 | docker { |
| 43 | // dockerHost = System.env.DOCKER_HOST ?: 'unix:///var/run/docker.sock' |
| 44 | // dockerHost = System.env.DOCKER_HOST ?: 'https://192.168.99.100:2376' |
| 45 | // certPath = System.getProperty('docker.cert.path') ?: "${System.getProperty('user.home')}/.docker/machine/machines/default" |
| 46 | // authConfigPlain = [ |
| 47 | // "username" : "joe", |
| 48 | // "password" : "some-pw-as-needed", |
| 49 | // "email" : "joe@acme.com", |
| 50 | // "serveraddress" : "https://index.docker.io/v1/" |
| 51 | // ] |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | ext { |
| 56 | |
David K. Bainbridge | 094508e | 2016-11-15 17:23:51 -0800 | [diff] [blame] | 57 | // Deployment target config file (yaml format); this can be overwritten from the command line |
| 58 | // using the -PdeployConfig=<file-path> syntax. |
| 59 | deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml' |
| 60 | |
| 61 | println "Using deployment config: $deployConfig" |
| 62 | File configFile = new File(deployConfig) |
| 63 | def yaml = new Yaml() |
| 64 | config = yaml.load(configFile.newReader()) |
| 65 | |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 66 | // Upstream registry to simplify filling out the comps table below |
Zsolt Haraszti | a9f7250 | 2016-05-12 16:07:03 -0700 | [diff] [blame] | 67 | upstreamReg = project.hasProperty('upstreamReg') ? project.getProperty('upstreamReg') : 'docker.io' |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 68 | |
| 69 | // Target registry to be used to publish docker images needed for deployment |
David K. Bainbridge | 094508e | 2016-11-15 17:23:51 -0800 | [diff] [blame] | 70 | targetReg = project.hasProperty('targetReg') |
| 71 | ? project.getProperty('targetReg') |
| 72 | : config.docker && config.docker.registry |
| 73 | ? config.docker.registry |
| 74 | : config.seedServer.ip |
| 75 | ? config.seedServer.ip + ":5000" |
| 76 | : 'localhost:5000' |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 77 | |
| 78 | // The tag used to tag the docker images push to the target registry |
David K. Bainbridge | 094508e | 2016-11-15 17:23:51 -0800 | [diff] [blame] | 79 | targetTag = project.hasProperty('targetTag') |
| 80 | ? project.getProperty('targetTag') |
| 81 | : config.docker && config.docker.imageVersion |
| 82 | ? config.docker.imageVersion |
| 83 | : 'candidate' |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 84 | |
| 85 | // Component table |
| 86 | comps = [ |
Andy Bavier | 65c8e15 | 2016-12-22 16:01:27 -0500 | [diff] [blame] | 87 | // ONOS 1.8.1.SNAPSHOT from the support branch |
| 88 | // This is probably not exactly what we want |
David K. Bainbridge | d54ca70 | 2016-07-13 22:27:12 -0700 | [diff] [blame] | 89 | 'onosproject/onos': [ |
| 90 | 'type': 'image', |
| 91 | 'upstream': upstreamReg, |
| 92 | 'name': 'onosproject/onos', |
Andy Bavier | 65c8e15 | 2016-12-22 16:01:27 -0500 | [diff] [blame] | 93 | 'digest': 'sha256:83aa5b1f43d4bf772929dc5aacf3f57cbd4467a4c7184586b53a35ea8a23226a' |
David K. Bainbridge | d54ca70 | 2016-07-13 22:27:12 -0700 | [diff] [blame] | 94 | ], |
Zsolt Haraszti | 3dbe616 | 2016-05-12 12:25:56 -0700 | [diff] [blame] | 95 | 'nginx': [ |
| 96 | 'type': 'image', |
| 97 | 'upstream': upstreamReg, |
| 98 | 'name': 'nginx', |
| 99 | 'digest': 'sha256:b555f8c64ab4e85405e0d8b03f759b73ce88deb802892a3b155ef55e3e832806' |
| 100 | ], |
| 101 | 'swarm': [ |
| 102 | 'type': 'image', |
| 103 | 'upstream': upstreamReg, |
| 104 | 'name': 'swarm', |
| 105 | 'digest': 'sha256:6ca9b40980e2fcdcd229900ec8933f3e92c14ead22c9404cb09736cb4f3a9248' |
| 106 | ], |
Scott Baker | a0a0e44 | 2016-10-10 20:58:22 -0700 | [diff] [blame] | 107 | 'xosproject/vsg': [ |
| 108 | 'type': 'image', |
| 109 | 'upstream': upstreamReg, |
| 110 | 'name': 'xosproject/vsg', |
| 111 | 'digest': 'sha256:18d1c6ef9767d8a41c9b51948776052d024d4e3294e5d1d6dde1a49112175d91' |
| 112 | ], |
Scott Baker | bceca9c | 2016-11-05 18:59:25 -0700 | [diff] [blame] | 113 | 'xosproject/xos-postgres': [ |
| 114 | 'type': 'image', |
| 115 | 'upstream': upstreamReg, |
| 116 | 'name': 'xosproject/xos-postgres', |
| 117 | 'digest': 'sha256:f2d31a50b8af7434ab07b1e54e99c1ff1e10d77d16a46e5d6933d3c0528f4820' |
| 118 | ], |
| 119 | 'xosproject/cord-app-build': [ |
| 120 | 'type': 'image', |
| 121 | 'upstream': upstreamReg, |
| 122 | 'name': 'xosproject/cord-app-build', |
| 123 | 'digest': 'sha256:528c6ac3a87609779035857a7b1cf9fab8e046e7ac259d72cf275f1c46d7416e' |
| 124 | ], |
Jonathan Hart | 09dad6c | 2016-11-14 16:52:56 -0800 | [diff] [blame] | 125 | 'xosproject/xos-base': [ |
| 126 | 'type': 'image', |
| 127 | 'upstream': upstreamReg, |
| 128 | 'name': 'xosproject/xos-base', |
Scott Baker | 3bd9fa8 | 2016-12-19 12:45:47 -0800 | [diff] [blame] | 129 | 'digest': 'sha256:1bc8cc8e9f99ae8e9c40ace4ee513c4278952ad719118aabf8aa6d6cc0a466ba' |
Jonathan Hart | 09dad6c | 2016-11-14 16:52:56 -0800 | [diff] [blame] | 130 | ], |
Scott Baker | bceca9c | 2016-11-05 18:59:25 -0700 | [diff] [blame] | 131 | 'redis': [ |
| 132 | 'type': 'image', |
| 133 | 'upstream': upstreamReg, |
| 134 | 'name': 'redis', |
| 135 | 'digest': 'sha256:0fe5a7afa2c2154f37c8ab56a9a6c5023cb0405cc0e85b34d8dcc1de6c3f143e' |
| 136 | ], |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 137 | ] |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 138 | } |
| 139 | |
alshabib | 00c4b5d | 2016-06-17 17:26:10 -0700 | [diff] [blame] | 140 | // ---------------- Useful tasks ---------------- |
| 141 | |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 142 | task fetchUpstreamImages { |
Zsolt Haraszti | 3dbe616 | 2016-05-12 12:25:56 -0700 | [diff] [blame] | 143 | comps.each { name, spec -> if (spec.type == 'image') { dependsOn "fetch" + name } } |
| 144 | } |
| 145 | |
alshabib | 11b8e5c | 2016-08-29 15:36:36 -0700 | [diff] [blame] | 146 | |
| 147 | task fetch { |
| 148 | dependsOn fetchUpstreamImages |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 149 | } |
| 150 | |
alshabib | 11b8e5c | 2016-08-29 15:36:36 -0700 | [diff] [blame] | 151 | task buildImages { |
| 152 | logger.info "Root project has nothing to build" |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | task publishImages { |
alshabib | 11b8e5c | 2016-08-29 15:36:36 -0700 | [diff] [blame] | 156 | comps.each { name, spec -> if (spec.type == 'image') { |
| 157 | dependsOn "publish" + name |
| 158 | } |
| 159 | } |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | task publish { |
Zsolt Haraszti | 3dbe616 | 2016-05-12 12:25:56 -0700 | [diff] [blame] | 163 | dependsOn publishImages |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | tasks.addRule(new DockerFetchRule(project)) |
alshabib | 11b8e5c | 2016-08-29 15:36:36 -0700 | [diff] [blame] | 167 | tasks.addRule(new DockerPublishRule(project, project(':maas').prime)) |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 168 | tasks.addRule(new DockerTagRule(project)) |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 169 | |
alshabib | 11b8e5c | 2016-08-29 15:36:36 -0700 | [diff] [blame] | 170 | project('platform-install').deployPlatform.dependsOn project(':maas').deployBase |
| 171 | project('onos-apps').publishMavenRepoImage.dependsOn project(':maas').prime |
alshabib | c64cf7f | 2016-09-07 11:47:01 -0700 | [diff] [blame] | 172 | project('platform-install').deployPlatform.dependsOn project(':onos-apps').deploy |
| 173 | project(':onos-apps').deploy.dependsOn project(':maas').deployBase |
| 174 | |
Andy Bavier | beb89c0 | 2016-07-07 13:26:55 -0400 | [diff] [blame] | 175 | |
alshabib | 11b8e5c | 2016-08-29 15:36:36 -0700 | [diff] [blame] | 176 | task deploy { |
| 177 | dependsOn << project(':platform-install').deployPlatform |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 178 | } |
alshabib | b58aeab | 2016-06-17 16:47:02 -0700 | [diff] [blame] | 179 | |