indocker 0.0.2 → 0.0.5
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/Gemfile.lock +42 -6
- data/bin/indocker +1 -1
- data/indocker.gemspec +4 -0
- data/lib/indocker/application_initializer.rb +1 -12
- data/lib/indocker/cli.rb +10 -0
- data/lib/indocker/configs/config.rb +93 -22
- data/lib/indocker/configs/config_factory.rb +17 -16
- data/lib/indocker/configs/config_initializer.rb +9 -0
- data/lib/indocker/container/container_builder.rb +29 -0
- data/lib/indocker/{directives → container}/container_directives_runner.rb +8 -0
- data/lib/indocker/container/container_dsl.rb +26 -3
- data/lib/indocker/container/container_inspector.rb +26 -0
- data/lib/indocker/container/container_manager.rb +43 -32
- data/lib/indocker/container/container_metadata.rb +31 -26
- data/lib/indocker/container/container_metadata_factory.rb +5 -2
- data/lib/indocker/directives/base.rb +6 -10
- data/lib/indocker/directives/container_directives/base.rb +4 -0
- data/lib/indocker/directives/container_directives/cmd.rb +7 -0
- data/lib/indocker/directives/container_directives/env.rb +7 -0
- data/lib/indocker/directives/container_directives/env_file.rb +3 -3
- data/lib/indocker/directives/container_directives/from.rb +4 -2
- data/lib/indocker/directives/container_directives/ports.rb +11 -4
- data/lib/indocker/directives/container_directives/volume.rb +23 -0
- data/lib/indocker/directives/{docker_directives → image_directives}/base.rb +13 -1
- data/lib/indocker/directives/{docker_directives → image_directives}/cmd.rb +5 -1
- data/lib/indocker/directives/image_directives/copy.rb +32 -0
- data/lib/indocker/directives/{prepare_directives → image_directives}/docker_cp.rb +5 -1
- data/lib/indocker/directives/{docker_directives → image_directives}/entrypoint.rb +5 -1
- data/lib/indocker/directives/image_directives/env.rb +9 -0
- data/lib/indocker/directives/image_directives/env_file.rb +19 -0
- data/lib/indocker/directives/image_directives/expose.rb +9 -0
- data/lib/indocker/directives/image_directives/from.rb +36 -0
- data/lib/indocker/directives/image_directives/registry.rb +30 -0
- data/lib/indocker/directives/image_directives/run.rb +17 -0
- data/lib/indocker/directives/image_directives/workdir.rb +9 -0
- data/lib/indocker/directives/partial.rb +9 -1
- data/lib/indocker/docker_api/container_config.rb +121 -0
- data/lib/indocker/{docker_api.rb → docker_api/docker_api.rb} +79 -52
- data/lib/indocker/dsl_context.rb +4 -0
- data/lib/indocker/envs/env_metadata.rb +4 -0
- data/lib/indocker/errors.rb +5 -1
- data/lib/indocker/git/git_api.rb +32 -0
- data/lib/indocker/git/git_helper.rb +34 -0
- data/lib/indocker/git/git_service.rb +21 -0
- data/lib/indocker/handlers/{run_container.rb → container_run.rb} +4 -13
- data/lib/indocker/handlers/container_stop.rb +17 -0
- data/lib/indocker/handlers/performable.rb +22 -0
- data/lib/indocker/image/image_builder.rb +22 -7
- data/lib/indocker/image/image_dependencies_manager.rb +13 -9
- data/lib/indocker/image/image_directives_runner.rb +99 -0
- data/lib/indocker/image/image_dockerfile_builder.rb +24 -0
- data/lib/indocker/image/image_dsl.rb +38 -18
- data/lib/indocker/image/image_evaluator.rb +1 -1
- data/lib/indocker/image/image_helper.rb +9 -0
- data/lib/indocker/image/image_metadata.rb +9 -9
- data/lib/indocker/image/image_metadata_factory.rb +11 -10
- data/lib/indocker/image/image_metadata_repository.rb +8 -9
- data/lib/indocker/registry/registry_api.rb +46 -0
- data/lib/indocker/registry/registry_helper.rb +20 -0
- data/lib/indocker/registry/registry_service.rb +28 -0
- data/lib/indocker/utils/logger_factory.rb +1 -0
- data/lib/indocker/utils/registry_authenticator.rb +5 -5
- data/lib/indocker/utils/tar_helper.rb +5 -5
- data/lib/indocker/version.rb +1 -1
- data/lib/indocker/volumes/volume_metadata.rb +9 -0
- data/lib/indocker/volumes/volume_metadata_factory.rb +9 -0
- data/lib/indocker/volumes/volume_metadata_repository.rb +34 -0
- data/lib/indocker.rb +56 -27
- data/spec/example/.indocker/config.rb +14 -7
- data/spec/fixtures/spec.env +2 -0
- data/spec/indocker/configs/config_spec.rb +52 -1
- data/spec/indocker/container/container_builder_spec.rb +67 -0
- data/spec/indocker/container/container_manager_spec.rb +177 -129
- data/spec/indocker/docker_api/container_config_spec.rb +64 -0
- data/spec/indocker/{utils → docker_api}/docker_api_spec.rb +38 -13
- data/spec/indocker/handlers/container_run_spec.rb +60 -0
- data/spec/indocker/image/image_builder_spec.rb +64 -26
- data/spec/indocker/image/image_directives_runner_spec.rb +141 -0
- data/spec/indocker/image/image_dockerfile_builder_spec.rb +25 -0
- data/spec/indocker/image/image_evaluator_spec.rb +29 -9
- data/spec/spec_helper.rb +38 -16
- metadata +108 -32
- data/lib/indocker/directives/docker_directives/copy.rb +0 -27
- data/lib/indocker/directives/docker_directives/env.rb +0 -5
- data/lib/indocker/directives/docker_directives/from.rb +0 -30
- data/lib/indocker/directives/docker_directives/run.rb +0 -5
- data/lib/indocker/directives/docker_directives/workdir.rb +0 -5
- data/lib/indocker/directives/image_directives_runner.rb +0 -120
- data/lib/indocker/directives/prepare_directives/base.rb +0 -6
- data/lib/indocker/envs/manager.rb +0 -30
- data/lib/indocker/handlers/base.rb +0 -13
- data/spec/indocker/directives/image_directives_runner_spec.rb +0 -121
- data/spec/indocker/handlers/run_container_spec.rb +0 -107
- data/spec/tmp/indocker_list_container_files/deeper/example3.txt +0 -1
- data/spec/tmp/indocker_list_container_files/deeper/example4.txt +0 -1
- data/spec/tmp/indocker_list_container_files/example1.txt +0 -1
- data/spec/tmp/indocker_list_container_files/example2.txt +0 -1
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: indocker
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Droid Labs
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-11-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: byebug
|
|
@@ -24,6 +24,20 @@ dependencies:
|
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rspec
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
27
41
|
- !ruby/object:Gem::Dependency
|
|
28
42
|
name: smart_ioc
|
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -52,6 +66,20 @@ dependencies:
|
|
|
52
66
|
- - ">="
|
|
53
67
|
- !ruby/object:Gem::Version
|
|
54
68
|
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: docker_registry2
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
55
83
|
- !ruby/object:Gem::Dependency
|
|
56
84
|
name: thor
|
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -80,6 +108,34 @@ dependencies:
|
|
|
80
108
|
- - ">="
|
|
81
109
|
- !ruby/object:Gem::Version
|
|
82
110
|
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: git
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: byebug
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
type: :runtime
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0'
|
|
83
139
|
description: DSL for build, run and deploy docker containers
|
|
84
140
|
email: hello@droidlabs.pro
|
|
85
141
|
executables:
|
|
@@ -100,47 +156,61 @@ files:
|
|
|
100
156
|
- lib/indocker/cli.rb
|
|
101
157
|
- lib/indocker/configs/config.rb
|
|
102
158
|
- lib/indocker/configs/config_factory.rb
|
|
159
|
+
- lib/indocker/configs/config_initializer.rb
|
|
103
160
|
- lib/indocker/configs/locator.rb
|
|
161
|
+
- lib/indocker/container/container_builder.rb
|
|
162
|
+
- lib/indocker/container/container_directives_runner.rb
|
|
104
163
|
- lib/indocker/container/container_dsl.rb
|
|
105
164
|
- lib/indocker/container/container_evaluator.rb
|
|
165
|
+
- lib/indocker/container/container_inspector.rb
|
|
106
166
|
- lib/indocker/container/container_manager.rb
|
|
107
167
|
- lib/indocker/container/container_metadata.rb
|
|
108
168
|
- lib/indocker/container/container_metadata_factory.rb
|
|
109
169
|
- lib/indocker/container/container_metadata_repository.rb
|
|
110
170
|
- lib/indocker/directives/base.rb
|
|
111
171
|
- lib/indocker/directives/container_directives/base.rb
|
|
172
|
+
- lib/indocker/directives/container_directives/cmd.rb
|
|
112
173
|
- lib/indocker/directives/container_directives/depends_on.rb
|
|
174
|
+
- lib/indocker/directives/container_directives/env.rb
|
|
113
175
|
- lib/indocker/directives/container_directives/env_file.rb
|
|
114
176
|
- lib/indocker/directives/container_directives/expose.rb
|
|
115
177
|
- lib/indocker/directives/container_directives/from.rb
|
|
116
178
|
- lib/indocker/directives/container_directives/network.rb
|
|
117
179
|
- lib/indocker/directives/container_directives/ports.rb
|
|
118
180
|
- lib/indocker/directives/container_directives/ready.rb
|
|
119
|
-
- lib/indocker/directives/
|
|
120
|
-
- lib/indocker/directives/
|
|
121
|
-
- lib/indocker/directives/
|
|
122
|
-
- lib/indocker/directives/
|
|
123
|
-
- lib/indocker/directives/
|
|
124
|
-
- lib/indocker/directives/
|
|
125
|
-
- lib/indocker/directives/
|
|
126
|
-
- lib/indocker/directives/
|
|
127
|
-
- lib/indocker/directives/
|
|
128
|
-
- lib/indocker/directives/
|
|
181
|
+
- lib/indocker/directives/container_directives/volume.rb
|
|
182
|
+
- lib/indocker/directives/image_directives/base.rb
|
|
183
|
+
- lib/indocker/directives/image_directives/cmd.rb
|
|
184
|
+
- lib/indocker/directives/image_directives/copy.rb
|
|
185
|
+
- lib/indocker/directives/image_directives/docker_cp.rb
|
|
186
|
+
- lib/indocker/directives/image_directives/entrypoint.rb
|
|
187
|
+
- lib/indocker/directives/image_directives/env.rb
|
|
188
|
+
- lib/indocker/directives/image_directives/env_file.rb
|
|
189
|
+
- lib/indocker/directives/image_directives/expose.rb
|
|
190
|
+
- lib/indocker/directives/image_directives/from.rb
|
|
191
|
+
- lib/indocker/directives/image_directives/registry.rb
|
|
192
|
+
- lib/indocker/directives/image_directives/run.rb
|
|
193
|
+
- lib/indocker/directives/image_directives/workdir.rb
|
|
129
194
|
- lib/indocker/directives/partial.rb
|
|
130
|
-
- lib/indocker/
|
|
131
|
-
- lib/indocker/
|
|
132
|
-
- lib/indocker/docker_api.rb
|
|
195
|
+
- lib/indocker/docker_api/container_config.rb
|
|
196
|
+
- lib/indocker/docker_api/docker_api.rb
|
|
133
197
|
- lib/indocker/dsl_context.rb
|
|
134
198
|
- lib/indocker/envs/env_metadata.rb
|
|
135
199
|
- lib/indocker/envs/loader.rb
|
|
136
|
-
- lib/indocker/envs/manager.rb
|
|
137
200
|
- lib/indocker/errors.rb
|
|
138
|
-
- lib/indocker/
|
|
139
|
-
- lib/indocker/
|
|
201
|
+
- lib/indocker/git/git_api.rb
|
|
202
|
+
- lib/indocker/git/git_helper.rb
|
|
203
|
+
- lib/indocker/git/git_service.rb
|
|
204
|
+
- lib/indocker/handlers/container_run.rb
|
|
205
|
+
- lib/indocker/handlers/container_stop.rb
|
|
206
|
+
- lib/indocker/handlers/performable.rb
|
|
140
207
|
- lib/indocker/image/image_builder.rb
|
|
141
208
|
- lib/indocker/image/image_dependencies_manager.rb
|
|
209
|
+
- lib/indocker/image/image_directives_runner.rb
|
|
210
|
+
- lib/indocker/image/image_dockerfile_builder.rb
|
|
142
211
|
- lib/indocker/image/image_dsl.rb
|
|
143
212
|
- lib/indocker/image/image_evaluator.rb
|
|
213
|
+
- lib/indocker/image/image_helper.rb
|
|
144
214
|
- lib/indocker/image/image_metadata.rb
|
|
145
215
|
- lib/indocker/image/image_metadata_factory.rb
|
|
146
216
|
- lib/indocker/image/image_metadata_repository.rb
|
|
@@ -149,6 +219,9 @@ files:
|
|
|
149
219
|
- lib/indocker/networks/network_metadata_repository.rb
|
|
150
220
|
- lib/indocker/partial/partial_metadata.rb
|
|
151
221
|
- lib/indocker/partial/partial_metadata_repository.rb
|
|
222
|
+
- lib/indocker/registry/registry_api.rb
|
|
223
|
+
- lib/indocker/registry/registry_helper.rb
|
|
224
|
+
- lib/indocker/registry/registry_service.rb
|
|
152
225
|
- lib/indocker/utils/ioc_container.rb
|
|
153
226
|
- lib/indocker/utils/logger.rb
|
|
154
227
|
- lib/indocker/utils/logger_factory.rb
|
|
@@ -159,23 +232,26 @@ files:
|
|
|
159
232
|
- lib/indocker/utils/tar_helper.rb
|
|
160
233
|
- lib/indocker/utils/test_logger_factory.rb
|
|
161
234
|
- lib/indocker/version.rb
|
|
235
|
+
- lib/indocker/volumes/volume_metadata.rb
|
|
236
|
+
- lib/indocker/volumes/volume_metadata_factory.rb
|
|
237
|
+
- lib/indocker/volumes/volume_metadata_repository.rb
|
|
162
238
|
- spec/example/.indocker/config.rb
|
|
163
239
|
- spec/example/.indocker/images_and_containers.rb
|
|
164
240
|
- spec/example/assets/index.css
|
|
165
241
|
- spec/example/assets/index.js
|
|
242
|
+
- spec/fixtures/spec.env
|
|
166
243
|
- spec/indocker/configs/config_factory_spec.rb
|
|
167
244
|
- spec/indocker/configs/config_spec.rb
|
|
245
|
+
- spec/indocker/container/container_builder_spec.rb
|
|
168
246
|
- spec/indocker/container/container_manager_spec.rb
|
|
169
|
-
- spec/indocker/
|
|
170
|
-
- spec/indocker/
|
|
247
|
+
- spec/indocker/docker_api/container_config_spec.rb
|
|
248
|
+
- spec/indocker/docker_api/docker_api_spec.rb
|
|
249
|
+
- spec/indocker/handlers/container_run_spec.rb
|
|
171
250
|
- spec/indocker/image/image_builder_spec.rb
|
|
251
|
+
- spec/indocker/image/image_directives_runner_spec.rb
|
|
252
|
+
- spec/indocker/image/image_dockerfile_builder_spec.rb
|
|
172
253
|
- spec/indocker/image/image_evaluator_spec.rb
|
|
173
|
-
- spec/indocker/utils/docker_api_spec.rb
|
|
174
254
|
- spec/spec_helper.rb
|
|
175
|
-
- spec/tmp/indocker_list_container_files/deeper/example3.txt
|
|
176
|
-
- spec/tmp/indocker_list_container_files/deeper/example4.txt
|
|
177
|
-
- spec/tmp/indocker_list_container_files/example1.txt
|
|
178
|
-
- spec/tmp/indocker_list_container_files/example2.txt
|
|
179
255
|
homepage: https://github.com/droidlabs/indocker
|
|
180
256
|
licenses:
|
|
181
257
|
- MIT
|
|
@@ -205,16 +281,16 @@ test_files:
|
|
|
205
281
|
- spec/example/.indocker/images_and_containers.rb
|
|
206
282
|
- spec/example/assets/index.css
|
|
207
283
|
- spec/example/assets/index.js
|
|
284
|
+
- spec/fixtures/spec.env
|
|
208
285
|
- spec/indocker/configs/config_factory_spec.rb
|
|
209
286
|
- spec/indocker/configs/config_spec.rb
|
|
287
|
+
- spec/indocker/container/container_builder_spec.rb
|
|
210
288
|
- spec/indocker/container/container_manager_spec.rb
|
|
211
|
-
- spec/indocker/
|
|
212
|
-
- spec/indocker/
|
|
289
|
+
- spec/indocker/docker_api/container_config_spec.rb
|
|
290
|
+
- spec/indocker/docker_api/docker_api_spec.rb
|
|
291
|
+
- spec/indocker/handlers/container_run_spec.rb
|
|
213
292
|
- spec/indocker/image/image_builder_spec.rb
|
|
293
|
+
- spec/indocker/image/image_directives_runner_spec.rb
|
|
294
|
+
- spec/indocker/image/image_dockerfile_builder_spec.rb
|
|
214
295
|
- spec/indocker/image/image_evaluator_spec.rb
|
|
215
|
-
- spec/indocker/utils/docker_api_spec.rb
|
|
216
296
|
- spec/spec_helper.rb
|
|
217
|
-
- spec/tmp/indocker_list_container_files/deeper/example3.txt
|
|
218
|
-
- spec/tmp/indocker_list_container_files/deeper/example4.txt
|
|
219
|
-
- spec/tmp/indocker_list_container_files/example1.txt
|
|
220
|
-
- spec/tmp/indocker_list_container_files/example2.txt
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
class Indocker::DockerDirectives::Copy < Indocker::DockerDirectives::Base
|
|
2
|
-
attr_reader :copy_actions, :context, :compile
|
|
3
|
-
|
|
4
|
-
def initialize(context:, copy_actions:, compile: false)
|
|
5
|
-
@copy_actions = copy_actions
|
|
6
|
-
@context = context
|
|
7
|
-
@compile = compile
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def type
|
|
11
|
-
'COPY'
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def to_s
|
|
15
|
-
result = []
|
|
16
|
-
|
|
17
|
-
copy_actions.each do |from, to|
|
|
18
|
-
result.push "#{type} #{from} #{to}"
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
result.join("\n")
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def prepare_directive?
|
|
25
|
-
true
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
class Indocker::DockerDirectives::From < Indocker::DockerDirectives::Base
|
|
2
|
-
attr_reader :repo, :tag
|
|
3
|
-
|
|
4
|
-
def initialize(repo_tag, tag: nil)
|
|
5
|
-
case repo_tag
|
|
6
|
-
when String
|
|
7
|
-
@repo = repo_tag.split(':')[0]
|
|
8
|
-
@tag = tag || repo_tag.split(':')[1] || Indocker::ImageMetadata::DEFAULT_TAG
|
|
9
|
-
else
|
|
10
|
-
@repo = repo_tag
|
|
11
|
-
@tag = tag || Indocker::ImageMetadata::DEFAULT_TAG
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def full_name
|
|
16
|
-
"#{repo}:#{tag}"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def dockerhub_image?
|
|
20
|
-
repo.is_a?(String)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def to_s
|
|
24
|
-
"#{type} #{repo}:#{tag}"
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def type
|
|
28
|
-
'FROM'
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
class Indocker::ImageDirectivesRunner
|
|
2
|
-
include SmartIoC::Iocify
|
|
3
|
-
|
|
4
|
-
bean :image_directives_runner
|
|
5
|
-
|
|
6
|
-
inject :container_manager
|
|
7
|
-
inject :config
|
|
8
|
-
inject :render_util
|
|
9
|
-
|
|
10
|
-
def run_all(directives)
|
|
11
|
-
directives.each {|c| run(c)}
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def run(directive)
|
|
15
|
-
case directive
|
|
16
|
-
when Indocker::PrepareDirectives::DockerCp
|
|
17
|
-
run_docker_cp(directive)
|
|
18
|
-
when Indocker::DockerDirectives::Copy
|
|
19
|
-
run_copy(directive)
|
|
20
|
-
else
|
|
21
|
-
# do nothing
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def run_docker_cp(directive)
|
|
26
|
-
directive.copy_actions.each do |from, to|
|
|
27
|
-
container_manager.copy(
|
|
28
|
-
name: directive.container_name,
|
|
29
|
-
copy_from: from,
|
|
30
|
-
copy_to: to
|
|
31
|
-
)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def run_copy(directive)
|
|
36
|
-
directive.copy_actions.each do |from, to|
|
|
37
|
-
build_dir_file = File.join(directive.context.build_dir, from)
|
|
38
|
-
|
|
39
|
-
source_dir = File.join(config.root, from)
|
|
40
|
-
|
|
41
|
-
if File.directory?(from)
|
|
42
|
-
dest_dir = File.join(directive.context.build_dir, from)
|
|
43
|
-
else
|
|
44
|
-
dest_dir = File.join(directive.context.build_dir, File.dirname(from))
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
if File.exists?(build_dir_file) && File.file?(build_dir_file)
|
|
48
|
-
copy_compile_file(
|
|
49
|
-
from: build_dir_file,
|
|
50
|
-
to: build_dir_file,
|
|
51
|
-
locals: directive.context.storage,
|
|
52
|
-
compile: directive.compile
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
return
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
if File.exist?(build_dir_file) && File.directory?(build_dir_file)
|
|
59
|
-
files_list = Dir.glob(File.join(build_dir_file, '**', '*'), File::FNM_DOTMATCH)
|
|
60
|
-
|
|
61
|
-
files_list.each do |from|
|
|
62
|
-
copy_compile_file(
|
|
63
|
-
from: from,
|
|
64
|
-
to: from,
|
|
65
|
-
locals: directive.context.storage,
|
|
66
|
-
compile: directive.compile
|
|
67
|
-
)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
return
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
if File.exists?(source_dir) && File.file?(source_dir)
|
|
74
|
-
copy_compile_file(
|
|
75
|
-
from: source_dir,
|
|
76
|
-
to: File.join(dest_dir, File.basename(source_dir)),
|
|
77
|
-
locals: directive.context.storage,
|
|
78
|
-
compile: directive.compile
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
return
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
if Dir.exist?(source_dir) && File.directory?(source_dir)
|
|
85
|
-
files_list = Dir.glob(File.join(source_dir, '**', '*'), File::FNM_DOTMATCH)
|
|
86
|
-
|
|
87
|
-
files_list.each do |from|
|
|
88
|
-
relative_to = Pathname.new(from).relative_path_from( Pathname.new(source_dir) ).to_s
|
|
89
|
-
absolute_to = File.join(dest_dir, relative_to)
|
|
90
|
-
|
|
91
|
-
copy_compile_file(
|
|
92
|
-
from: from,
|
|
93
|
-
to: absolute_to,
|
|
94
|
-
locals: directive.context.storage,
|
|
95
|
-
compile: directive.compile
|
|
96
|
-
)
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
return
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
raise Indocker::Errors::FileDoesNotExists
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
private
|
|
107
|
-
|
|
108
|
-
def copy_compile_file(from:, to:, locals: {}, compile: false)
|
|
109
|
-
return if !File.exists?(from) || File.directory?(from)
|
|
110
|
-
|
|
111
|
-
FileUtils.mkdir_p(File.dirname(to)) unless Dir.exist?(File.dirname(to))
|
|
112
|
-
|
|
113
|
-
write_content = compile ? render_util.render( File.read(from), locals ) :
|
|
114
|
-
File.read(from)
|
|
115
|
-
|
|
116
|
-
File.write(to, write_content)
|
|
117
|
-
|
|
118
|
-
File.chmod(File.stat(from).mode, to)
|
|
119
|
-
end
|
|
120
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
class Indocker::Envs::Manager
|
|
2
|
-
include SmartIoC::Iocify
|
|
3
|
-
|
|
4
|
-
bean :envs_manager
|
|
5
|
-
|
|
6
|
-
inject :config
|
|
7
|
-
inject :logger
|
|
8
|
-
inject :envs_loader
|
|
9
|
-
|
|
10
|
-
def load_init_application_env_variables
|
|
11
|
-
config.load_env_file.each do |path|
|
|
12
|
-
env_file = File.join(config.root, path)
|
|
13
|
-
|
|
14
|
-
begin
|
|
15
|
-
metadata = envs_loader.parse(env_file)
|
|
16
|
-
rescue Indocker::Errors::EnvFileDoesNotExist
|
|
17
|
-
logger.warn "File #{env_file} doesn't exist. Check path to environment_path"
|
|
18
|
-
return
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
metadata.to_hash.each do |key, value|
|
|
22
|
-
if ENV.has_key?(key) && ENV[key] != value
|
|
23
|
-
logger.warn "Environment file '#{path}' overwrites ENV['#{key}'] from '#{ENV[key]}' to '#{value}'!"
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
ENV[key] = value
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
module Indocker::Handlers
|
|
2
|
-
class Base
|
|
3
|
-
def perform(options)
|
|
4
|
-
env = options.delete(:env)
|
|
5
|
-
|
|
6
|
-
application_initializer.init_app(options[:current_path], env: env)
|
|
7
|
-
|
|
8
|
-
self.method(:handle).call(options)
|
|
9
|
-
rescue Docker::Error::ClientError => e
|
|
10
|
-
logger.error(e.message)
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Indocker::ImageDirectivesRunner do
|
|
4
|
-
let(:image_directives_runner) { ioc.image_directives_runner }
|
|
5
|
-
|
|
6
|
-
let(:context) {
|
|
7
|
-
Indocker::DSLContext.new(
|
|
8
|
-
display: 'none',
|
|
9
|
-
use_strict: true,
|
|
10
|
-
build_dir: build_dir
|
|
11
|
-
)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
let(:directive) {
|
|
15
|
-
Indocker::DockerDirectives::Copy.new(
|
|
16
|
-
context: context,
|
|
17
|
-
copy_actions: {
|
|
18
|
-
from_path => to_path
|
|
19
|
-
}
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
let(:from_path) { 'assets/.' }
|
|
24
|
-
let(:to_path) { '/assets' }
|
|
25
|
-
|
|
26
|
-
describe "#run_copy" do
|
|
27
|
-
let(:build_dir) { ioc.config.root.join('../../tmp/build_dir') }
|
|
28
|
-
|
|
29
|
-
context 'for :from as directory path' do
|
|
30
|
-
context "when directory exists in build directory" do
|
|
31
|
-
before do
|
|
32
|
-
FileUtils.mkdir_p(File.join(build_dir, 'assets'))
|
|
33
|
-
File.open(build_dir.join('assets', 'index.css'), 'w') {|f| f.write("/* located at build directory */")}
|
|
34
|
-
File.open(build_dir.join('assets', 'index.js'), 'w') {|f| f.write("// located at build directory")}
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it 'copy files from root to build directory' do
|
|
38
|
-
image_directives_runner.run(directive)
|
|
39
|
-
|
|
40
|
-
ensure_content(build_dir.join('assets', 'index.css'), "/* located at build directory */")
|
|
41
|
-
ensure_content(build_dir.join('assets', 'index.js'), "// located at build directory")
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
context "when directory exists in project root directory" do
|
|
46
|
-
it 'copy files from root to build directory' do
|
|
47
|
-
image_directives_runner.run(directive)
|
|
48
|
-
|
|
49
|
-
ensure_content(build_dir.join('assets', 'index.css'), "* { display: <%= display %>; }")
|
|
50
|
-
ensure_content(build_dir.join('assets', 'index.js'), "<% if use_strict %>'use strict';<% end %>")
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
context "when directory does not exists" do
|
|
55
|
-
let(:from_path) { 'invalid/dir/.' }
|
|
56
|
-
let(:to_path) { '/invalid/dir' }
|
|
57
|
-
|
|
58
|
-
it "raises error Indocker::Errors::FileDoesNotExists" do
|
|
59
|
-
expect{
|
|
60
|
-
image_directives_runner.run(directive)
|
|
61
|
-
}.to raise_error(Indocker::Errors::FileDoesNotExists)
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
context 'with compile: true option' do
|
|
66
|
-
let(:directive) {
|
|
67
|
-
Indocker::DockerDirectives::Copy.new(
|
|
68
|
-
context: context,
|
|
69
|
-
copy_actions: {
|
|
70
|
-
from_path => to_path
|
|
71
|
-
},
|
|
72
|
-
compile: true
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
it 'copy compiles files from root to build directory' do
|
|
77
|
-
image_directives_runner.run(directive)
|
|
78
|
-
|
|
79
|
-
ensure_content(build_dir.join('assets', 'index.css'), "* { display: none; }")
|
|
80
|
-
ensure_content(build_dir.join('assets', 'index.js'), "'use strict';")
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
context "for :from as single file path" do
|
|
86
|
-
let(:from_path) { 'assets/index.css' }
|
|
87
|
-
let(:to_path) { '/assets' }
|
|
88
|
-
|
|
89
|
-
context 'without compilation' do
|
|
90
|
-
it 'copy files from root to build directory if no file in build directory' do
|
|
91
|
-
image_directives_runner.run(directive)
|
|
92
|
-
|
|
93
|
-
ensure_content(build_dir.join('assets', 'index.css'), "* { display: <%= display %>; }")
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
context 'with compilaton' do
|
|
98
|
-
let(:directive) {
|
|
99
|
-
Indocker::DockerDirectives::Copy.new(
|
|
100
|
-
context: context,
|
|
101
|
-
copy_actions: {
|
|
102
|
-
from_path => to_path
|
|
103
|
-
},
|
|
104
|
-
compile: true
|
|
105
|
-
)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
before do
|
|
109
|
-
FileUtils.mkdir_p(File.join(build_dir, 'assets'))
|
|
110
|
-
File.open(build_dir.join('assets', 'index.css'), 'w') {|f| f.write("/* <%= display %>; */")}
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
it 'compiles and overwrites file is present in build directory' do
|
|
114
|
-
image_directives_runner.run(directive)
|
|
115
|
-
|
|
116
|
-
ensure_content(build_dir.join('assets', 'index.css'), "/* none; */")
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
end
|