dry-stack 0.0.85 → 0.0.88
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/stack.rb +17 -13
- 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: ae624210dd275eb7f62eb30f4023ea37dfde7689e84b80e9f98bf4d47f5d66b4
|
4
|
+
data.tar.gz: '0109ac07fea18f6f942ad66d71292fd52da1f27cc0b99c2834d1620b6bdb2c67'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07a69b0fc65be43c138f561eabff1a38525ceea703b43c368c292bbcd350bdff283f64b74f992aef6f7b0b97761af6ff7e594ee07b634900b1780ef559bae281
|
7
|
+
data.tar.gz: fc51afc785660c574d971374b300da2ba8ce67f9673b1d700822867ba7baefc89de0addba17c52e5b3da56c32bb2b2617233cf3337f3ee64ad5e925309f46b9f
|
data/lib/dry-stack/stack.rb
CHANGED
@@ -58,7 +58,6 @@ module Dry
|
|
58
58
|
def logging(opts) = (@service[:logging] ||= {}).merge! opts
|
59
59
|
def user(user) = @service[:user] = user # "${UID}:${GID}", "www-data:www-data"
|
60
60
|
def network(names) = (@service[:networks] ||= []) << names
|
61
|
-
def basic_auth(user_and_password) = @service[:basic_auth] = user_and_password
|
62
61
|
def ingress(ing) = ((@service[:ingress] ||=[]) << ing).flatten!
|
63
62
|
end
|
64
63
|
|
@@ -147,6 +146,8 @@ module Dry
|
|
147
146
|
|
148
147
|
compose[:services].each do |name, service|
|
149
148
|
|
149
|
+
service[:image].gsub!(/:latest$/, '') # let docker swarm to create tag: :latest@sha265:0000...
|
150
|
+
|
150
151
|
ingress = [@ingress[name], service[:ingress] || [] ].flatten.compact
|
151
152
|
|
152
153
|
service[:deploy] ||= {}
|
@@ -173,14 +174,6 @@ module Dry
|
|
173
174
|
ingress[0][:port] ||= service[:ports]&.first
|
174
175
|
|
175
176
|
ingress.each_with_index do |ing, index|
|
176
|
-
|
177
|
-
if service[:basic_auth]
|
178
|
-
ba_user, ba_password, salt = service[:basic_auth].split ':'
|
179
|
-
hashed_password = apr1_crypt ba_password, (salt || rand(36**8).to_s(36))
|
180
|
-
service[:deploy][:labels] << "traefik.http.middlewares.#{service_name}-#{index}_auth.basicauth.users=#{ba_user}:#{hashed_password.gsub('$','$$')}"
|
181
|
-
service[:deploy][:labels] << "traefik.http.routers.#{service_name}-#{index}.middlewares=#{service_name}-#{index}_auth"
|
182
|
-
end
|
183
|
-
|
184
177
|
ing[:port] ||= service[:ports]&.first
|
185
178
|
service[:deploy][:labels] += [
|
186
179
|
"traefik.http.routers.#{service_name}-#{index}.service=#{service_name}-#{index}",
|
@@ -200,9 +193,18 @@ module Dry
|
|
200
193
|
|
201
194
|
rule = []
|
202
195
|
rule << "HostRegexp(`{name:#{nginx_host2regexp ing[:host]}}`)" if ing[:host]
|
196
|
+
rule << "ClientIP(#{[ing[:client_ip]].flatten.map{ "`#{_1}`" }.join ','})" if ing[:client_ip]
|
203
197
|
rule << "PathPrefix(`#{nginx_host2regexp ing[:path]}`)" if ing[:path]
|
204
198
|
rule << "#{ing[:rule]}" if ing[:rule]
|
205
199
|
|
200
|
+
if ing[:basic_auth]
|
201
|
+
ba_user, ba_password, salt = ing[:basic_auth].split ':'
|
202
|
+
hashed_password = apr1_crypt ba_password, (salt || rand(36**8).to_s(36))
|
203
|
+
service[:deploy][:labels] << "traefik.http.middlewares.#{service_name}-#{index}_auth.basicauth.users=#{ba_user}:#{hashed_password.gsub('$','$$')}"
|
204
|
+
service[:deploy][:labels] << "traefik.http.routers.#{service_name}-#{index}.middlewares=#{service_name}-#{index}_auth"
|
205
|
+
end
|
206
|
+
|
207
|
+
|
206
208
|
service[:deploy][:labels] << "traefik.http.routers.#{service_name}-#{index}.rule=#{rule.join ' && '}"
|
207
209
|
|
208
210
|
if ing[:path_sub]
|
@@ -214,7 +216,6 @@ module Dry
|
|
214
216
|
end
|
215
217
|
end
|
216
218
|
end
|
217
|
-
service.delete :basic_auth
|
218
219
|
service.delete :ingress
|
219
220
|
|
220
221
|
service[:environment] = @environment[name].merge(service[:environment]) if @environment[name]
|
@@ -269,15 +270,18 @@ module Dry
|
|
269
270
|
end
|
270
271
|
|
271
272
|
compose[:configs].update(compose[:configs]) do |name, config|
|
273
|
+
# total config name must be max 64 characters length. MD5 - 32 characters
|
274
|
+
short_name = name[0..30]
|
275
|
+
|
272
276
|
if config[:file_content]
|
273
277
|
md5 = Digest::MD5.hexdigest config[:file_content]
|
274
|
-
fname = "./#{@name}.config.#{name}.#{md5}" # use MD5, when
|
278
|
+
fname = "./#{@name}.config.#{name}.#{md5}" # use MD5, when run in parallel may have different content
|
275
279
|
File.write fname, config[:file_content]
|
276
|
-
{name: "#{
|
280
|
+
{name: "#{short_name}-#{md5}", file: fname}.merge config.except(:file_content)
|
277
281
|
elsif config[:file]
|
278
282
|
body = File.read config[:file] rescue ''
|
279
283
|
md5 = Digest::MD5.hexdigest body
|
280
|
-
{name: "#{
|
284
|
+
{name: "#{short_name}-#{md5}", file: fname}.merge config
|
281
285
|
else
|
282
286
|
config
|
283
287
|
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.0.
|
4
|
+
version: 0.0.88
|
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-07-
|
11
|
+
date: 2024-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|