-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
38 lines (32 loc) · 1.31 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
plugins {
id 'base'
id 'com.palantir.docker' version '0.31.0'
id 'com.palantir.docker-run' version '0.31.0'
id 'pl.allegro.tech.build.axion-release' version '1.13.6'
}
project.version = scmVersion.version
docker {
name "${project.name}:${project.version}"
files "plugins.txt", "seedJob.xml"
}
Process process
if (DefaultNativePlatform.getCurrentOperatingSystem().isWindows()) {
process = "docker run --rm -v /var/run/docker.sock:/var/run/docker.sock alpine stat -c %g /var/run/docker.sock".execute()
} else if (DefaultNativePlatform.getCurrentOperatingSystem().isLinux()) {
process = "stat -c %g /var/run/docker.sock".execute()
} else {
throw new GradleException("Unsupported operating system. No way to find group of /var/run/docker.sock.")
}
def out = new ByteArrayOutputStream()
process.waitForProcessOutput(out, System.err)
String dockerSockGroupId = out.toString().trim()
String extraPrefix = DefaultNativePlatform.getCurrentOperatingSystem().isWindows() ? '/' : ''
dockerRun {
name "${project.name}"
image "${project.name}:${project.version}"
ports '8080:8080'
clean true
daemonize false
arguments '-v', "$extraPrefix/var/run/docker.sock:/var/run/docker.sock", '--group-add', dockerSockGroupId
}