Sha256: a5ffbf94a0fddcf93b8c5aa6de3702c7a4f6d943077520400dc60029a136db40
Contents?: true
Size: 1.32 KB
Versions: 6
Compression:
Stored size: 1.32 KB
Contents
command :'ship host' 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 host example.com' c.action do |args, options| host = args[0] user = Ops::get_user_for(host) 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" Net::SSH.start(host, user) do |ssh| command = "docker run #{options.join(" ")} --name #{container_name} #{ports} #{config["image"]} #{config["command"]}" say "Docker CMD: #{command}\n" ssh.exec command end sleep 5 config["post-conditions"].each { |c| system c } end end end
Version data entries
6 entries across 6 versions & 2 rubygems