-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
125 lines (112 loc) · 4.36 KB
/
Dockerfile
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
ARG FROM=docker-remote.docker.mirantis.net/ubuntu:jammy
FROM $FROM as builder
SHELL ["/bin/bash", "-c"]
ARG TEST_IMAGE
ARG HELM_BINARY="https://binary.mirantis.com/openstack/bin/utils/helm/helm-v3.16.1-linux-amd64"
# NOTE(pas-ha) need Git for pbr to install from source checkout w/o sdist
ADD https://bootstrap.pypa.io/get-pip.py /tmp/get-pip.py
RUN apt-get update; \
apt-get -y upgrade
RUN apt-get install -y \
python3-distutils \
build-essential \
python3-dev \
libffi-dev \
libssl-dev \
libpcre3-dev \
wget \
git; \
python3 /tmp/get-pip.py
ADD . /opt/operator
RUN set -ex; \
EXTRA_DEPS=""; \
if [[ -d /opt/operator/source_requirements ]]; then \
echo "" > /opt/operator/source-requirements.txt; \
for req in $(ls -d /opt/operator/source_requirements/*/); do \
EXTRA_DEPS="${EXTRA_DEPS} $req"; \
pushd $req; \
req_name=$(python3 setup.py --name 2>/dev/null |grep -v "Generating ChangeLog"); \
req_version=$(python3 setup.py --version 2>/dev/null |grep -v "Generating ChangeLog"); \
popd; \
echo "$req_name==$req_version" >> /opt/operator/source-requirements.txt; \
done; \
else \
touch /opt/operator/source-requirements.txt; \
fi; \
if [[ -n "${EXTRA_DEPS}" ]]; then \
pip wheel --wheel-dir /opt/wheels --find-links /opt/wheels $EXTRA_DEPS; \
fi; \
IMAGE_TAG=$(/opt/operator/tools/get_version.sh); \
echo "${IMAGE_TAG}" > /opt/operator/image_tag.txt; \
rm -rf /opt/operator/source_requirements
RUN set -ex; \
OPENSTACK_CONTROLLER_EXTRAS=""; \
if [[ "${TEST_IMAGE}" == "True" ]]; then \
OPENSTACK_CONTROLLER_EXTRAS="[test]"; \
fi; \
pip wheel --wheel-dir /opt/wheels --find-links /opt/wheels /opt/operator${OPENSTACK_CONTROLLER_EXTRAS}
RUN wget -q -O /usr/local/bin/helm3 ${HELM_BINARY}; \
chmod +x /usr/local/bin/helm3
RUN set -ex; \
for req in $(ls -d /opt/operator/charts/{openstack,infra}/*/); do \
pushd $req; \
helm3 dep up; \
helm3 lint; \
popd; \
done
FROM $FROM
SHELL ["/bin/bash", "-c"]
ARG TEST_IMAGE
ARG USER=osctl
ARG UID=42424
COPY --from=builder /tmp/get-pip.py /tmp/get-pip.py
COPY --from=builder /opt/wheels /opt/wheels
COPY --from=builder /opt/operator/uwsgi.ini /opt/operator/uwsgi.ini
COPY --from=builder /opt/operator/source-requirements.txt /opt/operator/source-requirements.txt
COPY --from=builder /opt/operator/image_tag.txt /opt/operator/image_tag.txt
COPY --from=builder /opt/operator/etc/rockoon/ /etc/rockoon/
COPY --from=builder /opt/operator/charts/openstack/ /opt/operator/charts/openstack/
COPY --from=builder /opt/operator/charts/infra/ /opt/operator/charts/infra/
COPY --from=builder /usr/local/bin/helm3 /usr/local/bin/helm3
ADD kopf-patches /tmp/kopf-patches
RUN apt-get update; \
apt-get -y upgrade
# NOTE(pas-ha) apt-get download + dpkg-deb -x is a dirty hack
# to fetch distutils w/o pulling in most of python3.6
# FIXME(pas-ha) strace/gdb is installed only temporary for now for debugging
RUN set -ex; \
apt-get -q update; \
apt-get install -q -y --no-install-recommends --no-upgrade \
python3 \
python3-dbg \
libpython3.10 \
net-tools \
gdb \
patch \
strace \
ca-certificates \
wget \
git; \
apt-get download python3-distutils; \
dpkg-deb -x python3-distutils*.deb /; \
rm -vf python3-distutils*.deb; \
python3 /tmp/get-pip.py; \
pip install --no-index --no-cache --find-links /opt/wheels --pre -r /opt/operator/source-requirements.txt; \
OPENSTACK_CONTROLLER_PKG=rockoon; \
if [[ "${TEST_IMAGE}" == "True" ]]; then \
OPENSTACK_CONTROLLER_PKG=rockoon[test]; \
fi; \
pip install --no-index --no-cache --find-links /opt/wheels ${OPENSTACK_CONTROLLER_PKG}; \
cd /usr/local/lib/python3.10/dist-packages; \
for p in $(ls /tmp/kopf-patches/*.patch); do \
patch -p1 < $p; \
done; \
cd -; \
groupadd -g ${UID} ${USER}; \
useradd -u ${UID} -g ${USER} -m -d /var/lib/${USER} -c "${USER} user" ${USER}
RUN rm -rvf /tmp/kopf-patches
RUN rm -rvf /opt/wheels; \
apt-get -q clean; \
rm -rvf /var/lib/apt/lists/*; \
IMAGE_TAG=$(cat /opt/operator/image_tag.txt); \
sh -c "echo \"LABELS:\n IMAGE_TAG: ${IMAGE_TAG}\" > /dockerimage_metadata"