blob: 2dfc4b95e9819a4c7bdd3762fe5eb3b6ed50a1c1 [file] [log] [blame]
alshabib590d09a2016-08-24 17:59:38 -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
17import org.opencord.gradle.rules.*
18import org.yaml.snakeyaml.Yaml
19
20buildscript {
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
31apply plugin: "com.dorongold.task-tree"
32
33evaluationDependsOn(':maas')
34evaluationDependsOn(':platform-install')
35
36allprojects {
37 apply plugin: 'base'
38 apply plugin: 'de.gesellix.docker'
39 //apply plugin: 'com.tmiyamon.config'
40
41 docker {
42 // dockerHost = System.env.DOCKER_HOST ?: 'unix:///var/run/docker.sock'
43 // dockerHost = System.env.DOCKER_HOST ?: 'https://192.168.99.100:2376'
44 // certPath = System.getProperty('docker.cert.path') ?: "${System.getProperty('user.home')}/.docker/machine/machines/default"
45 // authConfigPlain = [
46 // "username" : "joe",
47 // "password" : "some-pw-as-needed",
48 // "email" : "joe@acme.com",
49 // "serveraddress" : "https://index.docker.io/v1/"
50 // ]
51 }
52}
53
54ext {
55
56 // Upstream registry to simplify filling out the comps table below
57 upstreamReg = project.hasProperty('upstreamReg') ? project.getProperty('upstreamReg') : 'docker.io'
58
59 // Target registry to be used to publish docker images needed for deployment
60 targetReg = project.hasProperty('targetReg') ? project.getProperty('targetReg') : 'localhost:5000'
61
62 // The tag used to tag the docker images push to the target registry
63 targetTag = project.hasProperty('targetTag') ? project.getProperty('targetTag') : 'candidate'
64
65 // Component table
66 comps = [
67 'onosproject/onos': [
68 'type': 'image',
69 'upstream': upstreamReg,
70 'name': 'onosproject/onos',
71 'digest': 'sha256:6c310b6bc798f745977973c8c883d3dd1eb250fd124ae4d627fd98a69efb5afc'
72 ],
73 'nginx': [
74 'type': 'image',
75 'upstream': upstreamReg,
76 'name': 'nginx',
77 'digest': 'sha256:b555f8c64ab4e85405e0d8b03f759b73ce88deb802892a3b155ef55e3e832806'
78 ],
79 'swarm': [
80 'type': 'image',
81 'upstream': upstreamReg,
82 'name': 'swarm',
83 'digest': 'sha256:6ca9b40980e2fcdcd229900ec8933f3e92c14ead22c9404cb09736cb4f3a9248'
84 ],
85 ]
86
87 // Deployment target config file (yaml format); this can be overwritten from the command line
88 // using the -PdeployConfig=<file-path> syntax.
89 deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml'
90
91}
92
93// ---------------- Useful tasks ----------------
94
95task fetchUpstreamImages {
96 comps.each { name, spec -> if (spec.type == 'image') { dependsOn "fetch" + name } }
97}
98
99
100task fetch {
101 dependsOn fetchUpstreamImages
102}
103
104task buildImages {
105 logger.info "Root project has nothing to build"
106}
107
108task publishImages {
109 comps.each { name, spec -> if (spec.type == 'image') {
110 dependsOn "publish" + name
111 }
112 }
113}
114
115task publish {
116 dependsOn publishImages
117}
118
119tasks.addRule(new DockerFetchRule(project))
alshabib5e8a3262016-08-25 14:00:47 -0700120tasks.addRule(new DockerPublishRule(project, project(':maas').prime))
alshabib590d09a2016-08-24 17:59:38 -0700121tasks.addRule(new DockerTagRule(project))
alshabib590d09a2016-08-24 17:59:38 -0700122
123project('platform-install').deployPlatform.dependsOn project(':maas').deployBase
alshabib590d09a2016-08-24 17:59:38 -0700124
125task deploy {
126 dependsOn << project(':platform-install').deployPlatform
127}
128