You can define multiple independent Docker Compose setups within a single project using nested configurations. This allows you to have different sets of tasks (e.g., myNestedComposeUp, myNestedComposeDown) for different environments or test types.
Groovy DSL Syntax:
dockerCompose {
myNested {
useComposeFiles = ['docker-compose-for-integration-tests.yml']
isRequiredBy(project.tasks.myTask)
}
}
Kotlin DSL Syntax:
configure<ComposeExtension> {
createNested("local").apply {
setProjectName("foo")
// ... other settings
}
}
When using nested configurations, the nested settings inherit from the main dockerCompose block, except for: projectName, startedServices, useComposeFiles, scale, captureContainersOutputToFile, captureContainersOutputToFiles, composeLogToFile, containerLogToDir, and pushServices.