Class: BoshJobDocker::DockerFile
- Inherits:
-
Object
- Object
- BoshJobDocker::DockerFile
- Defined in:
- lib/bosh_job_docker/docker_file.rb
Overview
Builds a Dockerfile.
Instance Method Summary collapse
- #add(src, dest) ⇒ Object
- #apt_get(packages) ⇒ Object
- #blank_line ⇒ Object
- #comment(text) ⇒ Object
- #env(name, value) ⇒ Object
- #from(image) ⇒ Object
-
#initialize ⇒ DockerFile
constructor
A new instance of DockerFile.
- #run(command) ⇒ Object
- #write(path) ⇒ Object
Constructor Details
#initialize ⇒ DockerFile
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_line ⇒ Object
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 |