Class: Sneaql::Docker::LocalTransformDockerfile
- Inherits:
-
Object
- Object
- Sneaql::Docker::LocalTransformDockerfile
- Defined in:
- lib/sneaql_lib/docker.rb
Instance Method Summary collapse
- #create_dockerfile ⇒ Object
- #create_step_files ⇒ Object
- #dockerfile ⇒ Object
-
#initialize(repo_dir, repo_tag) ⇒ LocalTransformDockerfile
constructor
A new instance of LocalTransformDockerfile.
Constructor Details
#initialize(repo_dir, repo_tag) ⇒ LocalTransformDockerfile
Returns a new instance of LocalTransformDockerfile.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/sneaql_lib/docker.rb', line 7 def initialize(repo_dir, repo_tag) @repo_dir = repo_dir @repo_tag = repo_tag @steps = JSON.parse( File.read("#{repo_dir}/sneaql.json") ) create_step_files create_dockerfile end |
Instance Method Details
#create_dockerfile ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/sneaql_lib/docker.rb', line 40 def create_dockerfile Dir.chdir(@repo_dir) do puts "creating Dockerfile..." puts create_step_files puts dockerfile f = File.open('Dockerfile', 'w') f.puts(dockerfile) f.close puts puts "building docker image..." puts `docker build --no-cache -t #{@repo_tag} . ` #Docker::Image.build_from_dir('.') puts puts "image build complete" end end |
#create_step_files ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sneaql_lib/docker.rb', line 18 def create_step_files @step_files = [] @step_files << { docker_path: 'sneaql.json', local_path: 'sneaql.json' #File.expand_path("#{repo_dir}/sneaql.json") } @steps.each { |s| @step_files << { docker_path: s['step_file'], local_path: s['step_file'] # File.expand_path(s['step_file']) } } end |
#dockerfile ⇒ Object
33 34 35 36 37 38 |
# File 'lib/sneaql_lib/docker.rb', line 33 def dockerfile %{FROM full360/sneaql:latest RUN mkdir /repo #{@step_files.map {|s| "ADD #{s[:local_path]} /repo/#{s[:docker_path]}"}.join("\n")} } end |