Skip to content

Commit

Permalink
Better configurable docker url
Browse files Browse the repository at this point in the history
The docker url property can be overriden with a project property for more flexibility.
  • Loading branch information
mrhaki committed Jan 9, 2016
1 parent 25905a4 commit c91e335
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions gradle/docker.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,22 @@ ext {


docker {
// If dockerUrl is set then it is used as docker url.
def dockerUrl = project.hasProperty('dockerUrl') ? project.property('dockerUrl') : null

// Check environment variables for DOCKER_HOST to use as docker url.
def dockerHost = System.env.DOCKER_HOST ? System.env.DOCKER_HOST.replace("tcp", "https") : null

// Set Docker host URL based on existence of environment
// variable DOCKER_HOST.
url = System.env.DOCKER_HOST ?
System.env.DOCKER_HOST.replace("tcp", "https") :
'unix:///var/run/docker.sock'
}
url = dockerUrl ?: dockerHost ?: 'unix:///var/run/docker.sock'

if (url.startsWith('https')) {
def dockerCertPath = project.hasProperty('docckerCertPath') ? project.property('dockerCertPath') : null

certPath = file(dockerCertPath ?: System.env.DOCKER_CERT_PATH)
}
}

import com.bmuschko.gradle.docker.tasks.image.Dockerfile
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
Expand Down

0 comments on commit c91e335

Please sign in to comment.