You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2019/12/05 15:19:07 UTC

[whimsy] branch master updated: add docker --prune option; don't start daemons on --update-all

This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new b9382f7  add docker --prune option; don't start daemons on --update-all
b9382f7 is described below

commit b9382f7b0f74e831d9518a17ab302153af18818d
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Thu Dec 5 10:18:20 2019 -0500

    add docker --prune option; don't start daemons on --update-all
---
 SETUPMYMAC.md     |  2 +-
 config/setupmymac | 30 +++++++++++++++++++++++-------
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/SETUPMYMAC.md b/SETUPMYMAC.md
index a4b409f..559cd3f 100644
--- a/SETUPMYMAC.md
+++ b/SETUPMYMAC.md
@@ -43,7 +43,7 @@ Once you have both configurations set up running this command again will change
 permissions on a few files, but generally will leave everything else is the
 same.  If you want to update more (say, to get a new version of `passenger`),
 there are options to do that, enter `whimsy/config/setupmymac --help` for
-details.  Pass `-all` to update everything.
+details.  Pass `--update-all` to update everything.
 
 If you want to know what is going on under the covers with the setupmymac
 scripts, visit either the [macOS](./MACOSX.md) or [Docker](./DOCKER.md)
diff --git a/config/setupmymac b/config/setupmymac
index db03f34..4b1a916 100755
--- a/config/setupmymac
+++ b/config/setupmymac
@@ -34,7 +34,7 @@ $dry_run = false
 restart_apache = false
 $brew_updated = false
 
-force = {clean: false}
+force = {clean: false, prune: false, toucher: false, ws: false}
 force[:svn] = true unless Dir.exists? '/srv/svn'
 force[:git] = true unless Dir.exists? '/srv/git'
 
@@ -135,6 +135,14 @@ OptionParser.new do |opts|
     force[:minutes] = opt
   end
 
+  opts.on('--update-all', '--all', "Update and launch everything") do |opt|
+    force.default = true
+  end
+
+  opts.on('--[no-]clean', "Clean up source directory") do |opt|
+    force[:clean] = opt
+  end
+
   opts.on('--[no-]toucher', "Restart rack applications on source change") do |opt|
     force[:toucher] = opt
   end
@@ -143,12 +151,8 @@ OptionParser.new do |opts|
     force[:ws] = opt
   end
 
-  opts.on('--all', "Update and launch everything") do |opt|
-    force.default = true
-  end
-
-  opts.on('--[no-]clean', "Clean up source directory") do |opt|
-    force[:clean] = opt
+  opts.on('--[no-]prune', "Prune docker containers and images") do |opt|
+    force[:prune] = opt
   end
 
   opts.on('--dry-run', "Only indicate what commands would be run") do |opt|
@@ -288,6 +292,18 @@ end
 
 ### Docker installation
 
+if force[:prune]
+  Dir.chdir 'docker' do
+    `docker-compose ps -q`.lines.each do |line|
+      run 'docker', 'stop', line.chomp
+    end
+  end
+
+  run 'docker', 'container', 'prune', '--force'
+  run 'docker', 'imagea', 'prune', '--force'
+  exit
+end
+
 if option == :docker
   if not Dir.exist? '/Applications/Docker.app'
     brew 'cask', 'install', 'docker'