This repository has been archived by the owner on Feb 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.j2
460 lines (377 loc) · 15.5 KB
/
Dockerfile.j2
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
FROM {{ base_image }}:{{ base_distro_tag }}
{% block labels %}
LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"
{% endblock %}
RUN . /etc/os-release;\
if [ "${PRETTY_NAME#{{ supported_distro_name }}}" = "$PRETTY_NAME" ]; then \
echo "Only releases \"{{ supported_distro_name }}\" are supported on {{ base_distro }}"; false; \
fi
# We use curl in this dockerfile so let configure it before first use
COPY curlrc /root/.curlrc
{% block base_lang %}
# NOTE(yoctozepto): use a UTF-8 (Unicode) locale like standard image installs do
# fixes issues arising from ascii fallback usage
ENV LANG en_US.UTF-8
{% endblock %}
{# NOTE(SamYaple): Avoid uid/gid conflicts by creating each user/group up front. #}
{# Specifics required such as homedir or shell are configured within the service specific image #}
{%- for name, user in users | dictsort() %}
{% if loop.first -%}RUN {% else %} && {% endif -%}
groupadd --force --gid {{ user.gid }} {{ user.group }} \
&& useradd -l -M --shell /usr/sbin/nologin --uid {{ user.uid }} --gid {{ user.gid }} {{ name }}
{%- if not loop.last %} \{% endif -%}
{%- endfor %}
LABEL kolla_version="{{ kolla_version }}"
{% import "macros.j2" as macros with context %}
{% block base_header %}{% endblock %}
ENV KOLLA_BASE_DISTRO={{ base_distro }} \
KOLLA_DISTRO_PYTHON_VERSION={{ distro_python_version }} \
KOLLA_BASE_ARCH={{ base_arch }}
#### 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)]$ "
{% if base_package_type == 'rpm' %}
# 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 :)
RUN cat /tmp/kolla_bashrc >> /etc/bashrc \
&& sed -i 's|^\(override_install_langs=.*\)|# \1|' /etc/dnf/dnf.conf
{% block base_dnf_conf %}
{% block base_yum_conf %}
COPY dnf.conf /etc/dnf/dnf.conf
{% endblock %}
{% endblock %}
#### BEGIN REPO ENABLEMENT
{% set base_yum_repo_files = [
] %}
{% set base_yum_url_packages = [
] %}
{% set base_yum_repo_keys = [
] %}
{% if base_arch == 'x86_64' %}
{% set base_yum_repo_files = [
'elasticsearch.repo',
'grafana.repo',
'influxdb.repo',
'mariadb.repo',
'proxysql.repo',
'rabbitmq_rabbitmq-server.repo',
'rabbitmq_rabbitmq-erlang.repo',
'td.repo',
] %}
# FIXME(mgoddard): Not available for CentOS 8 yet.
# 'crmsh.repo',
{% set base_yum_repo_keys = [
'https://artifacts.elastic.co/GPG-KEY-elasticsearch',
'https://packages.grafana.com/gpg.key',
'https://repos.influxdata.com/influxdb.key',
'https://downloads.mariadb.com/MariaDB/RPM-GPG-KEY-MariaDB',
'https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc',
'https://packages.treasuredata.com/GPG-KEY-td-agent',
'https://repo.proxysql.com/ProxySQL/repo_pub_key',
] %}
{% elif base_arch == 'aarch64' %}
{% set base_yum_repo_files = [
'elasticsearch.repo',
'grafana.repo',
'rabbitmq_rabbitmq-server.repo',
'td.repo',
] %}
{% set base_yum_repo_keys = [
'https://packages.grafana.com/gpg.key',
'https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc',
] %}
# FIXME(mgoddard): Not available for CentOS 8 yet.
#
# 'https://artifacts.elastic.co/GPG-KEY-elasticsearch',
#
{% elif base_arch == 'ppc64le' %}
{% set base_yum_repo_files = [
'rabbitmq_rabbitmq-server.repo',
] %}
# FIXME(mgoddard): Not available for CentOS 8 yet.
#
# 'elasticsearch.repo',
#
{% set base_yum_repo_keys = [
] %}
# FIXME(mgoddard): Not available for CentOS 8 yet.
#
# 'https://artifacts.elastic.co/GPG-KEY-elasticsearch',
#
{% endif %}
{%- for repo_file in base_yum_repo_files | customizable('yum_repo_files') %}
COPY {{ repo_file }} /etc/yum.repos.d/{{ repo_file }}
{%- endfor %}
# NOTE(hrw): 'rabbitmq-server' is 'noarch' so we can install it on ppc64le from
# repo for other architecture.
# NOTE(mjturek): tripleo-ci overrides these repos so the file would not exist
# in that case. We test for the file's existence to avoid sed failing in that case.
{% if base_arch == 'ppc64le' %}
RUN if [[ -e /etc/yum.repos.d/rabbitmq_rabbitmq-server.repo ]]; then \
sed -i -e 's/\$basearch/x86_64/g' /etc/yum.repos.d/rabbitmq_rabbitmq-server.repo; \
fi
{% endif %}
{% block base_centos_repo_overrides_post_copy %}{% endblock %}
# Install what is needed for en_US.UTF-8
{% block base_centos_distro_sync_and_languages %}
{% set base_centos_language_packages = [
'langpacks-en',
'glibc-all-langpacks'
] %}
# NOTE(hrw): this macro file drops all languages other than C.UTF-8 so horizon fails
# https://bugzilla.redhat.com/show_bug.cgi?id=1729770
RUN rm -f /etc/rpm/macros.image-language-conf \
&& {{ macros.install_packages(base_centos_language_packages | customizable("centos_language_packages"), chain=True, clean=False) }} \
&& {{ macros.rpm_security_update(clean_package_cache) }}
{% endblock %}
{{ macros.install_packages(base_yum_url_packages | customizable("yum_url_packages")) }}
{% for key in base_yum_repo_keys | customizable('yum_repo_keys') %}
{%- if loop.first %}RUN {% else %} && {% endif -%}
rpm --import {{ key }}
{%- if not loop.last %} \{% endif %}
{% endfor -%}
{% if install_metatype in ['rdo', 'mixed'] %}
{% for cmd in rpm_setup %}
{{ cmd }}
{% endfor %}
{% block base_centos_repo_overrides_post_rpm %}{% endblock %}
{% endif %}
{# endif for repo setup for all RHEL except RHEL OSP #}
{% if install_metatype == 'rhos' %}
{% block base_rhos_repo_enablement %}{% endblock %}
{% endif %}
{% if base_distro == 'centos' %}
{% block base_centos_gpg_key_import %}
{% endblock %}
{% set base_centos_yum_repo_keys = [
] %}
{% set base_centos_yum_repo_packages = [
'centos-release-openstack-{OPENSTACK_VERSION}',
'centos-release-opstools',
'epel-release',
] %}
# We need 'dnf-plugins-core' for 'dnf config-manager'
{% set base_centos_yum_repo_packages = base_centos_yum_repo_packages + [
'dnf-plugins-core'
] %}
{% set base_centos_yum_repos_to_enable = [
] %}
{% set base_centos_yum_repos_to_disable = [
'centos-advanced-virtualization',
'centos-ceph-{CEPH_VERSION}',
'centos-nfv-openvswitch',
'centos-opstools',
'centos-rabbitmq-38',
'epel',
'epel-modular',
] %}
{% if base_arch == 'x86_64' %}
{% set base_centos_yum_repos_to_disable = base_centos_yum_repos_to_disable + [
'influxdb',
] %}
{% endif %}
RUN {{ macros.install_packages(base_centos_yum_repo_packages | customizable("centos_yum_repo_packages"), chain=True, clean=False) }}
{%- for repo in base_centos_yum_repos_to_enable | customizable('centos_yum_repos_to_enable') %} && dnf config-manager --enable {{ repo }} {% endfor -%}
{%- for repo in base_centos_yum_repos_to_disable | customizable('centos_yum_repos_to_disable') %} && dnf config-manager --disable {{ repo }} {% endfor -%}
{%- for key in base_centos_yum_repo_keys | customizable('centos_yum_repo_keys') %} && rpm --import {{ key }} {% endfor %} \
{% block base_centos_repo_overrides_post_yum %}{% endblock -%}
&& {{ macros.rpm_security_update(clean_package_cache) }}
{%- endif %}
{# Endif for base_distro centos #}
{% if base_distro == 'rhel' %}
{% block base_rhel_package_installation %}{% endblock %}
{% endif %}
{# Endif for base_distro RHEL #}
#### END REPO ENABLEMENT
{# We are back to the basic if conditional here which is:
if base_package_type == 'rpm' #}
{% block base_redhat_binary_versionlock %}{% endblock %}
{% set base_centos_packages = [
'ca-certificates',
'curl',
'dumb-init',
'findutils',
'hostname',
'iproute',
'iscsi-initiator-utils',
'lsof',
'lvm2',
'ncurses',
'procps-ng',
'python3',
'python3-pip',
'socat',
'sudo',
'tar',
'util-linux-user',
'which'
] %}
# Install base packages
{{ macros.install_packages( base_centos_packages | customizable("centos_packages") | customizable("centos_binary_packages") | customizable("centos_source_packages") ) }}
{# endif for base_package_type rpm #}
{% elif base_package_type == 'deb' %}
# Customize PS1 bash shell
# - enlarge 'system users' range so 'haproxy' package will not complain
# see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=939470
# - enlarge 'system groups' range so 'hacluster' user added in
# https://review.opendev.org/c/openstack/kolla/+/802671
# can be in 'haclient' group with same high uid
RUN cat /tmp/kolla_bashrc >> /etc/bash.bashrc \
&& sed -i -e s/LAST_SYSTEM_UID=999/LAST_SYSTEM_UID=59999/g \
-e s/LAST_SYSTEM_GID=999/LAST_SYSTEM_GID=59999/g /etc/adduser.conf
# 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
{% block base_ubuntu_package_pre %}
# Need apt-transport-https and ca-certificates before replacing sources.list or
# apt-get update will not work if any repositories are accessed via HTTPS
{% set base_ubuntu_package_pre_packages = [
'apt-transport-https',
'ca-certificates',
'curl',
'dirmngr',
'gnupg'
] %}
{{ macros.install_packages(base_ubuntu_package_pre_packages | customizable("base_ubuntu_package_pre_packages")) }}
{% endblock %}
{% block base_ubuntu_package_sources_list %}
{% if base_distro == 'debian' or ( base_distro == 'ubuntu' and base_arch == 'x86_64' ) %}
COPY sources.list.{{ base_distro }} /etc/apt/sources.list
{% else %}
COPY sources.list.{{ base_distro }}.{{ base_arch }} /etc/apt/sources.list
{% endif %}
COPY sources.list /etc/apt/sources.list.d/kolla-custom.list
{% endblock %}
{% block base_debian_after_sources_list %}{% endblock %}
{# install Debian Openstack repos - they are not mirrored on CI #}
{% if base_distro == 'debian' %}
RUN apt update \
&& apt install -y --no-install-recommends extrepo \
&& extrepo enable openstack_{OPENSTACK_VERSION} \
&& apt purge -y extrepo \
&& apt --purge autoremove -y \
&& apt clean
{% endif %}
{% block base_ubuntu_package_apt_preferences %}
COPY apt_preferences.{{ base_distro }} /etc/apt/preferences
COPY apt_preferences /etc/apt/preferences.d/kolla-custom
{% endblock %}
{% set base_apt_packages = [
'apt-utils',
'curl',
'dumb-init',
'gawk',
'iproute2',
'kmod',
'lsof',
'lvm2',
'netbase',
'open-iscsi',
'procps',
'python3',
'python3-pip',
'socat',
'sudo',
'tgt'
] %}
{% if base_distro == 'ubuntu' %}
{# 391A9AA2147192839E9DB0315EDB1B62EC4926EA -- Canonical Cloud Archive Signing Key <[email protected]> #}
{# 46095ACC8548582C1A2699A9D27D666CD88E42B4 -- Elasticsearch (Elasticsearch Signing Key) <[email protected]> #}
{# 58118E89F3A912897C070ADBF76221572C52609D -- Docker Release Tool (releasedocker) <[email protected]> #}
{# 4D8EB5FDA37AB55F41A135203BF88A0C6A770882 -- Apache Qpid PPA Signing Key <[email protected]> #}
{# 901F9177AB97ACBE -- Treasure Data, Inc (Treasure Agent Official Signing key) <[email protected]> #}
{# A20F259AEB9C94BB -- Sensuapp (Freight) <[email protected]> #}
{# F1656F24C74CD1D8 -- MariaDB Signing Key <[email protected]> #}
{# F77F1EDA57EBB1CC -- Launchpad RabbitMQ Erlang PPA key #}
{# F6609E60DC62814E -- PackageCloud RabbitMQ repository key #}
{% set base_apt_keys = [
'391A9AA2147192839E9DB0315EDB1B62EC4926EA',
'46095ACC8548582C1A2699A9D27D666CD88E42B4',
'49B07274951063870A8B7EAE7B8AA1A344C05248',
'58118E89F3A912897C070ADBF76221572C52609D',
'4D8EB5FDA37AB55F41A135203BF88A0C6A770882',
'901F9177AB97ACBE',
'A20F259AEB9C94BB',
'F1656F24C74CD1D8',
'F77F1EDA57EBB1CC',
'F6609E60DC62814E',
] %}
{% set remote_apt_keys = [
'https://packages.grafana.com/gpg.key',
'https://repos.influxdata.com/influxdb.key',
] %}
{% elif base_distro == 'debian' %}
{% set base_apt_keys = [
'46095ACC8548582C1A2699A9D27D666CD88E42B4',
'F1656F24C74CD1D8',
'F77F1EDA57EBB1CC',
'F6609E60DC62814E',
] %}
{% set remote_apt_keys = [
'https://download.docker.com/linux/debian/gpg',
'https://packages.grafana.com/gpg.key',
'https://packages.treasuredata.com/GPG-KEY-td-agent',
'https://repos.influxdata.com/influxdb.key',
] %}
{% endif %}
{% block base_ubuntu_package_installation %}
{%- block base_ubuntu_package_key_installation %}
{% for key in base_apt_keys | customizable('apt_keys') %}
{%- if loop.first %}RUN {% else %} && {% endif %}apt-key adv --no-tty --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 {{ key }}
{%- if not loop.last %} \
{% endif -%}
{% endfor %}
{% for key in remote_apt_keys | customizable('remote_apt_keys') %}
{%- if loop.first %} RUN {% else %} && {% endif %}curl {{ key }} | apt-key add -
{%- if not loop.last %} \
{% endif -%}
{% endfor %}
{% endblock %}
RUN apt-get update \
&& apt-get -y install locales \
&& sed -e "s/# $LANG UTF-8/$LANG UTF-8/g" /etc/locale.gen -i \
&& locale-gen "$LANG" \
&& apt-get -y upgrade \
&& apt-get -y dist-upgrade \
&& {{ macros.install_packages(base_apt_packages | customizable('apt_packages'), True) }}
{% endblock %}
{# endif base_package_type deb #}
{% endif %}
{% if base_distro == 'centos' or base_distro == 'rhel' %}
RUN sed -ri '/-session(\s+)optional(\s+)pam_systemd.so/d' /etc/pam.d/system-auth \
&& sed -ri '/^[^#]/ s/systemd//g' /etc/nsswitch.conf
{% endif %}
COPY set_configs.py /usr/local/bin/kolla_set_configs
COPY start.sh /usr/local/bin/kolla_start
COPY copy_cacerts.sh /usr/local/bin/kolla_copy_cacerts
COPY httpd_setup.sh /usr/local/bin/kolla_httpd_setup
COPY sudoers /etc/sudoers
{% if use_dumb_init %}
ENTRYPOINT ["dumb-init", "--single-child", "--"]
{% endif %}
{% if docker_healthchecks %}
{% block healthcheck_installation %}
COPY healthcheck_curl healthcheck_filemod healthcheck_listen healthcheck_port healthcheck_socket /usr/local/bin/
RUN chmod 755 /usr/local/bin/healthcheck_*
{% endblock %}
{% endif %}
RUN sed -i 's/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/* \
&& sed -i 's/baseurl.*/baseurl=http:\/\/localhost:8080\/kolla_{OPENSTACK_VERSION}/g' /etc/yum.repos.d/* \
&& sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/* \
&& sed -i 's/#baseurl/baseurl/g' /etc/yum.repos.d/*
RUN echo "[global]" >>/etc/pip.conf && echo "index-url = http://localhost:9090/simple" >>/etc/pip.conf && echo "trusted-host = localhost" >> /etc/pip.conf
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 /usr/local/bin/kolla_copy_cacerts /usr/local/bin/kolla_httpd_setup \
&& chmod 440 /etc/sudoers \
&& mkdir -p /var/log/kolla \
&& chown :kolla /var/log/kolla \
&& chmod 2775 /var/log/kolla \
&& rm -f /tmp/kolla_bashrc
{% block base_footer %}{% endblock %}
CMD ["kolla_start"]