dry-stack 0.1.16 → 0.1.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dry-stack/command_swarm_deploy.rb +20 -18
- data/lib/dry-stack/stack.rb +12 -4
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54829c262a7ebcc4f610e60677db92468afdc9ef8d0f96a40b25146586182906
|
4
|
+
data.tar.gz: a9aef297aa9089a01dec3dfba63b06eebd9ea8465f724fab13c2abb3c725f560
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dc83172b86117389996574cfbd7a351b9dfb195037ee1727ec2510954daddb7970904ea2798d00632844041fecd611f1e1697a0d21b2a147a69300071f90953
|
7
|
+
data.tar.gz: 89e35595ec63f7005ce4427622171d657785c9092001db88d0807214566b3f05a5b9dcb32a04e722fb4cabd81ce5b882eeeca9de141265a65b8d738837bcc819
|
@@ -9,31 +9,33 @@ Dry::CommandLine::COMMANDS[:swarm_deploy] = Class.new do
|
|
9
9
|
_params = stack.options.merge params
|
10
10
|
stack.name = _params[:name] if _params[:name]
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
ENV['DOCKER_CONTEXT'] = name.to_s
|
12
|
+
raise 'Context endpoint required' unless params[:context_endpoint]
|
13
|
+
|
14
|
+
name = params[:context_endpoint].gsub( /[\/.:@]/,'_').gsub( '__','_')
|
15
|
+
name = "dry-#{name}".to_sym
|
16
|
+
endpoint = params[:context_endpoint]
|
17
|
+
$stdout.puts "Looking for docker context '#{name}'"
|
18
|
+
|
19
|
+
contexts = {}
|
20
|
+
exec_o_lines 'docker context ls --format json' do |line|
|
21
|
+
ctx = JSON.parse line, symbolize_names: true
|
22
|
+
contexts[ctx[:Name].to_sym] = ctx # {"Current":false,"Description":"","DockerEndpoint":"ssh://root@x.x.x.x","Error":"","Name":"prod-swarm"}
|
23
|
+
end
|
24
|
+
|
25
|
+
if contexts[name] && contexts[name][:DockerEndpoint] != endpoint
|
26
|
+
raise "context '#{name}' has different host value: #{contexts[name][:DockerEndpoint]} != #{endpoint}"
|
29
27
|
end
|
30
28
|
|
29
|
+
exec_i "docker context create #{name} --docker host=#{endpoint}" unless contexts[name]
|
30
|
+
|
31
|
+
ENV['DOCKER_CONTEXT'] = name.to_s
|
32
|
+
|
31
33
|
# substitute ENV variables
|
32
34
|
yaml = stack.to_compose(_params).lines[1..].join
|
33
35
|
# system " echo \"#{yaml.gsub("`", '\\\`')}\" | docker stack deploy -c - #{stack.name} --prune --resolve-image changed"
|
34
36
|
|
35
37
|
# --prune --resolve-image changed
|
36
|
-
exec_i "docker stack deploy -c - #{stack.name}
|
38
|
+
exec_i "docker stack deploy -c - --with-registry-auth #{extra}" #{stack.name} , yaml
|
37
39
|
system "docker config rm $(docker config ls --filter label=com.docker.stack.namespace=#{stack.name} --format \"{{.ID}}\")"
|
38
40
|
|
39
41
|
exec_i "docker config rm #{stack.name}_readme || echo 'failed to remove config #{stack.name}_readme'"
|
data/lib/dry-stack/stack.rb
CHANGED
@@ -15,6 +15,7 @@ require_relative 'apache_specific_md5'
|
|
15
15
|
|
16
16
|
module Dry
|
17
17
|
EMPTY_HASH = :empty_hash
|
18
|
+
DEFAULT_INIT_SERVICE = true # add "init: true" option
|
18
19
|
|
19
20
|
class ::Hash
|
20
21
|
def deep_merge!(second)
|
@@ -205,23 +206,26 @@ module Dry
|
|
205
206
|
rule << "PathPrefix(`#{nginx_host2regexp ing[:path]}`)" if ing[:path]
|
206
207
|
rule << "#{ing[:rule]}" if ing[:rule]
|
207
208
|
|
209
|
+
middlewares = []
|
210
|
+
|
208
211
|
if ing[:basic_auth]
|
209
212
|
ba_user, ba_password, salt = ing[:basic_auth].split ':'
|
210
213
|
hashed_password = apr1_crypt ba_password, (salt || rand(36**8).to_s(36))
|
211
214
|
service[:deploy][:labels] << "traefik.http.middlewares.#{service_name}-#{index}_auth.basicauth.users=#{ba_user}:#{hashed_password.gsub('$','$$')}"
|
212
|
-
|
215
|
+
middlewares << "#{service_name}-#{index}_auth"
|
213
216
|
end
|
214
217
|
|
215
|
-
|
216
218
|
service[:deploy][:labels] << "traefik.http.routers.#{service_name}-#{index}.rule=#{rule.join ' && '}"
|
217
219
|
|
218
220
|
if ing[:path_sub]
|
221
|
+
middlewares << "#{service_name}-#{index}-path_sub"
|
219
222
|
service[:deploy][:labels] += [
|
220
|
-
"traefik.http.routers.#{service_name}-#{index}.middlewares=#{service_name}-#{index}-path_sub",
|
221
223
|
"traefik.http.middlewares.#{service_name}-#{index}-path_sub.replacepathregex.regex=#{ing[:path_sub][0]}",
|
222
224
|
"traefik.http.middlewares.#{service_name}-#{index}-path_sub.replacepathregex.replacement=#{ing[:path_sub][1].gsub('$','$$')}"
|
223
225
|
]
|
224
226
|
end
|
227
|
+
|
228
|
+
service[:deploy][:labels] << "traefik.http.routers.#{service_name}-#{index}.middlewares=#{middlewares.join ","}" unless middlewares.empty?
|
225
229
|
end
|
226
230
|
end
|
227
231
|
service.delete :ingress
|
@@ -381,7 +385,11 @@ module Dry
|
|
381
385
|
opts[:ports] = [opts[:ports]].flatten if opts.key? :ports
|
382
386
|
opts[:environment] = opts.delete(:env) if opts.key? :env
|
383
387
|
|
384
|
-
service = @services[name.to_sym] ||=
|
388
|
+
service = @services[name.to_sym] ||= begin
|
389
|
+
s = {environment: {}, deploy: {labels: []}, networks: {}}
|
390
|
+
DEFAULT_INIT_SERVICE ? s.merge(init: true) : s
|
391
|
+
end
|
392
|
+
|
385
393
|
service.deep_merge! opts
|
386
394
|
ServiceFunction.new(service, &) if block_given?
|
387
395
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-stack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artyom B
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|