shiplane_deployers_capistrano_docker 0.2.24 → 0.2.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e51aa42405333bab8f619f5f551707ee4edf6d106ed7832df8731670f692d333
4
- data.tar.gz: 7bf1e245f021935bb7db1f3ef37a660b74ee43edd390f62b0d107703d75f5b0d
3
+ metadata.gz: a9594fa7bcaf039459fc10accab4f55abf669857fd735cd7ea1fdd35dcd8115a
4
+ data.tar.gz: e16d7407b7eb4857f0116e8e34cb3d1be0b380ffd936bdb8e33b03e37b2a1252
5
5
  SHA512:
6
- metadata.gz: 5fcf8231052b9d201b0ef516aaf19d953ae092d50224ee5c22ba832c8f9e8f4f40f17c42c46ff56bc72add1f922c7143a4dc7197835e0cb8699da19df53ef34e
7
- data.tar.gz: 7385c9ba8399d1ac6e7a510011ae3ace58f0a849faf77f0a882e94a181f7025d3332e34bfc5e1c0b371669b9ab94f4ce04daae5c7f3d69be99a14a8c652592c8
6
+ metadata.gz: bd52b61de9281bb8eaddef0b2ea321168361ca104e1ffb05b8e58cc2703b444b1c854e092a8b1fe626b283357728f43d7bfa70d2a17d5077817e0b1ff0098c73
7
+ data.tar.gz: 230a3613adb6cded45119c178f657b55d5147e6531ea1e20ec8577e38daae9dba2e2eb31e1e7d60fd24b92754505cf59947d135aa8daf8256b1df9df33d620e0
@@ -46,7 +46,7 @@ namespace :shiplane do
46
46
  end
47
47
 
48
48
  desc "Deploy the current branch to production via its docker container"
49
- task deploy: [:instantiate_shiplane_environment, :create_networks, :download_container, :stop_old_containers, :remove_conflicting_containers] do
49
+ task deploy: [:instantiate_shiplane_environment, :create_networks, :download_container, :stop_old_containers, :remove_conflicting_containers, :cleanup_old_releases] do
50
50
  fetch(:shiplane_container_configurations).each do |name, config|
51
51
  roles = roles(config.fetch(:capistrano_role, :all)).map{|role| Shiplane::Host.new(role, env) }
52
52
  roles.each do |role|
@@ -84,4 +84,30 @@ namespace :shiplane do
84
84
  end
85
85
  end
86
86
  end
87
+
88
+ task :cleanup_old_releases do
89
+ all_roles = {}
90
+
91
+ fetch(:shiplane_container_configurations).each do |name, config|
92
+ roles = roles(config.fetch(:capistrano_role, :all)).map{|role| Shiplane::Host.new(role, env) }
93
+
94
+ roles.each do |role|
95
+ all_roles[role] = config.docker_command(role)
96
+ on role.capistrano_role do
97
+ container_ids_to_keep = capture("#{config.docker_command(role)} container ls -aq --filter name=#{config.container_name} -n #{config.env.fetch(:keep_releases, 5)}").split("\n")
98
+ all_container_ids = capture("#{config.docker_command(role)} container ls -aq --filter name=#{config.container_name}").split("\n")
99
+
100
+ (all_container_ids - container_ids_to_keep).each do |container_id|
101
+ execute "#{config.docker_command(role)} rm #{container_id}"
102
+ end
103
+ end
104
+ end
105
+ end
106
+
107
+ all_roles.keys.each do |role|
108
+ on role.capistrano_role do
109
+ execute "#{all_roles[role]} image prune -fa"
110
+ end
111
+ end
112
+ end
87
113
  end
@@ -3,7 +3,7 @@
3
3
  module Shiplane
4
4
  module Deployers
5
5
  module CapistranoDocker
6
- VERSION = "0.2.24"
6
+ VERSION = "0.2.25"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shiplane_deployers_capistrano_docker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.24
4
+ version: 0.2.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Epperson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-18 00:00:00.000000000 Z
11
+ date: 2022-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano