Class: DockerJockey::ImageHelper

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

Class Method Summary collapse

Class Method Details

.build1(from, entry, args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/image_helper.rb', line 5

def self.build1(from, entry, args)
  if args.length < 1
    raise "devo: image command requires image name and filename of script to run."
  end
  image_name = args[0]
  filename = args[1]
  # tmpdir = 'tmp/app'
  # FileUtils.mkdir_p tmpdir
  # DockerJockey.exec("cp -r . #{tmpdir}")
  entrypoint = [entry]
  entrypoint << filename if filename
  # exec("cp /scripts/lib/Dockerfile /tmp/app")
  dockerfile = "__Dockerfile__"
  File.open(dockerfile, 'w') { |file|
    file.write("FROM #{from}
    WORKDIR /app
    COPY . /app/
    ENTRYPOINT [ #{entrypoint.map{ |e| '"' + e + '"'}.join(', ') }  ]
    ")
  }
  # DockerJockey.exec("cat /tmp/app/Dockerfile")
  # DockerJockey.exec("ls -al /tmp/app")
  # FileUtils.cd(tmpdir) do
    DockerJockey.exec("docker version")
    DockerJockey.exec("docker build -t #{image_name} -f #{dockerfile} .")
  # end
  File.delete(dockerfile)

end