Class: Escualo::Script::Dockerized

Inherits:
Mode
  • Object
show all
Defined in:
lib/escualo/script.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Mode

#run_commands_for!

Instance Attribute Details

#dockerfileObject

Returns the value of attribute dockerfile.



39
40
41
# File 'lib/escualo/script.rb', line 39

def dockerfile
  @dockerfile
end

Instance Method Details

#base_image(options) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/escualo/script.rb', line 59

def base_image(options)
  if options.base_image == 'ubuntu'
    'ubuntu:xenial'
  elsif options.base_image == 'debian'
    'debian:jessie'
  else
    raise "Unsupported base image #{options.base_image}. Only debian and ubuntu are supported"
  end
end

#escualo_install(options) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/escualo/script.rb', line 49

def escualo_install(options)
  if options.development
    "
COPY escualo-#{Escualo::VERSION}.gem escualo-#{Escualo::VERSION}.gem
RUN gem install escualo-#{Escualo::VERSION}.gem\n"
  else
    "RUN gem install escualo -v #{Escualo::VERSION}\n"
  end
end

#finish!Object



73
74
75
# File 'lib/escualo/script.rb', line 73

def finish!
  File.write('Dockerfile', @dockerfile)
end

#run_command!(command, ssh, options) ⇒ Object



69
70
71
# File 'lib/escualo/script.rb', line 69

def run_command!(command, ssh, options)
  @dockerfile << "RUN #{command}\n"
end

#start!(options) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/escualo/script.rb', line 41

def start!(options)
  @dockerfile = "
FROM #{base_image options}
MAINTAINER #{ENV['USER']}
RUN apt-get update && apt-get install ruby ruby-dev build-essential -y
#{escualo_install options}"
end