Class: Dockerploy::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/dockerploy/image.rb

Instance Method Summary collapse

Constructor Details

#initialize(config, options = {}) ⇒ Image

Returns a new instance of Image.



3
4
5
6
# File 'lib/dockerploy/image.rb', line 3

def initialize(config, options = {})
  @config = config
  @options = options
end

Instance Method Details

#buildObject



8
9
10
11
# File 'lib/dockerploy/image.rb', line 8

def build
  command = sprintf('env DOCKER_HOST=%s docker build -t %s .', @config.docker_host, image_name)
  ShellClient.new.command(command)
end

#pullObject



18
19
20
21
22
23
24
# File 'lib/dockerploy/image.rb', line 18

def pull
  return unless @config.servers
  @config.servers.each do |server|
    ssh_client = SSHClient.new(server[:host], server[:username], server[:password], server[:port])
    ssh_client.command(sprintf('docker pull %s', image_name))
  end
end

#pushObject



13
14
15
16
# File 'lib/dockerploy/image.rb', line 13

def push
  command = sprintf('env DOCKER_HOST=%s docker push %s', @config.docker_host, image_name)
  ShellClient.new.command(command)
end