Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add artcommon to install #161

Merged
merged 4 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 22 additions & 23 deletions container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ LABEL name="art-bot" \
description="art-bot container image" \
maintainer="OpenShift Automated Release Tooling (ART) Team <[email protected]>"

# 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 \
Expand All @@ -16,15 +16,17 @@ 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 \
gcc krb5-devel python3-devel python3-pip \
# other tools
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
Expand All @@ -35,38 +37,35 @@ 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
USER "$USER_UID"

# Set non-root user
USER "$USER_UID"
11 changes: 8 additions & 3 deletions container/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ ARG USERNAME=dev
ARG USER_UID=1000
ARG USER_GID=$USER_UID

USER "$USER_UID"
# Looks like we need a USER 0 here
USER 0
# Clone art-tools and run install.sh script
RUN cd art-tools \
&& git pull \
&& ./install.sh

# install dependencies (allow even openshift's random user to see)
# Install dependencies from requirements.txt
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 pip3 install --upgrade -r requirements.txt -r requirements-dev.txt

# install art-bot and default configs
COPY container/krb5-redhat.conf /etc/krb5.conf
Expand Down
26 changes: 18 additions & 8 deletions container/Dockerfile.latest
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,37 @@ FROM art-bot:base
# This build is meant to be based on an existing build and
# update just doozer, elliott, and art-bot.

# Update pip once in the start of this build
RUN pip3 install --upgrade pip

# use same non-root user from the initial install
ARG USERNAME=dev
# On Linux, replace with your actual UID, GID if not the default 1000
ARG USER_UID=1000
ARG USER_GID=$USER_UID

WORKDIR /workspaces/art-bot

RUN git config --global --add safe.directory /workspaces/art-bot/art-tools
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed if we use USER 0, need to check


# Looks like we need a USER 0 here
USER 0
# Clone art-tools and run install.sh script
RUN cd art-tools \
&& git pull \
&& ./install.sh

# install dependencies (allow even openshift's random user to see)
# 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
ashwindasr marked this conversation as resolved.
Show resolved Hide resolved

# 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
USER "$USER_UID"

# Switch back to the non-root user and final work directory
USER "$USER_UID"
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ cachetools
aiohttp>=3.7.3
requests_kerberos
PyYAML
requests
slack_bolt==1.15.1
pip_system_certs
fuzzywuzzy
Expand Down