IBM / cloud-pak-deployer

Configuration-based installation of OpenShift and Cloud Pak for Data/Integration/Watson AIOps on various private and public cloud infrastructure providers. Deployment attempts to achieve the end-state defined in the configuration. If something fails along the way, you only need to restart the process to continue the deployment.
https://ibm.github.io/cloud-pak-deployer/
Apache License 2.0
130 stars 65 forks source link

CP4D 4.8.2+plus breaks Dockerfile #628

Closed israel-a-vizcarra closed 5 months ago

israel-a-vizcarra commented 5 months ago

Describe the bug When using CPD_OLM_UTILS_V2_IMAGE=cp.stg.icr.io/cp/cpd/olm-utils-v2:4.8.2 cp-deploy build breaks

The reason for the failure is because from this version the image is using rhel9 with python3.11 by default

Dockerfile contains references to installation of python3.8 which is not available in this version of rhel

To Reproduce Steps to reproduce the behavior:

  1. export CPD_OLM_UTILS_V2_IMAGE=cp.stg.icr.io/cp/cpd/olm-utils-v2:4.8.2
  2. Configure your cpd-config and cpd-status dirs (config file)
  3. Run cloud-pak-deployer/cp-deploy.sh build

Expected behavior cp-deploy.sh build should finish successfully

Actual behavior Failure while building image

Error:

[3/3] STEP 4/15: RUN yum install -y yum-utils python38 python38-pip &&     yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo &&     yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm &&     yum install -y tar sudo unzip wget jq skopeo httpd-tools git hostname bind-utils iproute procps-ng &&     pip3 install --upgrade pip &&     pip3 install jmespath pyyaml argparse python-benedict pyvmomi psutil &&     alternatives --set python /usr/bin/python3 &&     yum install -y vault &&     yum install -y nginx &&     curl -O https://download.java.net/java/GA/jdk9/9/binaries/openjdk-9_linux-x64_bin.tar.gz &&     tar -xvf openjdk-9_linux-x64_bin.tar.gz -C /usr &&     ln -fs /usr/jdk-9/bin/java /usr/bin/java &&     ln -fs /usr/jdk-9/bin/keytool /usr/bin/keytool &&     rm -f openjdk-9_linux-x64_bin.tar.gz &&     curl -O https://get.helm.sh/helm-v3.6.0-linux-amd64.tar.gz &&     tar -zxvf helm-v3.6.0-linux-amd64.tar.gz linux-amd64/helm &&     mv linux-amd64/helm helm &&     rm -f helm-v3.6.0-linux-amd64.tar.gz &&     chmod u+x helm &&     mv helm /usr/bin/ &&     yum clean all
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use subscription-manager to register.

Red Hat Universal Base Image 9 (RPMs) - BaseOS  251 kB/s | 514 kB     00:02    
Red Hat Universal Base Image 9 (RPMs) - AppStre 887 kB/s | 1.8 MB     00:02    
Red Hat Universal Base Image 9 (RPMs) - CodeRea 114 kB/s | 192 kB     00:01    
No match for argument: python38
No match for argument: python38-pip
Error: Unable to find a match: python38 python38-pip
Error: building at STEP "RUN yum install -y yum-utils python38 python38-pip &&     yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo &&     yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm &&     yum install -y tar sudo unzip wget jq skopeo httpd-tools git hostname bind-utils iproute procps-ng &&     pip3 install --upgrade pip &&     pip3 install jmespath pyyaml argparse python-benedict pyvmomi psutil &&     alternatives --set python /usr/bin/python3 &&     yum install -y vault &&     yum install -y nginx &&     curl -O https://download.java.net/java/GA/jdk9/9/binaries/openjdk-9_linux-x64_bin.tar.gz &&     tar -xvf openjdk-9_linux-x64_bin.tar.gz -C /usr &&     ln -fs /usr/jdk-9/bin/java /usr/bin/java &&     ln -fs /usr/jdk-9/bin/keytool /usr/bin/keytool &&     rm -f openjdk-9_linux-x64_bin.tar.gz &&     curl -O https://get.helm.sh/helm-v3.6.0-linux-amd64.tar.gz &&     tar -zxvf helm-v3.6.0-linux-amd64.tar.gz linux-amd64/helm &&     mv linux-amd64/helm helm &&     rm -f helm-v3.6.0-linux-amd64.tar.gz &&     chmod u+x helm &&     mv helm /usr/bin/ &&     yum clean all": while running runtime: exit status 1

Desktop (please complete the following information):

Additional context

I was able to fix the issue for that specific image using following Dockerfile. I am unclear on how to map that to make it retro compatible

# Container image including olm-utils
ARG CPD_OLM_UTILS_V1_IMAGE
ARG CPD_OLM_UTILS_V2_IMAGE

FROM registry.access.redhat.com/ubi8/ubi

FROM ${CPD_OLM_UTILS_V1_IMAGE} as olm-utils-v1

RUN cd /opt/ansible && \
    tar czf /tmp/opt-ansible-v1.tar.gz *

FROM ${CPD_OLM_UTILS_V2_IMAGE}

LABEL authors="Arthur Laimbock, \
            Markus Wiegleb, \
            Frank Ketelaars, \ 
            Jiri Petnik"

USER 0

# Install required packages, including HashiCorp Vault client
RUN yum install -y yum-utils python3.11 python3.11-pip && \
    sed -i "s|#!/usr/bin/python3|#!/usr/bin/python3.9|g" /usr/bin/yum-config-manager && \
    yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo && \
    yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
    yum install -y tar sudo unzip wget jq skopeo httpd-tools git hostname bind-utils iproute procps-ng && \
    pip3 install --upgrade pip && \
    pip3 install jmespath pyyaml argparse python-benedict pyvmomi psutil && \
    #alternatives --set python /usr/bin/python3 && \
    yum install -y vault && \
    yum install -y nginx && \
    curl -O https://download.java.net/java/GA/jdk9/9/binaries/openjdk-9_linux-x64_bin.tar.gz && \
    tar -xvf openjdk-9_linux-x64_bin.tar.gz -C /usr && \
    ln -fs /usr/jdk-9/bin/java /usr/bin/java && \
    ln -fs /usr/jdk-9/bin/keytool /usr/bin/keytool && \
    rm -f openjdk-9_linux-x64_bin.tar.gz && \
    curl -O https://get.helm.sh/helm-v3.6.0-linux-amd64.tar.gz && \
    tar -zxvf helm-v3.6.0-linux-amd64.tar.gz linux-amd64/helm && \
    mv linux-amd64/helm helm && \
    rm -f helm-v3.6.0-linux-amd64.tar.gz && \
    chmod u+x helm && \
    mv helm /usr/bin/ && \
    yum clean all

RUN ansible-galaxy collection install community.general community.crypto ansible.utils community.vmware kubernetes.core

VOLUME ["/Data"]

# Prepare directory that runs automation scripts
RUN mkdir -p /cloud-pak-deployer && \
    mkdir -p /Data && \
    mkdir -p /olm-utils

COPY . /cloud-pak-deployer/
COPY ./deployer-web/nginx.conf   /etc/nginx/

COPY --from=olm-utils-v1 /tmp/opt-ansible-v1.tar.gz /olm-utils/

RUN cd /opt/ansible && \
    tar czf /olm-utils/opt-ansible-v2.tar.gz *

RUN pip3 install -r /cloud-pak-deployer/deployer-web/requirements.txt > /tmp/deployer-web-pip-install.out 2>&1

ENV USER_UID=1001

RUN chown -R ${USER_ID}:0 /Data && \
    chown -R ${USER_ID}:0 /cloud-pak-deployer && \
    chmod -R ug+rwx /cloud-pak-deployer/docker-scripts && \
    chmod ug+rwx /cloud-pak-deployer/*.sh

# USER ${USER_UID}

ENTRYPOINT ["/cloud-pak-deployer/docker-scripts/container-bash.sh"]
fketelaars commented 5 months ago

@israel-a-vizcarra I removed the yum install python* as Python is already included in the olm-utils-v2 image. Can you try again using the airgap-misc branch?

israel-a-vizcarra commented 5 months ago

Worked fine with airpap-misc branch. Thanks @fketelaars


Successfully tagged localhost/cloud-pak-deployer:latest
f7c77a8fd892455e8ee862cc36d10c16d262e885249704fd18974de4f0def459
israel@Israels-MacBook-Pro cloud-pak-deployer % git branch
* (HEAD detached at origin/airgap-misc)
* ```