Module: Kitchen::Docker::Helpers::DockerfileHelper
- Includes:
- Configurable
- Included in:
- Container::Linux
- Defined in:
- lib/kitchen/docker/helpers/dockerfile_helper.rb
Instance Method Summary collapse
- #almalinux_platform ⇒ Object
- #amazonlinux_platform ⇒ Object
- #arch_platform ⇒ Object
- #centosstream_platform ⇒ Object
- #debian_platform ⇒ Object
- #dockerfile_base_linux(username, homedir) ⇒ Object
- #dockerfile_platform ⇒ Object
- #fedora_platform ⇒ Object
- #gentoo_paludis_platform ⇒ Object
- #gentoo_platform ⇒ Object
- #opensuse_platform ⇒ Object
- #photonos_platform ⇒ Object
- #rhel_platform ⇒ Object
- #rockylinux_platform ⇒ Object
Instance Method Details
#almalinux_platform ⇒ Object
137 138 139 140 141 142 143 144 |
# File 'lib/kitchen/docker/helpers/dockerfile_helper.rb', line 137 def almalinux_platform <<-CODE ENV container=docker RUN yum clean all RUN yum install -y sudo openssh-server openssh-clients which RUN [ -f "/etc/ssh/ssh_host_rsa_key" ] || ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' CODE end |
#amazonlinux_platform ⇒ Object
119 120 121 122 123 124 125 126 |
# File 'lib/kitchen/docker/helpers/dockerfile_helper.rb', line 119 def amazonlinux_platform <<-CODE ENV container=docker RUN yum clean all RUN yum install -y --allowerasing sudo openssh-server openssh-clients which curl RUN [ -f "/etc/ssh/ssh_host_rsa_key" ] || ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' CODE end |
#arch_platform ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/kitchen/docker/helpers/dockerfile_helper.rb', line 54 def arch_platform <<-CODE RUN pacman --noconfirm -Sy archlinux-keyring RUN pacman-db-upgrade RUN pacman --noconfirm -Syu openssl openssh sudo curl RUN [ -f "/etc/ssh/ssh_host_rsa_key" ] || ssh-keygen -A -t rsa -f /etc/ssh/ssh_host_rsa_key CODE end |
#centosstream_platform ⇒ Object
128 129 130 131 132 133 134 135 |
# File 'lib/kitchen/docker/helpers/dockerfile_helper.rb', line 128 def centosstream_platform <<-CODE ENV container=docker RUN yum clean all RUN yum install -y sudo openssh-server openssh-clients which RUN [ -f "/etc/ssh/ssh_host_rsa_key" ] || ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' CODE end |
#debian_platform ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/kitchen/docker/helpers/dockerfile_helper.rb', line 63 def debian_platform disable_upstart = <<-CODE RUN [ ! -f "/sbin/initctl" ] || dpkg-divert --local --rename --add /sbin/initctl \ && ln -sf /bin/true /sbin/initctl CODE packages = <<-CODE ENV DEBIAN_FRONTEND=noninteractive ENV container=docker RUN apt-get update RUN apt-get install -y sudo openssh-server curl lsb-release CODE config[:disable_upstart] ? disable_upstart + packages : packages end |
#dockerfile_base_linux(username, homedir) ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/kitchen/docker/helpers/dockerfile_helper.rb', line 165 def dockerfile_base_linux(username, homedir) <<-CODE RUN if ! getent passwd #{username}; then \ useradd -d #{homedir} -m -s /bin/bash -p '*' #{username}; \ fi RUN mkdir -p /etc/sudoers.d RUN chmod 0750 /etc/sudoers.d RUN echo "#{username} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/#{username} RUN echo "Defaults !requiretty" >> /etc/sudoers.d/#{username} RUN mkdir -p #{homedir}/.ssh RUN chown -R #{username} #{homedir}/.ssh RUN chmod 0700 #{homedir}/.ssh RUN touch #{homedir}/.ssh/authorized_keys RUN chown #{username} #{homedir}/.ssh/authorized_keys RUN chmod 0600 #{homedir}/.ssh/authorized_keys RUN mkdir -p /run/sshd CODE end |
#dockerfile_platform ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/kitchen/docker/helpers/dockerfile_helper.rb', line 23 def dockerfile_platform case config[:platform] when "arch" arch_platform when "debian", "ubuntu" debian_platform when "fedora" fedora_platform when "gentoo" gentoo_platform when "gentoo-paludis" gentoo_paludis_platform when "opensuse/tumbleweed", "opensuse/leap", "opensuse", "sles" opensuse_platform when "rhel", "centos", "oraclelinux" rhel_platform when "amazonlinux" amazonlinux_platform when "centosstream" centosstream_platform when "almalinux" almalinux_platform when "rockylinux" rockylinux_platform when "photon" photonos_platform else raise ActionFailed, "Unknown platform '#{config[:platform]}'" end end |
#fedora_platform ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/kitchen/docker/helpers/dockerfile_helper.rb', line 77 def fedora_platform <<-CODE ENV container=docker RUN dnf clean all RUN dnf install -y sudo openssh-server openssh-clients which curl RUN [ -f "/etc/ssh/ssh_host_rsa_key" ] || ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' CODE end |
#gentoo_paludis_platform ⇒ Object
94 95 96 97 98 99 100 |
# File 'lib/kitchen/docker/helpers/dockerfile_helper.rb', line 94 def gentoo_paludis_platform <<-CODE RUN cave sync RUN cave resolve -zx net-misc/openssh app-admin/sudo RUN [ -f "/etc/ssh/ssh_host_rsa_key" ] || ssh-keygen -A -t rsa -f /etc/ssh/ssh_host_rsa_key CODE end |
#gentoo_platform ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/kitchen/docker/helpers/dockerfile_helper.rb', line 86 def gentoo_platform <<-CODE RUN emerge-webrsync RUN emerge --quiet --noreplace net-misc/openssh app-admin/sudo RUN [ -f "/etc/ssh/ssh_host_rsa_key" ] || ssh-keygen -A -t rsa -f /etc/ssh/ssh_host_rsa_key CODE end |
#opensuse_platform ⇒ Object
102 103 104 105 106 107 108 |
# File 'lib/kitchen/docker/helpers/dockerfile_helper.rb', line 102 def opensuse_platform <<-CODE ENV container=docker RUN zypper install -y sudo openssh which curl gawk RUN /usr/sbin/sshd-gen-keys-start CODE end |
#photonos_platform ⇒ Object
155 156 157 158 159 160 161 162 163 |
# File 'lib/kitchen/docker/helpers/dockerfile_helper.rb', line 155 def photonos_platform <<-CODE ENV container=docker RUN tdnf clean all RUN tdnf install -y sudo openssh-server openssh-clients which curl RUN [ -f "/etc/ssh/ssh_host_ecdsa_key" ] || ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N '' RUN [ -f "/etc/ssh/ssh_host_ed25519_key" ] || ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N '' CODE end |
#rhel_platform ⇒ Object
110 111 112 113 114 115 116 117 |
# File 'lib/kitchen/docker/helpers/dockerfile_helper.rb', line 110 def rhel_platform <<-CODE ENV container=docker RUN yum clean all RUN yum install -y sudo openssh-server openssh-clients which curl RUN [ -f "/etc/ssh/ssh_host_rsa_key" ] || ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' CODE end |
#rockylinux_platform ⇒ Object
146 147 148 149 150 151 152 153 |
# File 'lib/kitchen/docker/helpers/dockerfile_helper.rb', line 146 def rockylinux_platform <<-CODE ENV container=docker RUN yum clean all RUN yum install -y sudo openssh-server openssh-clients which RUN [ -f "/etc/ssh/ssh_host_rsa_key" ] || ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' CODE end |