Module: Docker::Cli::DockerfileTemplate::DupGemBundlerEnv

Included in:
TemplateEngine
Defined in:
lib/docker/cli/dockerfile_template/dup_gem_bundler_env.rb

Instance Method Summary collapse

Instance Method Details

#dup_gem_bundler_env(&block) ⇒ Object

DSL entry by including into DockerfileTemplate module



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
34
35
36
37
38
39
# File 'lib/docker/cli/dockerfile_template/dup_gem_bundler_env.rb', line 8

def dup_gem_bundler_env(&block)
  if has_dev_gems?
    logger.debug "Detected development gems"

    #add_mandatory_key(:docker_root)
    #if not has_mandatory_keys? and block
    #  @docker_root = block.call(:docker_root)
    #else
      raise TemplateKeyRequired, "docker_root is required for dup_gem_bundler_env to function" if is_empty?(@docker_root)
    #end

    # gen shell script
    res = gen_script
    block.call(:script_output, res) if block
    localPath = File.join(Dir.getwd,"dup_gem_bundler_env.rb")
    File.open(localPath,"w") do |f|
      f.write res
    end

    inst = []
    # copy inside docker
    inst << "COPY #{File.basename(localPath)} /tmp/dup_gem_bundler_env.rb"
    # run the script
    inst << "RUN ruby /tmp/dup_gem_bundler_env.rb"
    # for the docker just this two lines
    # but the localPath must be there first before this two
    # lines can come into effect
    inst.join("\n")
  else
    ""
  end
end