From 07051a7afb10a23fe866af9b38531ab18d1ae80b Mon Sep 17 00:00:00 2001 From: Eero Tamminen Date: Fri, 25 Oct 2024 18:54:52 +0300 Subject: [PATCH] Use staged builds to minimize final image size So that redundant things do not end in final image: - Git repo history - Test directories - Git tool and its deps And drop explicit installation of: - jemalloc & GLX: nothing uses them (in ChatQnA at least), and for testing it's trivial to create image adding those on top: https://pytorch.org/tutorials/recipes/recipes/tuning_guide.html#switch-memory-allocator - langchain_core: GenAIComps install langchain which already depends on that This demonstrates that only 2-3 lines in the Dockerfiles are unique, and everything before those can be removed with a common base image. Signed-off-by: Eero Tamminen --- AudioQnA/Dockerfile | 50 +++++++++++++++-------- AudioQnA/Dockerfile.multilang | 50 +++++++++++++++-------- AvatarChatbot/Dockerfile | 51 +++++++++++++++-------- ChatQnA/Dockerfile | 51 ++++++++++++++--------- ChatQnA/Dockerfile.guardrails | 51 ++++++++++++++--------- ChatQnA/Dockerfile.without_rerank | 51 ++++++++++++++--------- CodeGen/Dockerfile | 52 +++++++++++++++-------- CodeTrans/Dockerfile | 50 +++++++++++++++-------- DocIndexRetriever/Dockerfile | 48 +++++++++++++++------- DocSum/Dockerfile | 50 +++++++++++++++-------- FaqGen/Dockerfile | 49 ++++++++++++++-------- MultimodalQnA/Dockerfile | 48 +++++++++++++++------- SearchQnA/Dockerfile | 50 +++++++++++++++-------- Translation/Dockerfile | 68 +++++++++++++++++-------------- VideoQnA/Dockerfile | 49 ++++++++++++++-------- VisualQnA/Dockerfile | 50 +++++++++++++++-------- 16 files changed, 528 insertions(+), 290 deletions(-) diff --git a/AudioQnA/Dockerfile b/AudioQnA/Dockerfile index 265c9c9b5..666f0872f 100644 --- a/AudioQnA/Dockerfile +++ b/AudioQnA/Dockerfile @@ -1,32 +1,48 @@ - - # 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 -RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ - libgl1-mesa-glx \ - libjemalloc-dev \ - git +RUN apt-get update + +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 -WORKDIR /home/user/GenAIComps -RUN pip install --no-cache-dir --upgrade pip setuptools && \ - pip install --no-cache-dir -r /home/user/GenAIComps/requirements.txt -COPY ./audioqna.py /home/user/audioqna.py +# Stage 2: latest GenAIComps sources +FROM base AS git + +RUN 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 setuptools && \ + 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 ./audioqna.py $HOME/audioqna.py ENTRYPOINT ["python", "audioqna.py"] diff --git a/AudioQnA/Dockerfile.multilang b/AudioQnA/Dockerfile.multilang index ef7c92697..3f0b8af3e 100644 --- a/AudioQnA/Dockerfile.multilang +++ b/AudioQnA/Dockerfile.multilang @@ -1,32 +1,48 @@ - - # 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 -RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ - libgl1-mesa-glx \ - libjemalloc-dev \ - git +RUN apt-get update + +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 -WORKDIR /home/user/GenAIComps -RUN pip install --no-cache-dir --upgrade pip setuptools && \ - pip install --no-cache-dir -r /home/user/GenAIComps/requirements.txt -COPY ./audioqna_multilang.py /home/user/audioqna_multilang.py +# Stage 2: latest GenAIComps sources +FROM base AS git + +RUN 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 setuptools && \ + 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 ./audioqna_multilang.py $HOME/audioqna_multilang.py ENTRYPOINT ["python", "audioqna_multilang.py"] diff --git a/AvatarChatbot/Dockerfile b/AvatarChatbot/Dockerfile index b845296f7..690fa2d86 100644 --- a/AvatarChatbot/Dockerfile +++ b/AvatarChatbot/Dockerfile @@ -1,33 +1,48 @@ - - # 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 -RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ - libgl1-mesa-glx \ - libjemalloc-dev \ - vim \ - git +RUN apt-get update + +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 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"] diff --git a/ChatQnA/Dockerfile b/ChatQnA/Dockerfile index 4e431ac77..c88b054f0 100644 --- a/ChatQnA/Dockerfile +++ b/ChatQnA/Dockerfile @@ -1,35 +1,48 @@ - - # 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 + +RUN apt-get update -RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ - libgl1-mesa-glx \ - libjemalloc-dev \ - 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 -WORKDIR /home/user/GenAIComps -RUN pip install --no-cache-dir --upgrade pip setuptools && \ - pip install --no-cache-dir -r /home/user/GenAIComps/requirements.txt && \ - pip install --no-cache-dir langchain_core -COPY ./chatqna.py /home/user/chatqna.py +# Stage 2: latest GenAIComps sources +FROM base AS git + +RUN 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 setuptools && \ + pip install --no-cache-dir -r $HOME/GenAIComps/requirements.txt +WORKDIR $HOME + +ENV PYTHONPATH=$PYTHONPATH:$HOME/GenAIComps USER user -WORKDIR /home/user -RUN echo 'ulimit -S -n 999999' >> ~/.bashrc +# Stage 4: unique part +FROM comps-base + +COPY ./chatqna.py . ENTRYPOINT ["python", "chatqna.py"] diff --git a/ChatQnA/Dockerfile.guardrails b/ChatQnA/Dockerfile.guardrails index ed811148c..f50b8f3c1 100644 --- a/ChatQnA/Dockerfile.guardrails +++ b/ChatQnA/Dockerfile.guardrails @@ -1,35 +1,48 @@ - - # 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 -RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ - libgl1-mesa-glx \ - libjemalloc-dev \ - git +RUN apt-get update + +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 -WORKDIR /home/user/GenAIComps -RUN pip install --no-cache-dir --upgrade pip setuptools && \ - pip install --no-cache-dir -r /home/user/GenAIComps/requirements.txt && \ - pip install --no-cache-dir langchain_core -COPY ./chatqna.py /home/user/chatqna.py +# Stage 2: latest GenAIComps sources +FROM base AS git + +RUN 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 setuptools && \ + pip install --no-cache-dir -r $HOME/GenAIComps/requirements.txt +WORKDIR $HOME + +ENV PYTHONPATH=$PYTHONPATH:$HOME/GenAIComps USER user -WORKDIR /home/user -RUN echo 'ulimit -S -n 999999' >> ~/.bashrc +# Stage 4: unique part +FROM comps-base + +COPY ./chatqna.py /home/user/chatqna.py ENTRYPOINT ["python", "chatqna.py", "--with-guardrails"] diff --git a/ChatQnA/Dockerfile.without_rerank b/ChatQnA/Dockerfile.without_rerank index 7d3a94c5d..bd0a26149 100644 --- a/ChatQnA/Dockerfile.without_rerank +++ b/ChatQnA/Dockerfile.without_rerank @@ -1,35 +1,48 @@ - - # 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 -RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ - git \ - libgl1-mesa-glx \ - libjemalloc-dev +RUN apt-get update + +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 -WORKDIR /home/user/GenAIComps -RUN pip install --no-cache-dir --upgrade pip setuptools && \ - pip install --no-cache-dir -r /home/user/GenAIComps/requirements.txt && \ - pip install --no-cache-dir langchain_core -COPY ./chatqna.py /home/user/chatqna.py +# Stage 2: latest GenAIComps sources +FROM base AS git + +RUN 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 setuptools && \ + pip install --no-cache-dir -r $HOME/GenAIComps/requirements.txt +WORKDIR $HOME + +ENV PYTHONPATH=$PYTHONPATH:$HOME/GenAIComps USER user -WORKDIR /home/user -RUN echo 'ulimit -S -n 999999' >> ~/.bashrc +# Stage 4: unique part +FROM comps-base + +COPY ./chatqna.py /home/user/chatqna.py ENTRYPOINT ["python", "chatqna.py", "--without-rerank"] diff --git a/CodeGen/Dockerfile b/CodeGen/Dockerfile index e0aa7d13f..cce992cff 100644 --- a/CodeGen/Dockerfile +++ b/CodeGen/Dockerfile @@ -1,34 +1,50 @@ - - # 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 -ENV LANG=C.UTF-8 +RUN apt-get update -RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ - libgl1-mesa-glx \ - libjemalloc-dev \ - 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 + + +# Stage 2: latest GenAIComps sources +FROM base AS git + +RUN apt-get install -y --no-install-recommends git + +RUN git clone --depth 1 https://github.com/opea-project/GenAIComps.git -WORKDIR /home/user/GenAIComps -RUN pip install --no-cache-dir --upgrade pip setuptools && \ - pip install --no-cache-dir -r /home/user/GenAIComps/requirements.txt -COPY ./codegen.py /home/user/codegen.py +# Stage 3: common layer shared by services using GenAIComps +FROM base AS comps-base -ENV PYTHONPATH=$PYTHONPATH:/home/user/GenAIComps +# 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 setuptools && \ + 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 + +ENV LANG=C.UTF-8 + +COPY ./codegen.py $HOME/codegen.py ENTRYPOINT ["python", "codegen.py"] diff --git a/CodeTrans/Dockerfile b/CodeTrans/Dockerfile index 918d936c9..ab8f52476 100644 --- a/CodeTrans/Dockerfile +++ b/CodeTrans/Dockerfile @@ -1,32 +1,48 @@ - - # 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 -RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ - libgl1-mesa-glx \ - libjemalloc-dev \ - git +RUN apt-get update + +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 -WORKDIR /home/user/GenAIComps -RUN pip install --no-cache-dir --upgrade pip setuptools && \ - pip install --no-cache-dir -r /home/user/GenAIComps/requirements.txt -COPY ./code_translation.py /home/user/code_translation.py +# Stage 2: latest GenAIComps sources +FROM base AS git + +RUN 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 setuptools && \ + 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 ./code_translation.py $HOME/code_translation.py ENTRYPOINT ["python", "code_translation.py"] diff --git a/DocIndexRetriever/Dockerfile b/DocIndexRetriever/Dockerfile index c8794f3ef..c3e5ec39c 100644 --- a/DocIndexRetriever/Dockerfile +++ b/DocIndexRetriever/Dockerfile @@ -1,30 +1,48 @@ # 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 -RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ - libgl1-mesa-glx \ - libjemalloc-dev \ - git +RUN apt-get update + +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 + + +# Stage 2: latest GenAIComps sources +FROM base AS git + +RUN apt-get install -y --no-install-recommends git + +RUN git clone --depth 1 https://github.com/opea-project/GenAIComps.git -WORKDIR /home/user/GenAIComps -RUN pip install --no-cache-dir --upgrade pip setuptools && \ - pip install --no-cache-dir -r /home/user/GenAIComps/requirements.txt -COPY ./retrieval_tool.py /home/user/retrieval_tool.py +# Stage 3: common layer shared by services using GenAIComps +FROM base AS comps-base -ENV PYTHONPATH=$PYTHONPATH:/home/user/GenAIComps +# 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 setuptools && \ + 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 ./retrieval_tool.py $HOME/retrieval_tool.py ENTRYPOINT ["python", "retrieval_tool.py"] diff --git a/DocSum/Dockerfile b/DocSum/Dockerfile index d0dac691c..769a5b6c4 100644 --- a/DocSum/Dockerfile +++ b/DocSum/Dockerfile @@ -1,32 +1,48 @@ - - # 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 -RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ - libgl1-mesa-glx \ - libjemalloc-dev \ - git +RUN apt-get update + +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 -WORKDIR /home/user/GenAIComps -RUN pip install --no-cache-dir --upgrade pip setuptools && \ - pip install --no-cache-dir -r /home/user/GenAIComps/requirements.txt -COPY ./docsum.py /home/user/docsum.py +# Stage 2: latest GenAIComps sources +FROM base AS git + +RUN 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 setuptools && \ + 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 ./docsum.py $HOME/docsum.py ENTRYPOINT ["python", "docsum.py"] diff --git a/FaqGen/Dockerfile b/FaqGen/Dockerfile index 4018b44d1..f8e4a67bf 100644 --- a/FaqGen/Dockerfile +++ b/FaqGen/Dockerfile @@ -1,33 +1,48 @@ - - # 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 +RUN apt-get update -RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ - libgl1-mesa-glx \ - libjemalloc-dev \ - 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 -WORKDIR /home/user/GenAIComps -RUN pip install --no-cache-dir --upgrade pip setuptools && \ - pip install --no-cache-dir -r /home/user/GenAIComps/requirements.txt -COPY ./faqgen.py /home/user/faqgen.py +# Stage 2: latest GenAIComps sources +FROM base AS git + +RUN 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 setuptools && \ + 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 ./faqgen.py $HOME/faqgen.py ENTRYPOINT ["python", "faqgen.py"] diff --git a/MultimodalQnA/Dockerfile b/MultimodalQnA/Dockerfile index 534203c96..1e0e5f942 100644 --- a/MultimodalQnA/Dockerfile +++ b/MultimodalQnA/Dockerfile @@ -1,31 +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 -RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ - libgl1-mesa-glx \ - libjemalloc-dev \ - git +RUN apt-get update + +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 + + +# Stage 2: latest GenAIComps sources +FROM base AS git + +RUN apt-get install -y --no-install-recommends git + +RUN git clone --depth 1 https://github.com/opea-project/GenAIComps.git -WORKDIR /home/user/GenAIComps -RUN pip install --no-cache-dir --upgrade pip setuptools && \ - pip install --no-cache-dir -r /home/user/GenAIComps/requirements.txt -COPY ./multimodalqna.py /home/user/multimodalqna.py +# Stage 3: common layer shared by services using GenAIComps +FROM base AS comps-base -ENV PYTHONPATH=$PYTHONPATH:/home/user/GenAIComps +# 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 setuptools && \ + 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 ./multimodalqna.py $HOME/multimodalqna.py ENTRYPOINT ["python", "multimodalqna.py"] # ENTRYPOINT ["/usr/bin/sleep", "infinity"] diff --git a/SearchQnA/Dockerfile b/SearchQnA/Dockerfile index 2d8e59f6b..6a9a5e4de 100644 --- a/SearchQnA/Dockerfile +++ b/SearchQnA/Dockerfile @@ -1,32 +1,48 @@ - - # 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 -RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ - libgl1-mesa-glx \ - libjemalloc-dev \ - git +RUN apt-get update + +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 -WORKDIR /home/user/GenAIComps -RUN pip install --no-cache-dir --upgrade pip setuptools && \ - pip install --no-cache-dir -r /home/user/GenAIComps/requirements.txt -COPY ./searchqna.py /home/user/searchqna.py +# Stage 2: latest GenAIComps sources +FROM base AS git + +RUN 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 setuptools && \ + 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 ./searchqna.py $HOME/searchqna.py ENTRYPOINT ["python", "searchqna.py"] diff --git a/Translation/Dockerfile b/Translation/Dockerfile index 33931689c..2e5aefb7a 100644 --- a/Translation/Dockerfile +++ b/Translation/Dockerfile @@ -1,42 +1,48 @@ -# Copyright (c) 2024 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -FROM python:3.11-slim - -RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ - libgl1-mesa-glx \ - libjemalloc-dev \ - git +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +# Stage 1: base setup used by other stages +FROM python:3.11-slim AS base + +RUN apt-get update + +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 -WORKDIR /home/user/GenAIComps -RUN pip install --no-cache-dir --upgrade pip setuptools && \ - pip install --no-cache-dir -r /home/user/GenAIComps/requirements.txt -COPY ./translation.py /home/user/translation.py +# Stage 2: latest GenAIComps sources +FROM base AS git + +RUN 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 setuptools && \ + 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 ./translation.py $HOME/translation.py ENTRYPOINT ["python", "translation.py"] diff --git a/VideoQnA/Dockerfile b/VideoQnA/Dockerfile index bd1ff121f..a2c2333e0 100644 --- a/VideoQnA/Dockerfile +++ b/VideoQnA/Dockerfile @@ -1,33 +1,48 @@ - - # 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 + +RUN apt-get update -RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ - libgl1-mesa-glx \ - libjemalloc-dev \ - 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/ +WORKDIR $HOME -RUN git clone https://github.com/opea-project/GenAIComps.git -WORKDIR /home/user/GenAIComps -RUN pip install --no-cache-dir --upgrade pip setuptools && \ - pip install --no-cache-dir -r /home/user/GenAIComps/requirements.txt +# Stage 2: latest GenAIComps sources +FROM base AS git + +RUN apt-get install -y --no-install-recommends git + +RUN git clone --depth 1 https://github.com/opea-project/GenAIComps.git -COPY ./videoqna.py /home/user/videoqna.py -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 setuptools && \ + 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 ./videoqna.py $HOME/videoqna.py ENTRYPOINT ["python", "videoqna.py"] diff --git a/VisualQnA/Dockerfile b/VisualQnA/Dockerfile index ef6a2e253..e019e41eb 100644 --- a/VisualQnA/Dockerfile +++ b/VisualQnA/Dockerfile @@ -1,32 +1,48 @@ - - # 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 -RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ - libgl1-mesa-glx \ - libjemalloc-dev \ - git +RUN apt-get update + +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 -WORKDIR /home/user/GenAIComps -RUN pip install --no-cache-dir --upgrade pip setuptools && \ - pip install --no-cache-dir -r /home/user/GenAIComps/requirements.txt -COPY ./visualqna.py /home/user/visualqna.py +# Stage 2: latest GenAIComps sources +FROM base AS git + +RUN apt-get install -y --no-install-recommends git + +RUN git clone --depth 1 https://github.com/opea-project/GenAIComps.git + -ENV 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 setuptools && \ + 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 ./visualqna.py $HOME/visualqna.py ENTRYPOINT ["python", "visualqna.py"]