lib/lint_trap/container/docker.rb in lint_trap-0.0.11 vs lib/lint_trap/container/docker.rb in lint_trap-0.0.13

- old
+ new

@@ -1,15 +1,27 @@ require_relative 'base' require 'pathname' +require 'open3' module LintTrap module Container # Acts like a container, without actually requiring a container. class Docker < Base - CONFIG_PATH = Pathname.new('/opt/lint_trap/config') - CODE_PATH = Pathname.new('/home/spin_cycle') + CONFIG_PATH = Pathname.new('/config') + CODE_PATH = Pathname.new('/src') + def pull + command = "docker pull #{image}" + Open3.popen2e(command) do |_, stdout, thread| + if thread.value.success? + true + else + raise ImagePullError.new(command, stdout.read) + end + end + end + def wrap(command) "docker run #{flags} #{image} #{command}" end def config_path(path) @@ -32,14 +44,15 @@ def flags [ # '-m', '50m', # memory # '-c', '1', # number of cpus + '--net="none"', '--privileged=false', '-v', "#{LOCAL_CONFIG_PATH}:#{CONFIG_PATH}", '-v', "#{repo_path}:#{CODE_PATH}", "--workdir=#{CODE_PATH}", - '--user=spin_cycle' + '--user=lint_trap' ].join(' ') end end end end