blob: 3b62215acde34d88895a90f2baf908f611eae396 [file] [log] [blame]
Zsolt Harasztiec7df102016-05-05 13:34:18 -07001/*
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 Haraszti0b790aa2016-05-12 22:33:14 -070017import org.opencord.gradle.rules.*
Zsolt Harasztiec7df102016-05-05 13:34:18 -070018import org.yaml.snakeyaml.Yaml
19
20allprojects {
21 apply plugin: 'base'
22 apply plugin: 'de.gesellix.docker'
23 //apply plugin: 'com.tmiyamon.config'
24
25 docker {
26 // dockerHost = System.env.DOCKER_HOST ?: 'unix:///var/run/docker.sock'
27 // dockerHost = System.env.DOCKER_HOST ?: 'https://192.168.99.100:2376'
28 // certPath = System.getProperty('docker.cert.path') ?: "${System.getProperty('user.home')}/.docker/machine/machines/default"
29 // authConfigPlain = [
30 // "username" : "joe",
31 // "password" : "some-pw-as-needed",
32 // "email" : "joe@acme.com",
33 // "serveraddress" : "https://index.docker.io/v1/"
34 // ]
35 }
36}
37
38ext {
39
40 // Upstream registry to simplify filling out the comps table below
Zsolt Harasztia9f72502016-05-12 16:07:03 -070041 upstreamReg = project.hasProperty('upstreamReg') ? project.getProperty('upstreamReg') : 'docker.io'
Zsolt Harasztiec7df102016-05-05 13:34:18 -070042
43 // Target registry to be used to publish docker images needed for deployment
Zsolt Harasztia9f72502016-05-12 16:07:03 -070044 targetReg = project.hasProperty('targetReg') ? project.getProperty('targetReg') : 'localhost:5000'
Zsolt Harasztiec7df102016-05-05 13:34:18 -070045
46 // The tag used to tag the docker images push to the target registry
Zsolt Harasztia9f72502016-05-12 16:07:03 -070047 targetTag = project.hasProperty('targetTag') ? project.getProperty('targetTag') : 'candidate'
Zsolt Harasztiec7df102016-05-05 13:34:18 -070048
49 // Component table
50 comps = [
Zsolt Haraszti3dbe6162016-05-12 12:25:56 -070051 'maas': [
52 'type': 'gitmodule',
53 'upstream': '../maas',
54 'branch': 'master',
55 'tag': null,
56 'componentDir': './components/maas'
57 ],
Zsolt Harasztifac9f192016-06-02 18:20:06 -070058 'cord-tester': [
59 'type': 'gitmodule',
60 'upstream': '../cord-tester',
61 'branch': 'master',
62 'tag': null,
63 'componentDir': './components/cord-tester'
64 ],
Zsolt Haraszti7fdeaf02016-06-03 09:12:28 -070065 'cord-onos-publisher': [
66 'type': 'gitmodule',
67 'upstream': '../cord-onos-publisher',
68 'branch': 'master',
69 'tag': null,
70 'componentDir': './components/cord-onos-publisher'
71 ],
Andy Bavierfe2b4072016-07-06 19:13:55 -040072 'platform-install': [
73 'type': 'gitmodule',
74 'upstream': '../platform-install',
75 'branch': 'master',
76 'tag': null,
77 'componentDir': './components/platform-install'
78 ],
Zsolt Haraszti3dbe6162016-05-12 12:25:56 -070079 'nginx': [
80 'type': 'image',
81 'upstream': upstreamReg,
82 'name': 'nginx',
83 'digest': 'sha256:b555f8c64ab4e85405e0d8b03f759b73ce88deb802892a3b155ef55e3e832806'
84 ],
85 'swarm': [
86 'type': 'image',
87 'upstream': upstreamReg,
88 'name': 'swarm',
89 'digest': 'sha256:6ca9b40980e2fcdcd229900ec8933f3e92c14ead22c9404cb09736cb4f3a9248'
90 ],
Zsolt Harasztiec7df102016-05-05 13:34:18 -070091 ]
92
93 // Deployment target config file (yaml format); this can be overwritten from the command line
94 // using the -PdeployConfig=<file-path> syntax.
Zsolt Harasztia9f72502016-05-12 16:07:03 -070095 deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml'
Zsolt Harasztiec7df102016-05-05 13:34:18 -070096
97}
98
alshabib00c4b5d2016-06-17 17:26:10 -070099// ------------- PlaceHolders ----------------
100
101task updateDocker (type: Exec) {
102 commandLine 'sudo', 'utils/enable-remote-docker-registry', "$targetReg"
103}
104
105task prime {
106 // TODO this is a place-holder.
107 dependsOn updateDocker
108 doFirst {
109 println "Using deployment config: $deployConfig"
110 File configFile = new File(deployConfig)
111 def yaml = new Yaml()
112 def config = yaml.load(configFile.newReader())
113 println "Config: $config"
114 println "Access some data in config:\n\tSeed server IP=${config.seedServer.ip}"
115 }
116}
117
alshabib00c4b5d2016-06-17 17:26:10 -0700118// ---------------- Useful tasks ----------------
119
Zsolt Harasztiec7df102016-05-05 13:34:18 -0700120task fetchUpstreamImages {
Zsolt Haraszti3dbe6162016-05-12 12:25:56 -0700121 comps.each { name, spec -> if (spec.type == 'image') { dependsOn "fetch" + name } }
122}
123
124task fetchGitSubmodules {
125 comps.each { name, spec -> if (spec.type == 'gitmodule') { dependsOn "gitupdate" + name } }
Zsolt Harasztiec7df102016-05-05 13:34:18 -0700126}
127
128task fetch {
Zsolt Haraszti3dbe6162016-05-12 12:25:56 -0700129 dependsOn fetchUpstreamImages
130 dependsOn fetchGitSubmodules
Zsolt Harasztiec7df102016-05-05 13:34:18 -0700131}
132
133task publishImages {
Zsolt Harasztia9f72502016-05-12 16:07:03 -0700134 comps.each { name, spec -> if (spec.type == 'image') { dependsOn "publish" + name } }
Zsolt Harasztiec7df102016-05-05 13:34:18 -0700135}
136
137task publish {
Zsolt Haraszti3dbe6162016-05-12 12:25:56 -0700138 dependsOn publishImages
Zsolt Harasztiec7df102016-05-05 13:34:18 -0700139}
140
141tasks.addRule(new DockerFetchRule(project))
142tasks.addRule(new DockerPublishRule(project))
143tasks.addRule(new DockerTagRule(project))
Zsolt Haraszti3dbe6162016-05-12 12:25:56 -0700144tasks.addRule(new GitSubmoduleUpdateRule(project))
Zsolt Harasztiec7df102016-05-05 13:34:18 -0700145
Andy Bavierbeb89c02016-07-07 13:26:55 -0400146task deployBase {
147 // TODO this is a place-holder.
148 doFirst {
149 println "Using deployment config: $deployConfig"
150 File configFile = new File(deployConfig)
151 def yaml = new Yaml()
152 def config = yaml.load(configFile.newReader())
153 println "Config: $config"
154 println "Access some data in config:\n\tSeed server IP=${config.seedServer.ip}"
155 }
156}
157
158task deployPlatform {
Zsolt Harasztiec7df102016-05-05 13:34:18 -0700159 // TODO this is a place-holder.
160 doFirst {
161 println "Using deployment config: $deployConfig"
162 File configFile = new File(deployConfig)
163 def yaml = new Yaml()
164 def config = yaml.load(configFile.newReader())
165 println "Config: $config"
166 println "Access some data in config:\n\tSeed server IP=${config.seedServer.ip}"
167 }
168}
alshabibb58aeab2016-06-17 16:47:02 -0700169