blob: 3de287063f8fee39b84790fb77bb2c7c27d0fa4d [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
Zsolt Haraszti19592c12016-09-08 13:52:23 -070048}
Zsolt Haraszti3d163532016-09-08 15:57:32 -070049
50// ~~~~~~~~~~~~~~~~~~~ Global tasks ~~~~~~~~~~~~~~~~~~~~~~~
51
52// To be used to fetch upstream binaries, clone repos, etc.
53task fetch {
54 // ...
55}
56
57// To be used to generate all needed binaries that need to be present on the target
58// as docker images in the local docker runner.
59task buildImages(type: Exec) {
Zsolt Haraszti57c3dc32016-09-08 16:21:49 -070060 commandLine "docker", 'build', '-t', 'cord/voltha', '-f', 'Dockerfile', '.'
Zsolt Haraszti3d163532016-09-08 15:57:32 -070061}
62
63task tagImage(type: Exec) {
64 dependsOn buildImages
Zsolt Haraszti57c3dc32016-09-08 16:21:49 -070065 commandLine "docker", 'tag', 'cord/voltha', "$targetReg/cord/voltha:$targetTag"
Zsolt Haraszti3d163532016-09-08 15:57:32 -070066}
67
68// Publish image(s) built during the build step into targetReg registry using the targetTag
69// tag. See maas subproject for examples on how to do this.
70task publishImages(type: Exec) {
71 dependsOn tagImage
Zsolt Haraszti57c3dc32016-09-08 16:21:49 -070072 commandLine "docker", 'push', "$targetReg/cord/voltha:$targetTag"
Zsolt Haraszti3d163532016-09-08 15:57:32 -070073}
74
75task publish {
76 dependsOn publishImages
77}