From 0a87b3d42cf24189116b7c65e39b6d2a9d9126e4 Mon Sep 17 00:00:00 2001 From: Ashwin Das Date: Tue, 14 Nov 2023 11:32:59 -0500 Subject: [PATCH] add artcommon to install --- container/Dockerfile | 45 ++++++++++++++++++------------------- container/Dockerfile.dev | 2 +- container/Dockerfile.latest | 17 ++++++++------ 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/container/Dockerfile b/container/Dockerfile index 492500b..b89b02a 100644 --- a/container/Dockerfile +++ b/container/Dockerfile @@ -3,8 +3,8 @@ LABEL name="art-bot" \ description="art-bot container image" \ maintainer="OpenShift Automated Release Tooling (ART) Team " -# the build will need to run inside the firewall to access internal resources. -# install Red Hat IT Root CA and RCM repos +# This build will need to be run inside the firewall to access internal resources. +# Install Red Hat IT Root CA and RCM repos, runtime dependencies, and upgrade pip RUN curl -o /etc/pki/ca-trust/source/anchors/RH-IT-Root-CA.crt --fail -L \ https://certs.corp.redhat.com/certs/2015-IT-Root-CA.pem \ && curl -o /etc/pki/ca-trust/source/anchors/2022-IT-Root-CA.pem --fail -L \ @@ -16,15 +16,16 @@ RUN curl -o /etc/pki/ca-trust/source/anchors/RH-IT-Root-CA.crt --fail -L \ krb5-workstation git rsync \ python3 python3-certifi python3-rpm python3-rhmsg \ # development dependencies - gcc krb5-devel python3-devel python3-pip python3-setuptools \ - # other tools + gcc krb5-devel python3-devel python3-pip \ bash-completion vim tmux wget curl iputils procps-ng psmisc net-tools iproute \ # install brewkoji koji brewkoji \ - && dnf clean all + && dnf clean all \ + # upgrade pip + && pip3 install --upgrade pip +# Install OpenShift Client ARG OC_VERSION=candidate -# include oc client RUN wget -O /tmp/openshift-client-linux-"$OC_VERSION".tar.gz https://mirror.openshift.com/pub/openshift-v4/clients/ocp/"$OC_VERSION"/openshift-client-linux.tar.gz \ && tar -C /usr/local/bin -xzf /tmp/openshift-client-linux-"$OC_VERSION".tar.gz oc kubectl \ && rm /tmp/openshift-client-linux-"$OC_VERSION".tar.gz @@ -35,38 +36,36 @@ ARG USERNAME=dev ARG USER_UID=1000 ARG USER_GID=$USER_UID -# Create the "dev" user RUN groupadd --gid "$USER_GID" "$USERNAME" \ && useradd --uid "$USER_UID" --gid "$USER_GID" -m "$USERNAME" \ - # give access to its files - && mkdir -p /workspaces/art-bot \ - && mkdir -p /workspaces/{elliott,doozer}{,-working-dir} \ - && mkdir -p /home/"$USERNAME"/.config/{elliott,doozer,art-bot} \ - && mkdir -p /home/"$USERNAME"/.docker \ + && mkdir -p /workspaces/art-bot /workspaces/{elliott,doozer}{,-working-dir} \ + /home/"$USERNAME"/.config/{elliott,doozer,art-bot} /home/"$USERNAME"/.docker \ && chown -R "${USER_UID}:${USER_GID}" /home/"$USERNAME" /workspaces \ && chmod -R 0755 /home/"$USERNAME" \ && chmod -R 0777 /workspaces \ - # and allow it passwordless sudo - && echo "$USERNAME" ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/"$USERNAME" \ + && echo "$USERNAME ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/"$USERNAME" \ && chmod 0440 /etc/sudoers.d/"$USERNAME" -USER "$USER_UID" +# Set work directory WORKDIR /workspaces/art-bot -# install dependencies (allow even openshift's random user to see) -ENV PATH=/home/"$USERNAME"/.local/bin:/home/"$USERNAME"/bin:"$PATH" +# Clone art-tools and run install.sh script +RUN git clone https://github.com/openshift-eng/art-tools.git /art-tools \ + && cd /art-tools \ + && ./install.sh + +# Install dependencies from requirements.txt COPY requirements.txt ./ -RUN umask a+rx && pip3 install --upgrade \ - "git+https://github.com/openshift-eng/art-tools.git#egg=rh-doozer&subdirectory=doozer" \ - "git+https://github.com/openshift-eng/art-tools.git#egg=rh-elliott&subdirectory=elliott" \ - -r ./requirements.txt +RUN pip3 install --upgrade -r requirements.txt -# install art-bot and default configs +# Install art-bot and default configs COPY container/krb5-redhat.conf /etc/krb5.conf COPY . /tmp/art-bot -USER 0 RUN cp -r /tmp/art-bot/{artbotlib,art-bot.py,art_bot_dev.py} . \ && cp /tmp/art-bot/container/doozer-settings.yaml /home/"$USERNAME"/.config/doozer/settings.yaml \ && cp /tmp/art-bot/container/elliott-settings.yaml /home/"$USERNAME"/.config/elliott/settings.yaml \ && rm -rf /tmp/art-bot + +# Return to non-root user and final work directory USER "$USER_UID" +WORKDIR /workspaces/art-bot diff --git a/container/Dockerfile.dev b/container/Dockerfile.dev index d843301..164e310 100644 --- a/container/Dockerfile.dev +++ b/container/Dockerfile.dev @@ -13,7 +13,7 @@ USER "$USER_UID" # install dependencies (allow even openshift's random user to see) COPY requirements.txt requirements-dev.txt ./ -RUN umask a+rx && pip3 install --user --upgrade rh-doozer rh-elliott -r ./requirements.txt -r ./requirements-dev.txt +RUN umask a+rx && pip3 install --user --upgrade rh-doozer rh-elliott rh-artcommon -r ./requirements.txt -r ./requirements-dev.txt # install art-bot and default configs COPY container/krb5-redhat.conf /etc/krb5.conf diff --git a/container/Dockerfile.latest b/container/Dockerfile.latest index 2ae78d0..2aab1f2 100644 --- a/container/Dockerfile.latest +++ b/container/Dockerfile.latest @@ -11,19 +11,22 @@ ARG USER_GID=$USER_UID USER 0 -# install dependencies (allow even openshift's random user to see) +WORKDIR /art-tools +RUN git pull +RUN ./install.sh + +# Install dependencies from requirements.txt COPY requirements.txt ./ -RUN umask a+rx && pip3 install --upgrade \ - "git+https://github.com/openshift-eng/art-tools.git#egg=rh-doozer&subdirectory=doozer" \ - "git+https://github.com/openshift-eng/art-tools.git#egg=rh-elliott&subdirectory=elliott" \ - -r ./requirements.txt +RUN pip3 install --upgrade -r requirements.txt -# install art-bot and default configs +# Install art-bot and default configs COPY container/krb5-redhat.conf /etc/krb5.conf COPY . /tmp/art-bot -USER 0 RUN cp -r /tmp/art-bot/{artbotlib,art-bot.py,art_bot_dev.py} . \ && cp /tmp/art-bot/container/doozer-settings.yaml /home/"$USERNAME"/.config/doozer/settings.yaml \ && cp /tmp/art-bot/container/elliott-settings.yaml /home/"$USERNAME"/.config/elliott/settings.yaml \ && rm -rf /tmp/art-bot + +# Switch back to the non-root user and final work directory USER "$USER_UID" +WORKDIR /workspaces/art-bot \ No newline at end of file