Method: Cnvrg::Images#create_custom_image

Defined in:
lib/cnvrg/Images.rb

#create_custom_image(new_image_name, working_dir, stored_commands) ⇒ Object



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/cnvrg/Images.rb', line 195

def create_custom_image(new_image_name,working_dir,stored_commands)

  python2_arr = get_installed_packages("python2")
  py2 = python2_arr.join(",") unless python2_arr.nil? or python2_arr.empty?
  python3_arr = get_installed_packages("python3")
  py3 = python3_arr.join(",") unless python3_arr.nil? or python3_arr.empty?
  system_arr = get_installed_packages("system")
  sys = system_arr.join(",") unless system_arr.nil? or system_arr.empty?

  response = Cnvrg::API.request("users/#{@owner}/projects/#{@project_slug}/images/push", 'POST', {image_slug: @image_slug, py2: py2,py3:py3,
                                                                                         dpkg: sys, new_image_name: new_image_name,
                                                                                         run_commands:stored_commands})
  if Cnvrg::CLI.is_response_success(response) and !response["result"]["slug"].nil?
    container = get_container()
    name = response["result"]["name"]
    container = get_container()
    container.commit({repo:name,tag:"latest"})
    update_image(name+":latest", container, response["result"]["slug"])
    File.truncate(working_dir+"/.cnvrg/custom_image.txt", 0)

  end

  return true

end