Skip to content

Commit c9c9b5f

Browse files
authored
Merge pull request #57 from avast/CustomProjectName
Allow set project name
2 parents 3060a7c + 32bed0f commit c9c9b5f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ dockerCompose {
5050
// removeContainers = false
5151
// removeImages = "None" // Other accepted values are: "All" and "Local"
5252
// removeVolumes = false
53+
// projectName = 'my-project' // allow to set custom docker-compose project name (defaults to directory name)
5354
// environment.put 'BACKEND_ADDRESS', '192.168.1.100' // Pass environment variable to 'docker-compose' for substitution in compose file
5455
}
5556

src/main/groovy/com/avast/gradle/dockercompose/ComposeExtension.groovy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class ComposeExtension {
2626
Duration waitAfterHealthyStateProbeFailure = Duration.ofSeconds(5)
2727
Duration waitForHealthyStateTimeout = Duration.ofMinutes(15)
2828
List<String> useComposeFiles = []
29+
String projectName = null
2930

3031
boolean stopContainers = true
3132
boolean removeContainers = true
@@ -74,12 +75,15 @@ class ComposeExtension {
7475
}
7576

7677
/**
77-
* Composes docker-compose command, mainly adds '-f' options when `useComposeFiles` is set.
78+
* Composes docker-compose command, mainly adds '-f' and '-p' options.
7879
*/
7980
@PackageScope
8081
Iterable<String> composeCommand(String... args) {
8182
def res = ['docker-compose']
8283
res.addAll(useComposeFiles.collectMany { ['-f', it] })
84+
if (projectName) {
85+
res.addAll(['-p', projectName])
86+
}
8387
res.addAll(args)
8488
res
8589
}

0 commit comments

Comments
 (0)