firespring_dev_commands 3.1.6.pre.alpha.1 → 3.1.6.pre.alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/firespring_dev_commands/docker.rb +16 -0
- data/lib/firespring_dev_commands/templates/docker/application.rb +0 -18
- data/lib/firespring_dev_commands/templates/docker/node/application.rb +20 -1
- data/lib/firespring_dev_commands/templates/docker/php/application.rb +20 -1
- data/lib/firespring_dev_commands/templates/docker/ruby/application.rb +20 -1
- data/lib/firespring_dev_commands/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92230376b44b914a2e4f5f1cbc0ccd76e44356e7acd7dd91402598cb945bad4f
|
4
|
+
data.tar.gz: 1c1159f881470ea08ed64bbd95f144a34ce01c958dfe04814592d1238e8e7b6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 111ff6f71498547adc5e7d477ca9970fa4289de65dc047fdfc693123be82ea90fc5baa7139cf2d2ad4155cba5bebf77e480fd98cd9fc106e046a91cf4a8f3a53
|
7
|
+
data.tar.gz: 35ae0cbe8edf002fb3fa77301ae91e0db61191855ee85f29f6edb3eec98c524746d231bfa8912ef4702df066a801f2211219da89f5c57ff243e9b0af8553f462
|
@@ -94,6 +94,22 @@ module Dev
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
+
def stop_project_containers(project_name:)
|
98
|
+
project_name = project_name.to_s.strip
|
99
|
+
raise 'No project name defined' if project_name.empty?
|
100
|
+
|
101
|
+
::Docker::Container.all(filters: {status: %w(restarting running)}.to_json).each do |container|
|
102
|
+
next unless container.info&.dig('Names')&.map { |name| name.split('/').last }&.any? { |it| it.start_with?(project_name) }
|
103
|
+
|
104
|
+
begin
|
105
|
+
container.stop
|
106
|
+
LOG.info "Stopped container #{container.id[0, 12]}"
|
107
|
+
rescue => e
|
108
|
+
LOG.error "Error stopping container #{contianer.id[0, 12]}: #{e}"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
97
113
|
# Prunes/removes all unused images
|
98
114
|
def prune_images
|
99
115
|
_prune('images')
|
@@ -118,24 +118,6 @@ module Dev
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
-
# Create the rake task which runs a docker compose exec bash for the application name
|
122
|
-
def create_sh_empty_task!
|
123
|
-
application = @name
|
124
|
-
exclude = @exclude
|
125
|
-
|
126
|
-
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
127
|
-
namespace application do
|
128
|
-
return if exclude.include?(:sh_empty)
|
129
|
-
|
130
|
-
desc "Open a shell into an empty #{application} container"
|
131
|
-
task sh_empty: %W(init_docker #{application}:up_empty_no_deps _pre_sh_hooks) do
|
132
|
-
Dev::Docker::Compose.new(services: [application]).sh
|
133
|
-
Rake::Task[:_post_sh_hooks].execute
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
121
|
# Create the rake task which runs a docker compose logs for the application name
|
140
122
|
def create_logs_task!
|
141
123
|
application = @name
|
@@ -106,7 +106,8 @@ module Dev
|
|
106
106
|
node = @node
|
107
107
|
exclude = @exclude
|
108
108
|
test_isolation = @test_isolation
|
109
|
-
|
109
|
+
up_prefix = @test_isolation ? :up_empty : :up # NOTE: This should maybe be it's own variable at some point?
|
110
|
+
up_cmd = @start_container_dependencies_on_test ? :"#{up_prefix}" : :"#{up_prefix}_no_deps"
|
110
111
|
test_artifacts = @test_artifacts
|
111
112
|
return if exclude.include?(:test)
|
112
113
|
|
@@ -145,10 +146,28 @@ module Dev
|
|
145
146
|
ensure
|
146
147
|
# Clean up resources if we are on an isolated project name
|
147
148
|
if test_isolation
|
149
|
+
# Need to call stop before down because other the "run" containers aren't stopped
|
150
|
+
Dev::Docker.new.stop_project_containers(project_name: Dev::Docker::Compose.config.project_name)
|
148
151
|
Dev::Docker::Compose.new.down
|
149
152
|
Dev::Docker.new.prune_project_volumes(project_name: Dev::Docker::Compose.config.project_name)
|
150
153
|
end
|
151
154
|
end
|
155
|
+
|
156
|
+
# If using test isolation then give users a way to 'sh' into the isolated container
|
157
|
+
if test_isolation
|
158
|
+
namespace :test do
|
159
|
+
desc "Open a shell into a test #{application} container"
|
160
|
+
task sh: %W(test_init_docker #{up_cmd} _pre_sh_hooks) do
|
161
|
+
Dev::Docker::Compose.new(services: @default_service).sh
|
162
|
+
Rake::Task[:_post_sh_hooks].execute
|
163
|
+
ensure
|
164
|
+
# Need to call stop before down because other the "run" containers aren't stopped
|
165
|
+
Dev::Docker.new.stop_project_containers(project_name: Dev::Docker::Compose.config.project_name)
|
166
|
+
Dev::Docker::Compose.new.down
|
167
|
+
Dev::Docker.new.prune_project_volumes(project_name: Dev::Docker::Compose.config.project_name)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
152
171
|
end
|
153
172
|
end
|
154
173
|
end
|
@@ -151,7 +151,8 @@ module Dev
|
|
151
151
|
php = @php
|
152
152
|
exclude = @exclude
|
153
153
|
test_isolation = @test_isolation
|
154
|
-
|
154
|
+
up_prefix = @test_isolation ? :up_empty : :up # NOTE: This should maybe be it's own variable at some point?
|
155
|
+
up_cmd = @start_container_dependencies_on_test ? :"#{up_prefix}" : :"#{up_prefix}_no_deps"
|
155
156
|
test_artifacts = @test_artifacts
|
156
157
|
return if exclude.include?(:test)
|
157
158
|
|
@@ -190,10 +191,28 @@ module Dev
|
|
190
191
|
ensure
|
191
192
|
# Clean up resources if we are on an isolated project name
|
192
193
|
if test_isolation
|
194
|
+
# Need to call stop before down because other the "run" containers aren't stopped
|
195
|
+
Dev::Docker.new.stop_project_containers(project_name: Dev::Docker::Compose.config.project_name)
|
193
196
|
Dev::Docker::Compose.new.down
|
194
197
|
Dev::Docker.new.prune_project_volumes(project_name: Dev::Docker::Compose.config.project_name)
|
195
198
|
end
|
196
199
|
end
|
200
|
+
|
201
|
+
# If using test isolation then give users a way to 'sh' into the isolated container
|
202
|
+
if test_isolation
|
203
|
+
namespace :test do
|
204
|
+
desc "Open a shell into a test #{application} container"
|
205
|
+
task sh: %W(test_init_docker #{up_cmd} _pre_sh_hooks) do
|
206
|
+
Dev::Docker::Compose.new(services: @default_service).sh
|
207
|
+
Rake::Task[:_post_sh_hooks].execute
|
208
|
+
ensure
|
209
|
+
# Need to call stop before down because other the "run" containers aren't stopped
|
210
|
+
Dev::Docker.new.stop_project_containers(project_name: Dev::Docker::Compose.config.project_name)
|
211
|
+
Dev::Docker::Compose.new.down
|
212
|
+
Dev::Docker.new.prune_project_volumes(project_name: Dev::Docker::Compose.config.project_name)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
197
216
|
end
|
198
217
|
end
|
199
218
|
end
|
@@ -107,7 +107,8 @@ module Dev
|
|
107
107
|
ruby = @ruby
|
108
108
|
exclude = @exclude
|
109
109
|
test_isolation = @test_isolation
|
110
|
-
|
110
|
+
up_prefix = @test_isolation ? :up_empty : :up # NOTE: This should maybe be it's own variable at some point?
|
111
|
+
up_cmd = @start_container_dependencies_on_test ? :"#{up_prefix}" : :"#{up_prefix}_no_deps"
|
111
112
|
test_artifacts = @test_artifacts
|
112
113
|
return if exclude.include?(:test)
|
113
114
|
|
@@ -145,10 +146,28 @@ module Dev
|
|
145
146
|
ensure
|
146
147
|
# Clean up resources if we are on an isolated project name
|
147
148
|
if test_isolation
|
149
|
+
# Need to call stop before down because other the "run" containers aren't stopped
|
150
|
+
Dev::Docker.new.stop_project_containers(project_name: Dev::Docker::Compose.config.project_name)
|
148
151
|
Dev::Docker::Compose.new.down
|
149
152
|
Dev::Docker.new.prune_project_volumes(project_name: Dev::Docker::Compose.config.project_name)
|
150
153
|
end
|
151
154
|
end
|
155
|
+
|
156
|
+
# If using test isolation then give users a way to 'sh' into the isolated container
|
157
|
+
if test_isolation
|
158
|
+
namespace :test do
|
159
|
+
desc "Open a shell into a test #{application} container"
|
160
|
+
task sh: %W(test_init_docker #{up_cmd} _pre_sh_hooks) do
|
161
|
+
Dev::Docker::Compose.new(services: @default_service).sh
|
162
|
+
Rake::Task[:_post_sh_hooks].execute
|
163
|
+
ensure
|
164
|
+
# Need to call stop before down because other the "run" containers aren't stopped
|
165
|
+
Dev::Docker.new.stop_project_containers(project_name: Dev::Docker::Compose.config.project_name)
|
166
|
+
Dev::Docker::Compose.new.down
|
167
|
+
Dev::Docker.new.prune_project_volumes(project_name: Dev::Docker::Compose.config.project_name)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
152
171
|
end
|
153
172
|
end
|
154
173
|
end
|