From 86a742760626e670ef7c2cc3d6aa5eebac8b847b Mon Sep 17 00:00:00 2001 From: Tullio Sebastiani Date: Tue, 4 Jun 2024 15:32:11 +0200 Subject: [PATCH] Dockerfile refactoring to build oc together with krkn Signed-off-by: Tullio Sebastiani added oc in /usr/local/bin as well Signed-off-by: Tullio Sebastiani fixed dumb docker build copy Signed-off-by: Tullio Sebastiani --- containers/Dockerfile | 44 ++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/containers/Dockerfile b/containers/Dockerfile index 63887395..b60d677a 100644 --- a/containers/Dockerfile +++ b/containers/Dockerfile @@ -1,31 +1,49 @@ +# azure-client FROM mcr.microsoft.com/azure-cli:latest as azure-cli +# oc build +FROM golang:1.22.2 AS oc-build +RUN apt-get update && apt-get install -y libkrb5-dev +WORKDIR /tmp +RUN git clone --branch release-4.18 https://github.com/openshift/oc.git +WORKDIR /tmp/oc +RUN make GO_REQUIRED_MIN_VERSION:= oc + FROM registry.access.redhat.com/ubi9/ubi:latest +# krkn version that will be built +ENV KRKN_VERSION v1.5.14 + ENV KUBECONFIG /root/.kube/config -# Copy azure client binary from azure-cli image -COPY --from=azure-cli /usr/local/bin/az /usr/bin/az +# update yum and install dependencies RUN yum update -y glibc glibc-common glibc-minimal-langpack runc RUN rpm -e --allmatches --nodeps --noscripts --notriggers python3-requests -# Install dependencies RUN yum install -y git python39 python3-pip jq gettext wget + +# get yq +RUN wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq + +# get kubectl +RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" &&\ + cp kubectl /usr/local/bin/kubectl && chmod +x /usr/local/bin/kubectl &&\ + cp kubectl /usr/bin/kubectl && chmod +x /usr/bin/kubectl + +# copy azure client binary from azure-cli image +COPY --from=azure-cli /usr/local/bin/az /usr/bin/az + +# copy oc client binary from oc-build image +COPY --from=oc-build /tmp/oc/oc /usr/bin/oc +COPY --from=oc-build /tmp/oc/oc /usr/local/bin/oc + +# krkn build RUN python3.9 -m pip install -U pip -RUN git clone https://github.com/krkn-chaos/krkn.git --branch v1.5.14 /root/kraken && \ +RUN git clone https://github.com/krkn-chaos/krkn.git --branch $KRKN_VERSION /root/kraken && \ mkdir -p /root/.kube WORKDIR /root/kraken RUN pip3.9 install -r requirements.txt RUN pip3.9 install virtualenv -RUN wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq - -# Get Kubernetes and OpenShift clients from stable releases -WORKDIR /tmp -RUN wget https://krkn-mirror.s3.us-west-2.amazonaws.com/oc/oc-krkn.tar.gz &&\ - tar xfvz oc-krkn.tar.gz && cp oc /usr/bin/oc && cp oc /usr/local/bin/oc -RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" &&\ - cp kubectl /usr/local/bin/kubectl && cp kubectl /usr/bin/kubectl WORKDIR /root/kraken - ENTRYPOINT ["python3.9", "run_kraken.py"] CMD ["--config=config/config.yaml"] \ No newline at end of file