blob: e479884542f8625e95baca38c2cccee4eae977cd [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
17import org.opencord.build.rules.*
18import 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
41 upstreamReg = 'docker.io'
42
43 // Target registry to be used to publish docker images needed for deployment
44 targetReg = 'localhost:5000'
45
46 // The tag used to tag the docker images push to the target registry
47 targetTag = 'candidate'
48
49 // Component table
50 comps = [
51 'nginx': [ 'type': 'image',
52 'upstream': upstreamReg,
53 'name': 'nginx',
54 'digest': 'sha256:b555f8c64ab4e85405e0d8b03f759b73ce88deb802892a3b155ef55e3e832806' ],
55 'swarm': [ 'type': 'image',
56 'upstream': upstreamReg,
57 'name': 'swarm',
58 'digest': 'sha256:6ca9b40980e2fcdcd229900ec8933f3e92c14ead22c9404cb09736cb4f3a9248' ],
59 ]
60
61 // Deployment target config file (yaml format); this can be overwritten from the command line
62 // using the -PdeployConfig=<file-path> syntax.
63 deployConfig = project.hasProperty('deployConfig') ?
64 project.getProperty('deployConfig') : './config/default.yml'
65
66}
67
68task fetchUpstreamImages {
69 comps.each { name, spec -> if (spec.type == 'image') { dependsOn "fetch" + name } }
70}
71
72task fetch {
73 dependsOn fetchUpstreamImages
74}
75
76task publishImages {
77 comps.each { name, _ -> dependsOn "publish" + name }
78}
79
80task publish {
81 dependsOn publishImages
82}
83
84tasks.addRule(new DockerFetchRule(project))
85tasks.addRule(new DockerPublishRule(project))
86tasks.addRule(new DockerTagRule(project))
87
88task deploy {
89 // TODO this is a place-holder.
90 doFirst {
91 println "Using deployment config: $deployConfig"
92 File configFile = new File(deployConfig)
93 def yaml = new Yaml()
94 def config = yaml.load(configFile.newReader())
95 println "Config: $config"
96 println "Access some data in config:\n\tSeed server IP=${config.seedServer.ip}"
97 }
98}