blob: 9478738afe61cfd1db72fed1e93b3595dfd2db01 [file] [log] [blame]
/*
* Copyright 2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.opencord.gradle.rules.*
import org.yaml.snakeyaml.Yaml
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.dorongold.plugins:task-tree:1.2.1"
}
}
apply plugin: "com.dorongold.task-tree"
evaluationDependsOn(':maas')
evaluationDependsOn(':platform-install')
evaluationDependsOn(':onos-apps')
allprojects {
apply plugin: 'base'
apply plugin: 'de.gesellix.docker'
//apply plugin: 'com.tmiyamon.config'
docker {
// dockerHost = System.env.DOCKER_HOST ?: 'unix:///var/run/docker.sock'
// dockerHost = System.env.DOCKER_HOST ?: 'https://192.168.99.100:2376'
// certPath = System.getProperty('docker.cert.path') ?: "${System.getProperty('user.home')}/.docker/machine/machines/default"
// authConfigPlain = [
// "username" : "joe",
// "password" : "some-pw-as-needed",
// "email" : "joe@acme.com",
// "serveraddress" : "https://index.docker.io/v1/"
// ]
}
}
ext {
// Deployment target config file (yaml format); this can be overwritten from the command line
// using the -PdeployConfig=<file-path> syntax.
deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml'
println "Using deployment config: $deployConfig"
File configFile = new File(deployConfig)
def yaml = new Yaml()
config = yaml.load(configFile.newReader())
// Upstream registry to simplify filling out the comps table below
upstreamReg = project.hasProperty('upstreamReg') ? project.getProperty('upstreamReg') : 'docker.io'
// Target registry to be used to publish docker images needed for deployment
targetReg = project.hasProperty('targetReg')
? project.getProperty('targetReg')
: config.docker && config.docker.registry
? config.docker.registry
: config.seedServer.ip
? config.seedServer.ip + ":5000"
: 'localhost:5000'
// The tag used to tag the docker images push to the target registry
targetTag = project.hasProperty('targetTag')
? project.getProperty('targetTag')
: config.docker && config.docker.imageVersion
? config.docker.imageVersion
: 'candidate'
// Component table
comps = [
'onosproject/onos': [
'type': 'image',
'upstream': upstreamReg,
'name': 'onosproject/onos',
'digest': 'sha256:6c310b6bc798f745977973c8c883d3dd1eb250fd124ae4d627fd98a69efb5afc'
],
'nginx': [
'type': 'image',
'upstream': upstreamReg,
'name': 'nginx',
'digest': 'sha256:b555f8c64ab4e85405e0d8b03f759b73ce88deb802892a3b155ef55e3e832806'
],
'swarm': [
'type': 'image',
'upstream': upstreamReg,
'name': 'swarm',
'digest': 'sha256:6ca9b40980e2fcdcd229900ec8933f3e92c14ead22c9404cb09736cb4f3a9248'
],
'xosproject/vsg': [
'type': 'image',
'upstream': upstreamReg,
'name': 'xosproject/vsg',
'digest': 'sha256:18d1c6ef9767d8a41c9b51948776052d024d4e3294e5d1d6dde1a49112175d91'
],
'xosproject/xos-postgres': [
'type': 'image',
'upstream': upstreamReg,
'name': 'xosproject/xos-postgres',
'digest': 'sha256:f2d31a50b8af7434ab07b1e54e99c1ff1e10d77d16a46e5d6933d3c0528f4820'
],
'xosproject/cord-app-build': [
'type': 'image',
'upstream': upstreamReg,
'name': 'xosproject/cord-app-build',
'digest': 'sha256:528c6ac3a87609779035857a7b1cf9fab8e046e7ac259d72cf275f1c46d7416e'
],
'xosproject/xos-base': [
'type': 'image',
'upstream': upstreamReg,
'name': 'xosproject/xos-base',
'digest': 'sha256:1bc8cc8e9f99ae8e9c40ace4ee513c4278952ad719118aabf8aa6d6cc0a466ba'
],
'redis': [
'type': 'image',
'upstream': upstreamReg,
'name': 'redis',
'digest': 'sha256:0fe5a7afa2c2154f37c8ab56a9a6c5023cb0405cc0e85b34d8dcc1de6c3f143e'
],
]
}
// ---------------- Useful tasks ----------------
task fetchUpstreamImages {
comps.each { name, spec -> if (spec.type == 'image') { dependsOn "fetch" + name } }
}
task fetch {
dependsOn fetchUpstreamImages
}
task buildImages {
logger.info "Root project has nothing to build"
}
task publishImages {
comps.each { name, spec -> if (spec.type == 'image') {
dependsOn "publish" + name
}
}
}
task publish {
dependsOn publishImages
}
tasks.addRule(new DockerFetchRule(project))
tasks.addRule(new DockerPublishRule(project, project(':maas').prime))
tasks.addRule(new DockerTagRule(project))
project('platform-install').deployPlatform.dependsOn project(':maas').deployBase
project('onos-apps').publishMavenRepoImage.dependsOn project(':maas').prime
project('platform-install').deployPlatform.dependsOn project(':onos-apps').deploy
project(':onos-apps').deploy.dependsOn project(':maas').deployBase
task deploy {
dependsOn << project(':platform-install').deployPlatform
}