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 | |
| 57 | // Upstream registry to simplify filling out the comps table below |
Zsolt Haraszti | a9f7250 | 2016-05-12 16:07:03 -0700 | [diff] [blame] | 58 | upstreamReg = project.hasProperty('upstreamReg') ? project.getProperty('upstreamReg') : 'docker.io' |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 59 | |
| 60 | // Target registry to be used to publish docker images needed for deployment |
Zsolt Haraszti | a9f7250 | 2016-05-12 16:07:03 -0700 | [diff] [blame] | 61 | targetReg = project.hasProperty('targetReg') ? project.getProperty('targetReg') : 'localhost:5000' |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 62 | |
| 63 | // The tag used to tag the docker images push to the target registry |
Zsolt Haraszti | a9f7250 | 2016-05-12 16:07:03 -0700 | [diff] [blame] | 64 | targetTag = project.hasProperty('targetTag') ? project.getProperty('targetTag') : 'candidate' |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 65 | |
| 66 | // Component table |
| 67 | comps = [ |
David K. Bainbridge | d54ca70 | 2016-07-13 22:27:12 -0700 | [diff] [blame] | 68 | 'onosproject/onos': [ |
| 69 | 'type': 'image', |
| 70 | 'upstream': upstreamReg, |
| 71 | 'name': 'onosproject/onos', |
| 72 | 'digest': 'sha256:6c310b6bc798f745977973c8c883d3dd1eb250fd124ae4d627fd98a69efb5afc' |
| 73 | ], |
Zsolt Haraszti | 3dbe616 | 2016-05-12 12:25:56 -0700 | [diff] [blame] | 74 | 'nginx': [ |
| 75 | 'type': 'image', |
| 76 | 'upstream': upstreamReg, |
| 77 | 'name': 'nginx', |
| 78 | 'digest': 'sha256:b555f8c64ab4e85405e0d8b03f759b73ce88deb802892a3b155ef55e3e832806' |
| 79 | ], |
| 80 | 'swarm': [ |
| 81 | 'type': 'image', |
| 82 | 'upstream': upstreamReg, |
| 83 | 'name': 'swarm', |
| 84 | 'digest': 'sha256:6ca9b40980e2fcdcd229900ec8933f3e92c14ead22c9404cb09736cb4f3a9248' |
| 85 | ], |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 86 | ] |
| 87 | |
| 88 | // Deployment target config file (yaml format); this can be overwritten from the command line |
| 89 | // using the -PdeployConfig=<file-path> syntax. |
Zsolt Haraszti | a9f7250 | 2016-05-12 16:07:03 -0700 | [diff] [blame] | 90 | deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml' |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 91 | |
| 92 | } |
| 93 | |
alshabib | 00c4b5d | 2016-06-17 17:26:10 -0700 | [diff] [blame] | 94 | // ---------------- Useful tasks ---------------- |
| 95 | |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 96 | task fetchUpstreamImages { |
Zsolt Haraszti | 3dbe616 | 2016-05-12 12:25:56 -0700 | [diff] [blame] | 97 | comps.each { name, spec -> if (spec.type == 'image') { dependsOn "fetch" + name } } |
| 98 | } |
| 99 | |
alshabib | 11b8e5c | 2016-08-29 15:36:36 -0700 | [diff] [blame] | 100 | |
| 101 | task fetch { |
| 102 | dependsOn fetchUpstreamImages |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 103 | } |
| 104 | |
alshabib | 11b8e5c | 2016-08-29 15:36:36 -0700 | [diff] [blame] | 105 | task buildImages { |
| 106 | logger.info "Root project has nothing to build" |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | task publishImages { |
alshabib | 11b8e5c | 2016-08-29 15:36:36 -0700 | [diff] [blame] | 110 | comps.each { name, spec -> if (spec.type == 'image') { |
| 111 | dependsOn "publish" + name |
| 112 | } |
| 113 | } |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | task publish { |
Zsolt Haraszti | 3dbe616 | 2016-05-12 12:25:56 -0700 | [diff] [blame] | 117 | dependsOn publishImages |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | tasks.addRule(new DockerFetchRule(project)) |
alshabib | 11b8e5c | 2016-08-29 15:36:36 -0700 | [diff] [blame] | 121 | tasks.addRule(new DockerPublishRule(project, project(':maas').prime)) |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 122 | tasks.addRule(new DockerTagRule(project)) |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 123 | |
alshabib | 11b8e5c | 2016-08-29 15:36:36 -0700 | [diff] [blame] | 124 | project('platform-install').deployPlatform.dependsOn project(':maas').deployBase |
| 125 | project('onos-apps').publishMavenRepoImage.dependsOn project(':maas').prime |
Andy Bavier | beb89c0 | 2016-07-07 13:26:55 -0400 | [diff] [blame] | 126 | |
alshabib | 11b8e5c | 2016-08-29 15:36:36 -0700 | [diff] [blame] | 127 | task deploy { |
| 128 | dependsOn << project(':platform-install').deployPlatform |
Zsolt Haraszti | ec7df10 | 2016-05-05 13:34:18 -0700 | [diff] [blame] | 129 | } |
alshabib | b58aeab | 2016-06-17 16:47:02 -0700 | [diff] [blame] | 130 | |