blob: 737cd3061607f13bae7672820f443916d3de835d [file] [log] [blame]
Zsolt Haraszti19592c12016-09-08 13:52:23 -07001/*
Zsolt Haraszti3d163532016-09-08 15:57:32 -07002 * Copyright 2016 the original author or authors.
Zsolt Haraszti19592c12016-09-08 13:52:23 -07003 *
Zsolt Haraszti3d163532016-09-08 15:57:32 -07004 * 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.
Zsolt Haraszti19592c12016-09-08 13:52:23 -070015 */
Zsolt Haraszti3d163532016-09-08 15:57:32 -070016import org.opencord.gradle.rules.*
17import org.yaml.snakeyaml.Yaml
Zsolt Haraszti19592c12016-09-08 13:52:23 -070018
Zsolt Haraszti3d163532016-09-08 15:57:32 -070019allprojects {
20 apply plugin: 'base'
21 apply plugin: 'de.gesellix.docker'
Zsolt Haraszti19592c12016-09-08 13:52:23 -070022
Zsolt Haraszti3d163532016-09-08 15:57:32 -070023 docker {
24 // dockerHost = System.env.DOCKER_HOST ?: 'unix:///var/run/docker.sock'
25 // dockerHost = System.env.DOCKER_HOST ?: 'https://192.168.99.100:2376'
26 // certPath = System.getProperty('docker.cert.path') ?: "${System.getProperty('user.home')}/.docker/machine/machines/default"
27 // authConfigPlain = [
28 // "username" : "joe",
29 // "password" : "some-pw-as-needed",
30 // "email" : "joe@acme.com",
31 // "serveraddress" : "https://index.docker.io/v1/"
32 // ]
33 }
Zsolt Haraszti19592c12016-09-08 13:52:23 -070034}
35
Zsolt Haraszti3d163532016-09-08 15:57:32 -070036ext {
Zsolt Haraszti19592c12016-09-08 13:52:23 -070037
Zsolt Haraszti3d163532016-09-08 15:57:32 -070038 // Target registry to be used to publish docker images needed for deployment
39 targetReg = project.hasProperty('targetReg') ? project.getProperty('targetReg') : 'localhost:5000'
40
41 // The tag used to tag the docker images push to the target registry
42 targetTag = project.hasProperty('targetTag') ? project.getProperty('targetTag') : 'candidate'
43
44 // Deployment target config file (yaml format); this can be overwritten from the command line
45 // using the -PdeployConfig=<file-path> syntax.
46 deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml'
47
48 dockerPath = project.hasProperty('dockerPath') ? project.getProperty('dockerPath') : '/usr/bin'
49
Zsolt Haraszti19592c12016-09-08 13:52:23 -070050}
Zsolt Haraszti3d163532016-09-08 15:57:32 -070051
52// ~~~~~~~~~~~~~~~~~~~ Global tasks ~~~~~~~~~~~~~~~~~~~~~~~
53
54// To be used to fetch upstream binaries, clone repos, etc.
55task fetch {
56 // ...
57}
58
59// To be used to generate all needed binaries that need to be present on the target
60// as docker images in the local docker runner.
61task buildImages(type: Exec) {
62 commandLine "$dockerPath/docker", 'build', '-t', 'cord/voltha', '-f', 'Dockerfile', '.'
63}
64
65task tagImage(type: Exec) {
66 dependsOn buildImages
67 commandLine "$dockerPath/docker", 'tag', 'cord/voltha', "$targetReg/cord/voltha:$targetTag"
68}
69
70// Publish image(s) built during the build step into targetReg registry using the targetTag
71// tag. See maas subproject for examples on how to do this.
72task publishImages(type: Exec) {
73 dependsOn tagImage
74 commandLine "$dockerPath/docker", 'push', "$targetReg/cord/voltha:$targetTag"
75}
76
77task publish {
78 dependsOn publishImages
79}