aboutsummaryrefslogtreecommitdiff
path: root/docker/base/Dockerfile.j2
blob: cddca0b650f4569ed8aa283c40cdea65a8a194a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
FROM {{ base_distro }}:{{ base_distro_tag }}
MAINTAINER {{ maintainer }}

LABEL kolla_version="{{ kolla_version }}"


{{ 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
RUN 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'] %}

# Customize PS1 bash shell
RUN 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

COPY ceph.yum.repo /etc/yum.repos.d/ceph.repo

RUN yum -y install http://repo.percona.com/release/7/RPMS/x86_64/percona-release-0.1-3.noarch.rpm

RUN rpm --import http://yum.mariadb.org/RPM-GPG-KEY-MariaDB \
    && rpm --import https://download.ceph.com/keys/release.asc \
    && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-Percona \
    && rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch

    {% 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 install -y epel-release yum-plugin-priorities \
    && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 \
    && 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 install -y \
        https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.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 install -y \
        tar \
        yum-utils \
        https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
    && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 \
    && yum clean all
RUN yum-config-manager --enable ol7_optional_latest ol7_addons
RUN yum install -y yum-plugin-priorities \
    && yum clean all

    {% endif %}
    {# Endif for base_distro oraclelinux #}

    {% if base_distro == 'fedora' %}

# Set up repositories
RUN yum install -y https://rdo.fedorapeople.org/rdo-release.rpm \
    && yum -y install dnf dnf-plugins-core \
    && yum -y install 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 update -y \
    && yum clean all

# Pin package versions
RUN yum install -y \
        yum-plugin-versionlock \
    && yum clean all
COPY versionlock.list /etc/yum/pluginconf.d/

    {% if install_type == 'binary' %}

# Install base packages
RUN yum install -y \
        sudo \
        which \
        python \
        python-jinja2 \
        python-kazoo \
        python-six \
        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 \
        python-jinja2 \
        python-kazoo \
        python-six \
        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'] %}

# 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

COPY sources.list /etc/apt/
COPY apt_preferences /etc/apt/preferences

RUN apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 199369E5404BD5FC7D2FE43BCBCB082A1BB943DB \
    && apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 391A9AA2147192839E9DB0315EDB1B62EC4926EA \
    && apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 430BDF5C56E7C94E848EE60C1C4CBDCDCD2EFD2A \
    && apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 08B73419AC32B4E966C1A330E84AC2C0460F3994 \
    && apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 46095ACC8548582C1A2699A9D27D666CD88E42B4 \
    && apt-get update \
    && apt-get upgrade -y \
    && apt-get dist-upgrade -y \
    && apt-get install -y --no-install-recommends \
        ca-certificates \
        python \
        python-jinja2 \
        python-kazoo \
        python-six \
        curl \
        open-iscsi \
        tgt \
        lvm2 \
    && apt-get clean \
    && 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 %}

COPY set_configs.py /usr/local/bin/kolla_set_configs
COPY start.sh /usr/local/bin/kolla_start
COPY sudoers /etc/sudoers
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

RUN rm -f /tmp/kolla_bashrc

CMD ["kolla_start"]