-
Notifications
You must be signed in to change notification settings - Fork 31
/
client-ui.gradle
78 lines (62 loc) · 2.59 KB
/
client-ui.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
plugins {
id 'com.bmuschko.docker-remote-api'
}
import com.bmuschko.gradle.docker.tasks.container.DockerCopyFileFromContainer
import com.bmuschko.gradle.docker.tasks.container.DockerCreateContainer
import com.bmuschko.gradle.docker.tasks.container.DockerRemoveContainer
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
def syncSourcesLocation = "${buildDir}/src"
task syncSources(type: Sync) {
from "${projectDir}"
into syncSourcesLocation
// Note: we are explicitly choosing to sync the clean sources into a build directory to ensure
// that the context we use for caching the dockerBuild task is correct and has as minimal
// surface area as possible. Otherwise, web devs who like to build using npm locally will be
// creating a lot of extra noise that will cause dockerBuild task to run much slower than it
// could otherwise.
// Unfortunately, there doesn't seem to be a good / universal way to exclude the patterns from
// our existing .dockerignore.
exclude "**/node_modules"
exclude "**/dist"
exclude "**/build"
}
task dockerTest(type: DockerBuildImage) {
dependsOn syncSources
onlyIf { TestTools.shouldRunTests(project) }
inputDir.set(file(syncSourcesLocation))
target.set('test')
}
task dockerBuild(type: DockerBuildImage) {
dependsOn syncSources
inputDir.set(file(syncSourcesLocation))
target.set('build')
//buildArgs.put('DEEPHAVEN_VERSION', "${project.version}")
images.add('deephaven/iriside')
}
def dockerContainerName = "client-ui-container-${UUID.randomUUID()}"
def dockerCopyLocation = "${buildDir}/iriside"
task dockerCreateContainer(type: DockerCreateContainer) {
dependsOn dockerBuild
targetImageId dockerBuild.getImageId()
containerName.set(dockerContainerName)
}
task dockerRemoveContainer(type: DockerRemoveContainer) {
dependsOn dockerCreateContainer
targetContainerId dockerCreateContainer.getContainerId()
}
task ideClient(type: DockerCopyFileFromContainer) {
// note: we could try to be smarter and cache these create/remove tasks
dependsOn dockerCreateContainer
finalizedBy dockerRemoveContainer
inputs.property("imageId", dockerBuild.imageId)
outputs.dir(dockerCopyLocation)
targetContainerId dockerCreateContainer.getContainerId()
remotePath.set('/usr/src/app/packages/app/build')
hostPath.set(dockerCopyLocation)
doFirst {
// we must manually delete this first, since docker cp will error if trying to overwrite
delete(dockerCopyLocation)
}
}
check.dependsOn dockerTest
(tasks.getByName('clean') as Delete).delete('node_modules')