class BoshJobDocker::DockerFile

Builds a Dockerfile.

Attributes

buffer[R]

Public Class Methods

new() click to toggle source
# File lib/bosh_job_docker/docker_file.rb, line 8
def initialize
  @buffer = StringIO.new
end

Public Instance Methods

add(src, dest) click to toggle source
# File lib/bosh_job_docker/docker_file.rb, line 19
def add(src, dest)
  line("ADD #{src} #{dest}")
end
apt_get(packages) click to toggle source
# 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_line() click to toggle source
# File lib/bosh_job_docker/docker_file.rb, line 36
def blank_line
  buffer << "\n"
end
comment(text) click to toggle source
# File lib/bosh_job_docker/docker_file.rb, line 40
def comment(text)
  line("# #{text}")
end
env(name, value) click to toggle source
# File lib/bosh_job_docker/docker_file.rb, line 23
def env(name, value)
  line("ENV #{name} #{value}")
end
from(image) click to toggle source
# File lib/bosh_job_docker/docker_file.rb, line 27
def from(image)
  line("FROM #{image}")
  blank_line
end
run(command) click to toggle source
# File lib/bosh_job_docker/docker_file.rb, line 32
def run(command)
  line("RUN #{command}")
end
write(path) click to toggle source
# File lib/bosh_job_docker/docker_file.rb, line 44
def write(path)
  open(path, 'w') { |f| f.write(buffer.string) }
end

Private Instance Methods

line(line) click to toggle source
# File lib/bosh_job_docker/docker_file.rb, line 50
def line(line)
  buffer << line
  buffer << "\n"
end