-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
111 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
dry-stack (0.1.16) | ||
dry-stack (0.1.17) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,31 +9,33 @@ def run(stack, params, args, extra) | |
_params = stack.options.merge params | ||
stack.name = _params[:name] if _params[:name] | ||
|
||
if params[:context_endpoint] | ||
name = params[:context_endpoint].gsub( /[\/.:@]/,'_').gsub( '__','_') | ||
name = "dry-#{name}".to_sym | ||
endpoint = params[:context_endpoint] | ||
contexts = {} | ||
exec_o_lines 'docker context ls --format json' do |line| | ||
ctx = JSON.parse line, symbolize_names: true | ||
contexts[ctx[:Name].to_sym] = ctx # {"Current":false,"Description":"","DockerEndpoint":"ssh://[email protected]","Error":"","Name":"prod-swarm"} | ||
end | ||
|
||
if contexts[name] && contexts[name][:DockerEndpoint] != endpoint | ||
raise "context '#{name}' has different host value: #{contexts[name][:DockerEndpoint]} != #{endpoint}" | ||
end | ||
|
||
exec_i "docker context create #{name} --docker host=#{endpoint}" unless contexts[name] | ||
|
||
ENV['DOCKER_CONTEXT'] = name.to_s | ||
raise 'Context endpoint required' unless params[:context_endpoint] | ||
|
||
name = params[:context_endpoint].gsub( /[\/.:@]/,'_').gsub( '__','_') | ||
name = "dry-#{name}".to_sym | ||
endpoint = params[:context_endpoint] | ||
$stdout.puts "Looking for docker context '#{name}'" | ||
|
||
contexts = {} | ||
exec_o_lines 'docker context ls --format json' do |line| | ||
ctx = JSON.parse line, symbolize_names: true | ||
contexts[ctx[:Name].to_sym] = ctx # {"Current":false,"Description":"","DockerEndpoint":"ssh://[email protected]","Error":"","Name":"prod-swarm"} | ||
end | ||
|
||
if contexts[name] && contexts[name][:DockerEndpoint] != endpoint | ||
raise "context '#{name}' has different host value: #{contexts[name][:DockerEndpoint]} != #{endpoint}" | ||
end | ||
|
||
exec_i "docker context create #{name} --docker host=#{endpoint}" unless contexts[name] | ||
|
||
ENV['DOCKER_CONTEXT'] = name.to_s | ||
|
||
# substitute ENV variables | ||
yaml = stack.to_compose(_params).lines[1..].join | ||
# system " echo \"#{yaml.gsub("`", '\\\`')}\" | docker stack deploy -c - #{stack.name} --prune --resolve-image changed" | ||
|
||
# --prune --resolve-image changed | ||
exec_i "docker stack deploy -c - #{stack.name} #{extra}", yaml | ||
exec_i "docker stack deploy -c - --with-registry-auth #{extra}" #{stack.name} , yaml | ||
system "docker config rm $(docker config ls --filter label=com.docker.stack.namespace=#{stack.name} --format \"{{.ID}}\")" | ||
|
||
exec_i "docker config rm #{stack.name}_readme || echo 'failed to remove config #{stack.name}_readme'" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Dry | ||
class Stack | ||
VERSION = '0.1.16' | ||
VERSION = '0.1.17' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ services: | |
environment: | ||
STACK_NAME: stack | ||
STACK_SERVICE_NAME: hidden | ||
init: true | ||
image: dummy/hidden |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ services: | |
DB_URL: "$DB_URL" | ||
STACK_NAME: stack | ||
STACK_SERVICE_NAME: reports | ||
init: true | ||
image: reports |
Oops, something went wrong.