Skip to content

Commit

Permalink
Merge pull request #23 from mrashisha/master
Browse files Browse the repository at this point in the history
Fixes #11: Updated removeImages to support local
  • Loading branch information
augi committed Jun 5, 2016
2 parents c870300 + 09e0946 commit 84ec061
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,8 @@ com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties

# Eclipse
.settings/
.classpath
.project
/bin/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dockerCompose {
// useComposeFiles = ['docker-compose.yml', 'docker-compose.prod.yml'] // like 'docker-compose -f <file>'
// stopContainers = false // useful for debugging
// removeContainers = false
// removeImages = true
// removeImages = "None" // Other accepted values are: "All" and "Local"
// removeVolumes = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ComposeExtension {

boolean stopContainers = true
boolean removeContainers = true
boolean removeImages = false
RemoveImages removeImages = RemoveImages.None
boolean removeVolumes = true

ComposeExtension(Project project, ComposeUp upTask, ComposeDown downTask) {
Expand Down Expand Up @@ -72,3 +72,9 @@ class ComposeExtension {
res
}
}

enum RemoveImages {
None,
Local, // images that don't have a custom name set by the `image` field
All
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.avast.gradle.dockercompose.tasks

import com.avast.gradle.dockercompose.ComposeExtension
import com.avast.gradle.dockercompose.RemoveImages
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction
import org.gradle.process.ExecSpec
Expand All @@ -23,8 +24,13 @@ class ComposeDown extends DefaultTask {
if (extension.removeContainers) {
if (getDockerComposeVersion() >= VersionNumber.parse('1.6.0')) {
String[] args = ['down']
if(extension.removeImages) {
args += ['--rmi', 'all']
switch (extension.removeImages) {
case RemoveImages.All:
case RemoveImages.Local:
args += ['--rmi', "${extension.removeImages}".toLowerCase()]
break
default:
break
}
if(extension.removeVolumes) {
args += ['--volumes']
Expand Down

0 comments on commit 84ec061

Please sign in to comment.