Sha256: 8dd5e96af184aa23e799ba31cfdea42d4ef060eedaebeb603808a66c6a4b40e6
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
command :ship do |c| c.summary = 'Create Docker containers defined in ops/containers/[host_name].yml' c.syntax = 'ops ship host [host_name]' c.description = "Create all docker containers described in #{Ops::CONTAINERS_DIR}/[host_name].yml" c.example "Create a container called 'www' in the host example.com. This is described in '#{Ops::CONTAINERS_DIR}/example.com.yml' like:\n # www:\n # detach: true\n # image: jlebrijo/prun\n # ports:\n # - '2222:22'\n # - '80:80'", 'ops ship example.com' c.action do |args, options| host = args[0] user = Ops::get_user_for(host) unless host == "localhost" Docker::containers_for(host).each do |container_name, config| ports = config["ports"].map{|port| "-p #{port}"}.join(" ") options = [] config.reject{|k| Docker::SPECIAL_OPTS.include? k}.each do |option, value| options << "--#{option}=#{value}" end say "Container '#{container_name}' loading on #{host}, please wait ....\n" command = "docker run #{options.join(" ")} --name #{container_name} #{ports} #{config["image"]} #{config["command"]}" if host == "localhost" system command else Net::SSH.start(host, user) do |ssh| say "Docker CMD: #{command}\n" ssh.exec command end end sleep 5 config["post-conditions"].each { |c| system c } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
open-dock-0.1.0 | lib/open-dock/commands/ship_host.rb |