Class: BoshJobDocker::DockerFile

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh_job_docker/docker_file.rb

Overview

Builds a Dockerfile.

Instance Method Summary collapse

Constructor Details

#initializeDockerFile

Returns a new instance of DockerFile.



8
9
10
# File 'lib/bosh_job_docker/docker_file.rb', line 8

def initialize
  @buffer = StringIO.new
end

Instance Method Details

#add(src, dest) ⇒ Object



19
20
21
# File 'lib/bosh_job_docker/docker_file.rb', line 19

def add(src, dest)
  line("ADD #{src} #{dest}")
end

#apt_get(packages) ⇒ Object



12
13
14
15
16
17
# File 'lib/bosh_job_docker/docker_file.rb', line 12

def apt_get(packages)
  packages.sort.each do |package|
    run("apt-get install -y #{package}")
  end
  blank_line
end

#blank_lineObject



36
37
38
# File 'lib/bosh_job_docker/docker_file.rb', line 36

def blank_line
  buffer << "\n"
end

#comment(text) ⇒ Object



40
41
42
# File 'lib/bosh_job_docker/docker_file.rb', line 40

def comment(text)
  line("# #{text}")
end

#env(name, value) ⇒ Object



23
24
25
# File 'lib/bosh_job_docker/docker_file.rb', line 23

def env(name, value)
  line("ENV #{name} #{value}")
end

#from(image) ⇒ Object



27
28
29
30
# File 'lib/bosh_job_docker/docker_file.rb', line 27

def from(image)
  line("FROM #{image}")
  blank_line
end

#run(command) ⇒ Object



32
33
34
# File 'lib/bosh_job_docker/docker_file.rb', line 32

def run(command)
  line("RUN #{command}")
end

#write(path) ⇒ Object



44
45
46
# File 'lib/bosh_job_docker/docker_file.rb', line 44

def write(path)
  open(path, 'w') { |f| f.write(buffer.string) }
end