Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

adapt build to build docker image on linux (without docker machine)

mhallineb0d9153e8f1
diff --git a/build.gradle b/build.gradle
index d18e94827..d2c257d37 100644
--- a/build.gradle
+++ b/build.gradle
@@ -36,15 +36,39 @@ allprojects {
apply plugin: "com.bmuschko.docker-remote-api"
docker {
- url = "$System.env.DOCKER_HOST".replace("tcp:", "https:")
- certPath = new File("$System.env.DOCKER_CERT_PATH")
+ url = dockerHostUrl()
+ certPath = dockerCertPath()
registryCredentials {
username = project.properties.dockerHubUsername
password = project.properties.dockerHubPassword
}
}
+
ext.dockerImageName = "$dockerRepository/$project.name:$imageVersion".toLowerCase(Locale.ROOT)
apply plugin: 'eclipse'
}
+
+URI dockerHostEnv() {
+ String uri = System.getenv('DOCKER_HOST')
+ uri ? new URI(uri) : null
+}
+
+String dockerHostUrl() {
+ if (dockerHostEnv()) {
+ URI uri = dockerHostEnv()
+ if (uri.scheme == 'unix') {
+ uri
+ } else if (uri.scheme == 'tcp') {
+ (new URI(uri.scheme != 'tcp' ?: 'https' , uri.userInfo, uri.host, uri.port, uri.path, uri.query, uri.fragment)).toString()
+ }
+ } else {
+ org.gradle.internal.os.OperatingSystem.current().isLinux() ? 'unix:///var/run/docker.sock' : 'http://localhost:2375'
+ }
+}
+
+File dockerCertPath() {
+ String certPathEnv = System.getenv('DOCKER_CERT_PATH')
+ certPathEnv ? file(certPathEnv) : null;
+}