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

Use staged builds to minimize final image sizes #1031

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
50 changes: 33 additions & 17 deletions AudioQnA/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
50 changes: 33 additions & 17 deletions AudioQnA/Dockerfile.multilang
Original file line number Diff line number Diff line change
@@ -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"]
51 changes: 33 additions & 18 deletions AvatarChatbot/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
51 changes: 32 additions & 19 deletions ChatQnA/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 $HOME/chatqna.py

ENTRYPOINT ["python", "chatqna.py"]
51 changes: 32 additions & 19 deletions ChatQnA/Dockerfile.guardrails
Original file line number Diff line number Diff line change
@@ -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 $HOME/chatqna.py

ENTRYPOINT ["python", "chatqna.py", "--with-guardrails"]
Loading
Loading