Class: Shipper::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/shipper/service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options) ⇒ Service

Returns a new instance of Service.



7
8
9
10
11
# File 'lib/shipper/service.rb', line 7

def initialize(name, options)
  @name = name
  @options = options
  @path = "#{Dir.pwd}/#{options['path']}"
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/shipper/service.rb', line 5

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/shipper/service.rb', line 5

def options
  @options
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/shipper/service.rb', line 5

def path
  @path
end

Instance Method Details

#ship!Object



13
14
15
16
17
18
# File 'lib/shipper/service.rb', line 13

def ship!
  executor.cd(path)
  options['before_build']&.each { |cmd| exec(cmd) }
  exec "docker build . -t #{options.fetch('repo')} #{build_args}".strip
  exec "docker push #{options.fetch('repo')}"
end