lib/kitchen/driver/docker.rb in kitchen-docker-2.6.0 vs lib/kitchen/driver/docker.rb in kitchen-docker-2.7.0

- old
+ new

@@ -55,13 +55,11 @@ default_config :private_key, File.join(Dir.pwd, '.kitchen', 'docker_id_rsa') default_config :public_key, File.join(Dir.pwd, '.kitchen', 'docker_id_rsa.pub') default_config :build_options, nil default_config :run_options, nil - default_config :use_sudo do |driver| - !driver.remote_socket? - end + default_config :use_sudo, false default_config :image do |driver| driver.default_image end @@ -200,12 +198,11 @@ end platform = case config[:platform] when 'debian', 'ubuntu' disable_upstart = <<-eos - RUN dpkg-divert --local --rename --add /sbin/initctl - RUN ln -sf /bin/true /sbin/initctl + RUN [ ! -f "/sbin/initctl" ] || dpkg-divert --local --rename --add /sbin/initctl && ln -sf /bin/true /sbin/initctl eos packages = <<-eos ENV DEBIAN_FRONTEND noninteractive ENV container docker RUN apt-get update @@ -215,37 +212,44 @@ when 'rhel', 'centos', 'fedora' <<-eos ENV container docker RUN yum clean all RUN yum install -y sudo openssh-server openssh-clients which curl - RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' - RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' + RUN [ -f "/etc/ssh/ssh_host_rsa_key" ] || ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' + RUN [ -f "/etc/ssh/ssh_host_dsa_key" ] || ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' eos + when 'opensuse', 'sles' + <<-eos + ENV container docker + RUN zypper install -y sudo openssh which curl + RUN [ -f "/etc/ssh/ssh_host_rsa_key" ] || ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' + RUN [ -f "/etc/ssh/ssh_host_dsa_key" ] || ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' + eos when 'arch' # See https://bugs.archlinux.org/task/47052 for why we # blank out limits.conf. <<-eos RUN pacman --noconfirm -Sy archlinux-keyring RUN pacman-db-upgrade RUN pacman --noconfirm -Sy openssl openssh sudo curl - RUN ssh-keygen -A -t rsa -f /etc/ssh/ssh_host_rsa_key - RUN ssh-keygen -A -t dsa -f /etc/ssh/ssh_host_dsa_key + RUN [ -f "/etc/ssh/ssh_host_rsa_key" ] || ssh-keygen -A -t rsa -f /etc/ssh/ssh_host_rsa_key + RUN [ -f "/etc/ssh/ssh_host_dsa_key" ] || ssh-keygen -A -t dsa -f /etc/ssh/ssh_host_dsa_key RUN echo >/etc/security/limits.conf eos when 'gentoo' <<-eos - RUN emerge sync + RUN emerge --sync RUN emerge net-misc/openssh app-admin/sudo - RUN ssh-keygen -A -t rsa -f /etc/ssh/ssh_host_rsa_key - RUN ssh-keygen -A -t dsa -f /etc/ssh/ssh_host_dsa_key + RUN [ -f "/etc/ssh/ssh_host_rsa_key" ] || ssh-keygen -A -t rsa -f /etc/ssh/ssh_host_rsa_key + RUN [ -f "/etc/ssh/ssh_host_dsa_key" ] || ssh-keygen -A -t dsa -f /etc/ssh/ssh_host_dsa_key eos when 'gentoo-paludis' <<-eos RUN cave sync RUN cave resolve -zx net-misc/openssh app-admin/sudo - RUN ssh-keygen -A -t rsa -f /etc/ssh/ssh_host_rsa_key - RUN ssh-keygen -A -t dsa -f /etc/ssh/ssh_host_dsa_key + RUN [ -f "/etc/ssh/ssh_host_rsa_key" ] || ssh-keygen -A -t rsa -f /etc/ssh/ssh_host_rsa_key + RUN [ -f "/etc/ssh/ssh_host_dsa_key" ] || ssh-keygen -A -t dsa -f /etc/ssh/ssh_host_dsa_key eos else raise ActionFailed, "Unknown platform '#{config[:platform]}'" end @@ -305,11 +309,11 @@ build_context = config[:build_context] ? '.' : '-' file = Tempfile.new('Dockerfile-kitchen', Dir.pwd) output = begin file.write(dockerfile) file.close - docker_command("#{cmd} -f #{Shellwords.escape(file.path)} #{build_context}", :input => dockerfile_contents) + docker_command("#{cmd} -f #{Shellwords.escape(dockerfile_path(file))} #{build_context}", :input => dockerfile_contents) ensure file.close unless file.closed? file.unlink end parse_image_id(output) @@ -406,9 +410,13 @@ when Array config.map {|c| config_to_options(c) }.join(' ') when Hash config.map {|k, v| Array(v).map {|c| "--#{k}=#{Shellwords.escape(c)}" }.join(' ') }.join(' ') end + end + + def dockerfile_path(file) + config[:build_context] ? Pathname.new(file.path).relative_path_from(Pathname.pwd).to_s : file.path end end end end