kolla/docker/base/Dockerfile.j2
Jeffrey Zhang 6710bbeb7c Use dumb-init to manage the pid 1 process
Normally, when you launch a Docker container, the process you're
executing becomes PID 1, giving it the quirks and responsibilities that
come with being the init system for the container.

There are two common issues this presents:

* In most cases, signals won't be handled properly.
* Orphaned zombie processes aren't properly reaped.

the dumb-init acting like a simple init system. It launches a single
process and then proxies all received signals to a session rooted at
that child process.

Closes-Bug: #1614509
Change-Id: I9d3d04648e151ddc7c6732b92ffd3b6c9fe467ec
2016-08-20 17:27:17 +00:00

270 lines
9.5 KiB
Django/Jinja
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

FROM {{ base_image }}:{{ base_distro_tag }}
MAINTAINER {{ maintainer }}
LABEL kolla_version="{{ kolla_version }}"
{% block base_header %}{% endblock %}
{{ include_header }}
ENV KOLLA_BASE_DISTRO {{ base_distro }}
ENV KOLLA_INSTALL_TYPE {{ install_type }}
ENV KOLLA_INSTALL_METATYPE {{ install_metatype }}
#### Customize PS1 to be used with bash shell
COPY kolla_bashrc /tmp/
RUN cat /tmp/kolla_bashrc >> /etc/skel/.bashrc \
&& cat /tmp/kolla_bashrc >> /root/.bashrc
# PS1 var when used /bin/sh shell
ENV PS1="$(tput bold)($(printenv KOLLA_SERVICE_NAME))$(tput sgr0)[$(id -un)@$(hostname -s) $(pwd)]$ "
# For RPM Variants, enable the correct repositories - this should all be done
# in the base image so repos are consistent throughout the system. This also
# enables to provide repo overrides at a later date in a simple fashion if we
# desire such functionality. I think we will :)
{% if base_distro in ['fedora', 'centos', 'oraclelinux', 'rhel'] %}
RUN if [ $(awk '{match($0, /[0-9]+/,version)}END{print version[0]}' /etc/system-release) != "{{ supported_distro_release }}" ]; then \
echo "Only supported {{ supported_distro_release }} release on {{ base_distro }}"; false; \
fi \
&& cat /tmp/kolla_bashrc >> /etc/bashrc
#### BEGIN REPO ENABLEMENT
# Turns on Elasticsearch repos
COPY elasticsearch.yum.repo /etc/yum.repos.d/elasticsearch.repo
# Turns on Kibana repo
COPY kibana.yum.repo /etc/yum.repos.d/kibana.yum.repo
# Turns on MariaDB repos throughout the RPM build
COPY mariadb.yum.repo /etc/yum.repos.d/MariaDB.repo
# Turns on InfluxDB repos throughout the RPM build
COPY influxdb.yum.repo /etc/yum.repos.d/influxdb.repo
RUN yum -y install \
http://repo.percona.com/release/7/RPMS/x86_64/percona-release-0.1-3.noarch.rpm \
&& rpm --import http://yum.mariadb.org/RPM-GPG-KEY-MariaDB \
&& rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-Percona \
&& rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch \
&& rpm --import https://repos.influxdata.com/influxdb.key
{% if install_metatype in ['rdo', 'mixed'] %}
{% for cmd in rpm_setup %}
{{ cmd }}
{% endfor %}
{% endif %}
{# endif for repo setup for all RHEL except RHEL OSP #}
{% if install_metatype == 'rhos' %}
# Turn on the RHOS 7.0 repo for RHOS
RUN yum-config-manager --enable rhel-7-server-rpms \
&& yum-config-manager --enable rhel-7-server-openstack-7.0-rpms
{% endif %}
{% if base_distro == 'centos' %}
RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 \
&& yum -y install \
epel-release \
yum-plugin-priorities \
centos-release-ceph-hammer \
centos-release-qemu-ev \
&& rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 \
&& rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Storage \
&& rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization \
&& yum clean all
{% endif %}
{# Endif for base_distro centos #}
{% if base_distro == 'rhel' %}
# Enable couple required repositories for all RHEL builds
# Turn on EPEL throughout the build
RUN yum -y install \
https://mirror.centos.org/centos-7/7/extras/x86_64/Packages/epel-release-7-5.noarch.rpm \
&& rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 \
&& yum -y install \
yum-plugin-priorities \
&& yum clean all \
&& yum-config-manager --enable rhel-7-server-optional-rpms \
&& yum-config-manager --enable rhel-7-server-extras-rpms
{% endif %}
{# Endif for base_distro RHEL #}
{% if base_distro == 'oraclelinux' %}
COPY oraclelinux-extras.repo /etc/yum.repos.d/oraclelinux-extras.repo
RUN yum -y install \
tar \
yum-utils \
http://mirror.centos.org/centos-7/7/extras/x86_64/Packages/epel-release-7-5.noarch.rpm \
&& rpm -Uvh --nodeps \
http://buildlogs.centos.org/centos/7/cloud/x86_64/openstack-mitaka/centos-release-openstack-mitaka-1-3.el7.noarch.rpm \
http://mirror.centos.org/centos-7/7/extras/x86_64/Packages/centos-release-ceph-hammer-1.0-5.el7.centos.noarch.rpm \
http://mirror.centos.org/centos-7/7/extras/x86_64/Packages/centos-release-qemu-ev-1.0-1.el7.noarch.rpm \
http://mirror.centos.org/centos-7/7/extras/x86_64/Packages/centos-release-virt-common-1-1.el7.centos.noarch.rpm \
http://mirror.centos.org/centos-7/7/extras/x86_64/Packages/centos-release-storage-common-1-2.el7.centos.noarch.rpm \
&& sed -i 's/\$releasever/7/g' /etc/yum.repos.d/CentOS-*.repo \
&& rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 \
&& rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Storage \
&& rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization \
&& yum-config-manager --enable ol7_optional_latest ol7_addons \
&& yum -y install \
yum-plugin-priorities \
&& yum clean all
{% endif %}
{# Endif for base_distro oraclelinux #}
{% if base_distro == 'fedora' %}
# Set up repositories
RUN yum -y install \
https://rdo.fedorapeople.org/rdo-release.rpm \
dnf \
dnf-plugins-core \
yum-plugin-priorities \
&& yum clean all
{% endif %}
{# Endif for base_distro fedora #}
#### END REPO ENABLEMENT
{# We are back to the basic if conditional here which is:
if base_distro in ['fedora', 'centos', 'oraclelinux', 'rhel'] #}
RUN yum -y update \
&& yum -y install \
yum-plugin-versionlock \
&& yum clean all
COPY versionlock.list /etc/yum/pluginconf.d/
{% if install_type == 'binary' %}
# Install base packages
RUN yum -y install \
sudo \
which \
python \
lvm2 \
scsi-target-utils \
iscsi-initiator-utils \
&& yum clean all
{% endif %}
{# Endif for install_type binary #}
{% if install_type == 'source' %}
# Update packages
RUN yum -y install \
curl \
sudo \
tar \
which \
lvm2 \
scsi-target-utils \
iscsi-initiator-utils \
&& yum clean all
{% endif %}
{# endif for install type is source for RPM based distros #}
{# endif for base_distro centos,fedora,oraclelinux,rhel #}
{% elif base_distro in ['ubuntu', 'debian'] %}
RUN if [ $(awk -F '=' '/DISTRIB_RELEASE/{print $2}' /etc/lsb-release) != "{{ supported_distro_release }}" ]; then \
echo "Only supported {{ supported_distro_release }} release on {{ base_distro }}"; false; fi
# Customize PS1 bash shell
RUN cat /tmp/kolla_bashrc >> /etc/bash.bashrc
# This will prevent questions from being asked during the install
ENV DEBIAN_FRONTEND noninteractive
# Reducing disk footprint
COPY dpkg_reducing_disk_footprint /etc/dpkg/dpkg.cfg.d/dpkg_reducing_disk_footprint
# Need apt-transport-https BEFORE we replace sources.list or apt-get update wont work!
RUN apt-get update && apt-get -y install --no-install-recommends apt-transport-https ca-certificates
COPY sources.list.{{ base_distro }} /etc/apt/sources.list
COPY apt_preferences.{{ base_distro }} /etc/apt/preferences
{% set base_apt_packages = [
'curl',
'gawk',
'kmod',
'lvm2',
'open-iscsi',
'python',
'sudo',
'tgt']
%}
{% if base_distro == 'ubuntu' %}
{% set base_apt_keys = [
'0xF1656F24C74CD1D8',
'391A9AA2147192839E9DB0315EDB1B62EC4926EA',
'430BDF5C56E7C94E848EE60C1C4CBDCDCD2EFD2A',
'08B73419AC32B4E966C1A330E84AC2C0460F3994',
'46095ACC8548582C1A2699A9D27D666CD88E42B4',
'58118E89F3A912897C070ADBF76221572C52609D',
'05CE15085FC09D18E99EFB22684A14CF2582E0C5',
] %}
{% elif base_distro == 'debian' %}
{% set base_apt_keys = [
'08B73419AC32B4E966C1A330E84AC2C0460F3994',
'58118E89F3A912897C070ADBF76221572C52609D',
'0xcbcb082a1bb943db',
'D27D666CD88E42B4',
'05CE15085FC09D18E99EFB22684A14CF2582E0C5',
] %}
{% set base_apt_packages = base_apt_packages +
['sudo',]
%}
{% endif %}
{% block base_ubuntu_package_installation %}
RUN true \
{% for key in base_apt_keys %}
&& apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 {{ key }} \
{% endfor %}
&& apt-get update \
&& apt-get -y upgrade \
&& apt-get -y dist-upgrade \
&& apt-get -y install --no-install-recommends {% for package in base_apt_packages %}{{ package }} {% endfor %} \
&& apt-get clean
{% endblock %}
{% if base_distro == 'ubuntu' %}
RUN 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 \
&& rm -rf /usr/lib/python2.7/site-packages \
&& ln -s dist-packages /usr/lib/python2.7/site-packages
{% endif %}
{# endif for base_distro ubuntu, debian #}
{% endif %}
COPY set_configs.py /usr/local/bin/kolla_set_configs
COPY start.sh /usr/local/bin/kolla_start
COPY sudoers /etc/sudoers
COPY curlrc /root/.curlrc
RUN touch /usr/local/bin/kolla_extend_start \
&& chmod 755 /usr/local/bin/kolla_start /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_set_configs \
&& chmod 440 /etc/sudoers \
&& groupadd kolla \
&& rm -f /tmp/kolla_bashrc \
&& curl -sSL https://github.com/Yelp/dumb-init/releases/download/v1.1.3/dumb-init_1.1.3_amd64 -o /usr/local/bin/dumb-init \
&& chmod +x /usr/local/bin/dumb-init
CMD ["kolla_start"]