Skip to content

Commit 7b94fa3

Browse files
committed
debugReload implemented with upstream dependency checks
1 parent fdd5864 commit 7b94fa3

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

docker/build.gradle

+36-11
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ quickstart_configs.each { taskName, config ->
152152

153153
// Register all quickstart tasks
154154
quickstart_configs.each { taskName, config ->
155-
tasks.register("${taskName}BuildImages")
155+
tasks.register("${taskName}PrepareAll")
156156
}
157157

158158
quickstart_configs.each { taskName, config ->
159159
if (config.modules) {
160-
tasks.getByName("${taskName}BuildImages").dependsOn(
161-
config.modules.collect { it + ":${config.isDebug ? 'dockerTagDebug' : 'dockerTag'}" }
160+
tasks.getByName("${taskName}PrepareAll").dependsOn(
161+
config.modules.collect { it + ':dockerPrepare' }
162162
)
163163
}
164164
}
@@ -187,13 +187,38 @@ tasks.withType(ComposeUp).configureEach {
187187
}
188188

189189
task debugReload(type: Exec) {
190-
//TODO: Make these a set of tasks that depend on its dependency, making it a no-op if its dependency is up-to-date
191-
def cmd = ['docker compose -p datahub --profile debug'] + ['-f', compose_base] + [
192-
'restart',
193-
'datahub-gms-debug',
194-
'system-update-debug',
195-
'frontend-debug'
190+
//TODO: Generate *reloadTasks for all quickStart configs. Need to move the moduleToContainer to ext and define mappings for all containers.
191+
// Map of module paths to their corresponding container names
192+
def moduleToContainer = [
193+
':metadata-service:war': 'datahub-gms-debug',
194+
':datahub-upgrade': 'system-update-debug',
195+
':datahub-frontend': 'frontend-debug'
196196
]
197-
commandLine 'bash', '-c', cmd.join(" ")
198-
dependsOn project.tasks.named("quickstartDebugBuildImages")
197+
198+
doFirst {
199+
// Get all tasks that were executed as part of this build
200+
def executedTasks = project.gradle.taskGraph.allTasks.findAll { it.state.executed }
201+
202+
// Find which modules actually had work done
203+
def containersToRestart = []
204+
moduleToContainer.each { modulePath, containerName ->
205+
def moduleProject = project.project(modulePath)
206+
def dockerPrepareTask = moduleProject.tasks.findByName('dockerPrepare')
207+
208+
if (dockerPrepareTask && executedTasks.contains(dockerPrepareTask) && !dockerPrepareTask.state.upToDate) {
209+
containersToRestart << containerName
210+
}
211+
}
212+
213+
// Only restart containers that had their modules rebuilt
214+
if (containersToRestart) {
215+
def cmd = ['docker compose -p datahub --profile debug'] + ['-f', compose_base] + ['restart'] + containersToRestart
216+
commandLine 'bash', '-c', cmd.join(" ")
217+
} else {
218+
// If no containers need restart, make this a no-op
219+
commandLine 'bash', '-c', 'echo "No containers need restarting - all modules are up to date"'
220+
}
221+
}
222+
223+
dependsOn tasks.named("quickstartDebugPrepareAll")
199224
}

0 commit comments

Comments
 (0)