blob: 9d5723a2903e656c57f01701570cc151b5f7504a [file] [log] [blame]
alshabib676bef52016-06-02 12:18:32 -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
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 appVersion = null
41
42 // Target registry to be used to publish docker images needed for deployment
43 targetReg = project.hasProperty('targetReg') ? project.getProperty('targetReg') : 'localhost:5000'
44
45 // The tag used to tag the docker images push to the target registry
46 targetTag = project.hasProperty('targetTag') ? project.getProperty('targetTag') : 'candidate'
47
alshabib4bfb9ce2016-06-02 22:25:12 -070048 // The tag used to tag the docker images push to the target registry
49 targetTag = project.hasProperty('targetTag') ? project.getProperty('targetTag') : 'candidate'
50
alshabib676bef52016-06-02 12:18:32 -070051 comps = [
52 'aaa' : [
53 'type': 'gitmodule',
54 'upstream': 'https://gerrit.opencord.org/aaa',
55 'branch' : 'master',
56 'tag' : appVersion,
57 'componentDir': './apps/aaa'
58 ],
59 'vtn' : [
60 'type': 'gitmodule',
61 'upstream': 'https://gerrit.opencord.org/vtn',
62 'branch' : 'master',
63 'tag' : appVersion,
64 'componentDir': './apps/vtn'
65 ],
66 'mcast' : [
67 'type': 'gitmodule',
68 'upstream': 'https://gerrit.opencord.org/mcast',
69 'branch' : 'master',
70 'tag' : appVersion,
71 'componentDir': './apps/mcast'
72 ],
73 'igmp' : [
74 'type': 'gitmodule',
75 'upstream': 'https://gerrit.opencord.org/igmp',
76 'branch' : 'master',
77 'tag' : appVersion,
78 'componentDir': './apps/igmp'
79 ],
80 'olt' : [
81 'type': 'gitmodule',
82 'upstream': 'https://gerrit.opencord.org/olt',
83 'branch' : 'master',
84 'tag' : appVersion,
85 'componentDir': './apps/olt'
86 ],
87 'config' : [
88 'type': 'gitmodule',
89 'upstream': 'https://gerrit.opencord.org/config',
90 'branch' : 'master',
91 'tag' : appVersion,
92 'componentDir': './apps/config'
alshabib4bfb9ce2016-06-02 22:25:12 -070093 ],
94 'nginx': [
95 'type': 'image',
96 'upstream': upstreamReg,
97 'name': 'nginx',
98 'digest': 'sha256:b555f8c64ab4e85405e0d8b03f759b73ce88deb802892a3b155ef55e3e832806'
alshabib676bef52016-06-02 12:18:32 -070099 ]
100 ]
101}
102
103// ~~~~~~~~~~~~~~~~~~~ Global tasks ~~~~~~~~~~~~~~~~~~~~~~~
104
105task fetchGitSubmodules {
106 comps.each { name, spec -> if (spec.type == 'gitmodule') { dependsOn "gitupdate" + name } }
107}
108
109task fetch {
110 dependsOn fetchGitSubmodules
111}
112
113// To be used to generate all needed binaries that need to be present on the target
114// as docker images in the local docker runner.
115task buildImages (dependsOn: fetch, type: Exec){
116 workingDir './apps'
117 commandLine 'mvn', 'clean', 'install'
alshabib4bfb9ce2016-06-02 22:25:12 -0700118
119 workingDir './'
120
121 commandLine 'cp', '-R', '~/.m2/repository' 'repository/'
122 commandLine 'docker', 'build', '-t', 'cordproject/mavenrepo', '.'
alshabib676bef52016-06-02 12:18:32 -0700123}
124
125// Publish image(s) built during the build step into targetReg registry using the targetTag
126// tag. See maas subproject for examples on how to do this.
alshabib4bfb9ce2016-06-02 22:25:12 -0700127task publish (dependsOn: buildImages, type: Exec) {
alshabib676bef52016-06-02 12:18:32 -0700128}
129
130tasks.addRule(new GitSubmoduleUpdateRule(project))