Skip to content

Commit 8e26d14

Browse files
authored
(ansible): update ansible base images to use multi-stage builds (#6333)
* update ansible base images to multi-stage builds so that we can ensure all packages are always included in the images we deliver by installing/building all packages in a build stage and copying them over to the final build stage. fixes #6302 Signed-off-by: Bryce Palmer <bpalmer@redhat.com> * update 2.11 preview image changes Signed-off-by: Bryce Palmer <bpalmer@redhat.com> --------- Signed-off-by: Bryce Palmer <bpalmer@redhat.com>
1 parent 5049e10 commit 8e26d14

File tree

3 files changed

+80
-29
lines changed

3 files changed

+80
-29
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# entries is a list of entries to include in
2+
# release notes and/or the migration guide
3+
entries:
4+
- description: >
5+
For ansible operators: fix a bug where the quay.io/operator-framework/ansible-operator image did not
6+
include the cryptography package on ppc64le & s390x architectures.
7+
8+
# kind is one of:
9+
# - addition
10+
# - change
11+
# - deprecation
12+
# - removal
13+
# - bugfix
14+
kind: "bugfix"
15+
16+
# Is this a breaking change?
17+
breaking: false

images/ansible-operator-2.11-preview/base.Dockerfile

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,12 @@
22
# It is built with dependencies that take a while to download, thus speeding
33
# up ansible deploy jobs.
44

5-
FROM registry.access.redhat.com/ubi8/ubi:8.7
6-
ARG TARGETARCH
7-
8-
# Label this image with the repo and commit that built it, for freshmaking purposes.
9-
ARG GIT_COMMIT=devel
10-
LABEL git_commit=$GIT_COMMIT
11-
12-
RUN mkdir -p /etc/ansible \
13-
&& echo "localhost ansible_connection=local" > /etc/ansible/hosts \
14-
&& echo '[defaults]' > /etc/ansible/ansible.cfg \
15-
&& echo 'roles_path = /opt/ansible/roles' >> /etc/ansible/ansible.cfg \
16-
&& echo 'library = /usr/share/ansible/openshift' >> /etc/ansible/ansible.cfg
5+
FROM registry.access.redhat.com/ubi8/ubi:8.7 AS builder
176

7+
# Install Rust so that we can ensure backwards compatibility with installing/building the cryptography wheel across all platforms
8+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
9+
ENV PATH="/root/.cargo/bin:${PATH}"
10+
RUN rustc --version
1811

1912
# Copy python dependencies (including ansible) to be installed using Pipenv
2013
COPY Pipfile* ./
@@ -30,14 +23,38 @@ ENV PIP_NO_CACHE_DIR=1 \
3023
RUN set -e && yum clean all && rm -rf /var/cache/yum/* \
3124
&& yum update -y \
3225
&& yum install -y libffi-devel openssl-devel python38-devel gcc python38-pip python38-setuptools \
33-
&& pip3 install --upgrade pip~=21.1.0 \
34-
&& pip3 install pipenv==2022.1.8 \
26+
&& pip3 install --upgrade pip~=23.0.1 \
27+
&& pip3 install pipenv==2023.2.18 \
3528
&& pipenv install --deploy \
36-
&& pipenv check -i 45114 \
29+
&& pipenv check -i 42926 -i 42923 -i 45114 \
3730
&& yum remove -y gcc libffi-devel openssl-devel python38-devel \
3831
&& yum clean all \
3932
&& rm -rf /var/cache/yum
4033

34+
FROM registry.access.redhat.com/ubi8/ubi:8.7
35+
ARG TARGETARCH
36+
37+
# Label this image with the repo and commit that built it, for freshmaking purposes.
38+
ARG GIT_COMMIT=devel
39+
LABEL git_commit=$GIT_COMMIT
40+
41+
RUN mkdir -p /etc/ansible \
42+
&& echo "localhost ansible_connection=local" > /etc/ansible/hosts \
43+
&& echo '[defaults]' > /etc/ansible/ansible.cfg \
44+
&& echo 'roles_path = /opt/ansible/roles' >> /etc/ansible/ansible.cfg \
45+
&& echo 'library = /usr/share/ansible/openshift' >> /etc/ansible/ansible.cfg
46+
47+
RUN set -e && yum clean all && rm -rf /var/cache/yum/* \
48+
&& yum update -y \
49+
&& yum install -y python38-pip python38-setuptools \
50+
&& pip3 install --upgrade pip~=23.0.1 \
51+
&& pip3 install pipenv==2023.2.18 \
52+
&& yum clean all \
53+
&& rm -rf /var/cache/yum
54+
55+
COPY --from=builder /usr/local/lib64/python3.8/site-packages /usr/local/lib64/python3.8/site-packages
56+
COPY --from=builder /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages
57+
4158
ENV TINI_VERSION=v0.19.0
4259
RUN curl -L -o /tini https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${TARGETARCH} \
4360
&& chmod +x /tini && /tini --version

images/ansible-operator/base.Dockerfile

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,12 @@
22
# It is built with dependencies that take a while to download, thus speeding
33
# up ansible deploy jobs.
44

5-
FROM registry.access.redhat.com/ubi8/ubi:8.7
6-
ARG TARGETARCH
7-
8-
# Label this image with the repo and commit that built it, for freshmaking purposes.
9-
ARG GIT_COMMIT=devel
10-
LABEL git_commit=$GIT_COMMIT
11-
12-
RUN mkdir -p /etc/ansible \
13-
&& echo "localhost ansible_connection=local" > /etc/ansible/hosts \
14-
&& echo '[defaults]' > /etc/ansible/ansible.cfg \
15-
&& echo 'roles_path = /opt/ansible/roles' >> /etc/ansible/ansible.cfg \
16-
&& echo 'library = /usr/share/ansible/openshift' >> /etc/ansible/ansible.cfg
5+
FROM registry.access.redhat.com/ubi8/ubi:8.7 AS builder
176

7+
# Install Rust so that we can ensure backwards compatibility with installing/building the cryptography wheel across all platforms
8+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
9+
ENV PATH="/root/.cargo/bin:${PATH}"
10+
RUN rustc --version
1811

1912
# Copy python dependencies (including ansible) to be installed using Pipenv
2013
COPY Pipfile* ./
@@ -30,14 +23,38 @@ ENV PIP_NO_CACHE_DIR=1 \
3023
RUN set -e && yum clean all && rm -rf /var/cache/yum/* \
3124
&& yum update -y \
3225
&& yum install -y libffi-devel openssl-devel python38-devel gcc python38-pip python38-setuptools \
33-
&& pip3 install --upgrade pip~=21.1.0 \
34-
&& pip3 install pipenv==2022.1.8 \
26+
&& pip3 install --upgrade pip~=23.0.1 \
27+
&& pip3 install pipenv==2023.2.18 \
3528
&& pipenv install --deploy \
3629
&& pipenv check -i 42926 -i 42923 -i 45114 \
3730
&& yum remove -y gcc libffi-devel openssl-devel python38-devel \
3831
&& yum clean all \
3932
&& rm -rf /var/cache/yum
4033

34+
FROM registry.access.redhat.com/ubi8/ubi:8.7
35+
ARG TARGETARCH
36+
37+
# Label this image with the repo and commit that built it, for freshmaking purposes.
38+
ARG GIT_COMMIT=devel
39+
LABEL git_commit=$GIT_COMMIT
40+
41+
RUN mkdir -p /etc/ansible \
42+
&& echo "localhost ansible_connection=local" > /etc/ansible/hosts \
43+
&& echo '[defaults]' > /etc/ansible/ansible.cfg \
44+
&& echo 'roles_path = /opt/ansible/roles' >> /etc/ansible/ansible.cfg \
45+
&& echo 'library = /usr/share/ansible/openshift' >> /etc/ansible/ansible.cfg
46+
47+
RUN set -e && yum clean all && rm -rf /var/cache/yum/* \
48+
&& yum update -y \
49+
&& yum install -y python38-pip python38-setuptools \
50+
&& pip3 install --upgrade pip~=23.0.1 \
51+
&& pip3 install pipenv==2023.2.18 \
52+
&& yum clean all \
53+
&& rm -rf /var/cache/yum
54+
55+
COPY --from=builder /usr/local/lib64/python3.8/site-packages /usr/local/lib64/python3.8/site-packages
56+
COPY --from=builder /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages
57+
4158
ENV TINI_VERSION=v0.19.0
4259
RUN curl -L -o /tini https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${TARGETARCH} \
4360
&& chmod +x /tini && /tini --version

0 commit comments

Comments
 (0)