Class: Dockerploy::Image

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

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Image

Returns a new instance of Image.



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

def initialize(config)
  @config = config
end

Instance Method Details

#buildObject



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

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

#pullObject



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

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', @config.image_name))
  end
end

#pushObject



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

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