PageRenderTime 42ms CodeModel.GetById 8ms RepoModel.GetById 1ms app.codeStats 0ms

/docker/base/Dockerfile.j2

https://gitlab.com/mimizone/kolla
Jinja | 231 lines | 168 code | 53 blank | 10 comment | 10 complexity | 6b2a2f605c5b89023c4f40f9c181b023 MD5 | raw file
  1. FROM {{ base_distro }}:{{ base_distro_tag }}
  2. MAINTAINER {{ maintainer }}
  3. LABEL kolla_version="{{ kolla_version }}"
  4. {{ include_header }}
  5. ENV KOLLA_BASE_DISTRO {{ base_distro }}
  6. ENV KOLLA_INSTALL_TYPE {{ install_type }}
  7. ENV KOLLA_INSTALL_METATYPE {{ install_metatype }}
  8. #### Customize PS1 to be used with bash shell
  9. COPY kolla_bashrc /tmp/
  10. RUN cat /tmp/kolla_bashrc >> /etc/skel/.bashrc
  11. RUN cat /tmp/kolla_bashrc >> /root/.bashrc
  12. # PS1 var when used /bin/sh shell
  13. ENV PS1="$(tput bold)($(printenv KOLLA_SERVICE_NAME))$(tput sgr0)[$(id -un)@$(hostname -s) $(pwd)]$ "
  14. # For RPM Variants, enable the correct repositories - this should all be done
  15. # in the base image so repos are consistent throughout the system. This also
  16. # enables to provide repo overrides at a later date in a simple fashion if we
  17. # desire such functionality. I think we will :)
  18. {% if base_distro in ['fedora', 'centos', 'oraclelinux', 'rhel'] %}
  19. # Customize PS1 bash shell
  20. RUN cat /tmp/kolla_bashrc >> /etc/bashrc
  21. #### BEGIN REPO ENABLEMENT
  22. # Turns on Elasticsearch repos
  23. COPY elasticsearch.yum.repo /etc/yum.repos.d/elasticsearch.repo
  24. # Turns on Kibana repo
  25. COPY kibana.yum.repo /etc/yum.repos.d/kibana.yum.repo
  26. # Turns on MariaDB repos throughout the RPM build
  27. COPY mariadb.yum.repo /etc/yum.repos.d/MariaDB.repo
  28. RUN yum -y install http://repo.percona.com/release/7/RPMS/x86_64/percona-release-0.1-3.noarch.rpm
  29. RUN rpm --import http://yum.mariadb.org/RPM-GPG-KEY-MariaDB \
  30. && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-Percona \
  31. && rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
  32. {% if install_metatype in ['rdo', 'mixed'] %}
  33. {% for cmd in rpm_setup %}
  34. {{ cmd }}
  35. {% endfor %}
  36. {% endif %}
  37. {# endif for repo setup for all RHEL except RHEL OSP #}
  38. {% if install_metatype == 'rhos' %}
  39. # Turn on the RHOS 7.0 repo for RHOS
  40. RUN yum-config-manager --enable rhel-7-server-rpms \
  41. && yum-config-manager --enable rhel-7-server-openstack-7.0-rpms
  42. {% endif %}
  43. {% if base_distro == 'centos' %}
  44. RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 \
  45. && yum install -y \
  46. epel-release \
  47. yum-plugin-priorities \
  48. centos-release-ceph-hammer \
  49. centos-release-qemu-ev \
  50. && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 \
  51. && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Storage \
  52. && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization \
  53. && yum clean all
  54. {% endif %}
  55. {# Endif for base_distro centos #}
  56. {% if base_distro == 'rhel' %}
  57. # Enable couple required repositories for all RHEL builds
  58. # Turn on EPEL throughout the build
  59. RUN yum install -y \
  60. https://mirror.centos.org/centos-7/7/extras/x86_64/Packages/epel-release-7-5.noarch.rpm \
  61. && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 \
  62. && yum -y install yum-plugin-priorities \
  63. && yum clean all \
  64. && yum-config-manager --enable rhel-7-server-optional-rpms \
  65. && yum-config-manager --enable rhel-7-server-extras-rpms
  66. {% endif %}
  67. {# Endif for base_distro RHEL #}
  68. {% if base_distro == 'oraclelinux' %}
  69. COPY oraclelinux-extras.repo /etc/yum.repos.d/oraclelinux-extras.repo
  70. RUN yum install -y \
  71. tar \
  72. yum-utils \
  73. http://mirror.centos.org/centos-7/7/extras/x86_64/Packages/epel-release-7-5.noarch.rpm \
  74. && yum clean all \
  75. && rpm -Uvh --nodeps \
  76. http://mirror.centos.org/centos/7/extras/x86_64/Packages/centos-release-openstack-mitaka-1-2.el7.centos.noarch.rpm \
  77. http://mirror.centos.org/centos-7/7/extras/x86_64/Packages/centos-release-ceph-hammer-1.0-5.el7.centos.noarch.rpm \
  78. http://mirror.centos.org/centos-7/7/extras/x86_64/Packages/centos-release-qemu-ev-1.0-1.el7.noarch.rpm \
  79. http://mirror.centos.org/centos-7/7/extras/x86_64/Packages/centos-release-virt-common-1-1.el7.centos.noarch.rpm \
  80. http://mirror.centos.org/centos-7/7/extras/x86_64/Packages/centos-release-storage-common-1-2.el7.centos.noarch.rpm \
  81. && sed -i 's/\$releasever/7/g' /etc/yum.repos.d/CentOS-*.repo \
  82. && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 \
  83. && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Storage \
  84. && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization
  85. RUN yum-config-manager --enable ol7_optional_latest ol7_addons
  86. RUN yum install -y yum-plugin-priorities \
  87. && yum clean all
  88. {% endif %}
  89. {# Endif for base_distro oraclelinux #}
  90. {% if base_distro == 'fedora' %}
  91. # Set up repositories
  92. RUN yum install -y https://rdo.fedorapeople.org/rdo-release.rpm \
  93. && yum -y install dnf dnf-plugins-core \
  94. && yum -y install yum-plugin-priorities \
  95. && yum clean all
  96. {% endif %}
  97. {# Endif for base_distro fedora #}
  98. #### END REPO ENABLEMENT
  99. {# We are back to the basic if conditional here which is:
  100. if base_distro in ['fedora', 'centos', 'oraclelinux', 'rhel'] #}
  101. RUN yum update -y \
  102. && yum clean all
  103. # Pin package versions
  104. RUN yum install -y \
  105. yum-plugin-versionlock \
  106. && yum clean all
  107. COPY versionlock.list /etc/yum/pluginconf.d/
  108. {% if install_type == 'binary' %}
  109. # Install base packages
  110. RUN yum install -y \
  111. sudo \
  112. which \
  113. python \
  114. python-jinja2 \
  115. python-kazoo \
  116. python-six \
  117. lvm2 \
  118. scsi-target-utils \
  119. iscsi-initiator-utils \
  120. && yum clean all
  121. {% endif %}
  122. {# Endif for install_type binary #}
  123. {% if install_type == 'source' %}
  124. # Update packages
  125. RUN yum -y install \
  126. curl \
  127. python-jinja2 \
  128. python-kazoo \
  129. python-six \
  130. sudo \
  131. tar \
  132. which \
  133. lvm2 \
  134. scsi-target-utils \
  135. iscsi-initiator-utils \
  136. && yum clean all
  137. {% endif %}
  138. {# endif for install type is source for RPM based distros #}
  139. {# endif for base_distro centos,fedora,oraclelinux,rhel #}
  140. {% elif base_distro in ['ubuntu', 'debian'] %}
  141. # Customize PS1 bash shell
  142. RUN cat /tmp/kolla_bashrc >> /etc/bash.bashrc
  143. # This will prevent questions from being asked during the install
  144. ENV DEBIAN_FRONTEND noninteractive
  145. COPY sources.list /etc/apt/
  146. COPY apt_preferences /etc/apt/preferences
  147. RUN apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 199369E5404BD5FC7D2FE43BCBCB082A1BB943DB \
  148. && apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 391A9AA2147192839E9DB0315EDB1B62EC4926EA \
  149. && apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 430BDF5C56E7C94E848EE60C1C4CBDCDCD2EFD2A \
  150. && apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 08B73419AC32B4E966C1A330E84AC2C0460F3994 \
  151. && apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 46095ACC8548582C1A2699A9D27D666CD88E42B4 \
  152. && apt-get update \
  153. && apt-get upgrade -y \
  154. && apt-get dist-upgrade -y \
  155. && apt-get install -y --no-install-recommends \
  156. ca-certificates \
  157. python \
  158. python-jinja2 \
  159. python-kazoo \
  160. python-six \
  161. curl \
  162. open-iscsi \
  163. tgt \
  164. lvm2 \
  165. && apt-get clean \
  166. && sed -i "s|'purelib': '\$base/local/lib/python\$py_version_short/dist-packages',|'purelib': '\$base/lib/python\$py_version_short/dist-packages',|;s|'platlib': '\$platbase/local/lib/python\$py_version_short/dist-packages',|'platlib': '\$platbase/lib/python\$py_version_short/dist-packages',|;s|'headers': '\$base/local/include/python\$py_version_short/\$dist_name',|'headers': '\$base/include/python\$py_version_short/\$dist_name',|;s|'scripts': '\$base/local/bin',|'scripts': '\$base/bin',|;s|'data' : '\$base/local',|'data' : '\$base',|" /usr/lib/python2.7/distutils/command/install.py \
  167. && rm -rf /usr/lib/python2.7/site-packages \
  168. && ln -s dist-packages /usr/lib/python2.7/site-packages
  169. {% endif %}
  170. COPY set_configs.py /usr/local/bin/kolla_set_configs
  171. COPY start.sh /usr/local/bin/kolla_start
  172. COPY sudoers /etc/sudoers
  173. RUN touch /usr/local/bin/kolla_extend_start \
  174. && chmod 755 /usr/local/bin/kolla_start /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_set_configs \
  175. && chmod 440 /etc/sudoers \
  176. && groupadd kolla
  177. RUN rm -f /tmp/kolla_bashrc
  178. CMD ["kolla_start"]