From 4a91d768cf0782ecaa09b3e5c5b92c5c788d6cd8 Mon Sep 17 00:00:00 2001 From: Abolfazl Shahbazi <12436063+ashahba@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:56:55 -0800 Subject: [PATCH] Isolate AvatarChatbot stage builds issue Signed-off-by: Abolfazl Shahbazi <12436063+ashahba@users.noreply.github.com> --- AvatarChatbot/Dockerfile | 52 ++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/AvatarChatbot/Dockerfile b/AvatarChatbot/Dockerfile index b845296f70..3266bc296a 100644 --- a/AvatarChatbot/Dockerfile +++ b/AvatarChatbot/Dockerfile @@ -1,33 +1,49 @@ - - # Copyright (C) 2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -FROM python:3.11-slim +# Stage 1: base setup used by other stages +FROM python:3.11-slim AS base + +# get security updates +RUN apt-get update && apt-get upgrade -y && \ + apt-get clean && rm -rf /var/lib/apt/lists/* -RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ - libgl1-mesa-glx \ - libjemalloc-dev \ - vim \ - git +ENV HOME=/home/user RUN useradd -m -s /bin/bash user && \ - mkdir -p /home/user && \ - chown -R user /home/user/ + mkdir -p $HOME && \ + chown -R user $HOME -WORKDIR /home/user/ -RUN git clone https://github.com/opea-project/GenAIComps.git -WORKDIR /home/user/GenAIComps +WORKDIR $HOME -RUN pip install --no-cache-dir --upgrade pip && \ - pip install --no-cache-dir -r /home/user/GenAIComps/requirements.txt -COPY ./avatarchatbot.py /home/user/avatarchatbot.py +# Stage 2: latest GenAIComps sources +FROM base AS git + +RUN apt-get update && apt-get install -y --no-install-recommends git +RUN git clone --depth 1 https://github.com/opea-project/GenAIComps.git + -ENV PYTHONPATH=$PYTHONPATH:/home/user/GenAIComps +# Stage 3: common layer shared by services using GenAIComps +FROM base AS comps-base + +# copy just relevant parts +COPY --from=git $HOME/GenAIComps/comps $HOME/GenAIComps/comps +COPY --from=git $HOME/GenAIComps/*.* $HOME/GenAIComps/LICENSE $HOME/GenAIComps/ + +WORKDIR $HOME/GenAIComps +RUN pip install --no-cache-dir --upgrade pip && \ + pip install --no-cache-dir -r $HOME/GenAIComps/requirements.txt +WORKDIR $HOME + +ENV PYTHONPATH=$PYTHONPATH:$HOME/GenAIComps USER user -WORKDIR /home/user + +# Stage 4: unique part +FROM comps-base + +COPY ./avatarchatbot.py $HOME/avatarchatbot.py ENTRYPOINT ["python", "avatarchatbot.py"]