Skip to content

Commit

Permalink
Support launch as Non-Root user in all published container images. (o…
Browse files Browse the repository at this point in the history
…pea-project#406)

Signed-off-by: zepan <[email protected]>
  • Loading branch information
ZePan110 authored and BaoHuiling committed Aug 13, 2024
1 parent 24f48e0 commit 7c8030f
Show file tree
Hide file tree
Showing 21 changed files with 148 additions and 80 deletions.
13 changes: 9 additions & 4 deletions comps/asr/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@

FROM python:3.11-slim

RUN useradd -m -s /bin/bash user && \
mkdir -p /home/user && \
chown -R user /home/user/
USER user

ENV LANG=C.UTF-8

COPY comps /home/comps
COPY comps /home/user/comps

RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r /home/comps/asr/requirements.txt
pip install --no-cache-dir -r /home/user/comps/asr/requirements.txt

ENV PYTHONPATH=$PYTHONPATH:/home
ENV PYTHONPATH=$PYTHONPATH:/home/user

WORKDIR /home/comps/asr
WORKDIR /home/user/comps/asr

ENTRYPOINT ["python", "asr.py"]
17 changes: 12 additions & 5 deletions comps/asr/whisper/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,28 @@

FROM python:3.11-slim


RUN useradd -m -s /bin/bash user && \
mkdir -p /home/user && \
chown -R user /home/user/

# Set environment variables
ENV LANG=en_US.UTF-8
ENV PYTHONPATH=/home/user

# Install system dependencies
RUN apt-get update \
&& apt-get install -y ffmpeg

COPY comps /home/comps
COPY --chown=user:user comps /home/user/comps

USER user

RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r /home/comps/asr/requirements.txt
pip install --no-cache-dir -r /home/user/comps/asr/requirements.txt && \
pip list

ENV PYTHONPATH=$PYTHONPATH:/home
ENV PYTHONPATH=$PYTHONPATH:/home/user

WORKDIR /home/comps/asr/whisper
WORKDIR /home/user/comps/asr/whisper

ENTRYPOINT ["python", "whisper_server.py", "--device", "cpu"]
14 changes: 10 additions & 4 deletions comps/asr/whisper/Dockerfile_hpu
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
# HABANA environment
FROM vault.habana.ai/gaudi-docker/1.16.1/ubuntu22.04/habanalabs/pytorch-installer-2.2.2:latest AS hpu

RUN useradd -m -s /bin/bash user && \
mkdir -p /home/user && \
chown -R user /home/user/

# Set environment variables
ENV LANG=en_US.UTF-8
ENV PYTHONPATH=/home/user:/usr/lib/habanalabs/:/optimum-habana
Expand All @@ -12,15 +16,17 @@ ENV PYTHONPATH=/home/user:/usr/lib/habanalabs/:/optimum-habana
RUN apt-get update \
&& apt-get install -y ffmpeg

COPY comps /home/comps
COPY --chown=user:user comps /home/user/comps

USER user

# Install requirements and optimum habana
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r /home/comps/asr/requirements.txt && \
pip install --no-cache-dir -r /home/user/comps/asr/requirements.txt && \
pip install optimum[habana]

ENV PYTHONPATH=$PYTHONPATH:/home
ENV PYTHONPATH=$PYTHONPATH:/home/user

WORKDIR /home/comps/asr/whisper
WORKDIR /home/user/comps/asr/whisper

ENTRYPOINT ["python", "whisper_server.py", "--device", "hpu"]
14 changes: 9 additions & 5 deletions comps/embeddings/langchain-mosec/mosec-docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@
# SPDX-License-Identifier: Apache-2.0

From ubuntu:22.04
RUN useradd -m -s /bin/bash user && \
mkdir -p /home/user && \
chown -R user /home/user/
ARG DEBIAN_FRONTEND=noninteractive

ENV GLIBC_TUNABLES glibc.cpu.x86_shstk=permissive
RUN apt update && apt install -y python3 python3-pip

COPY comps /root/comps
USER user
COPY comps /home/user/comps

RUN apt update && apt install -y python3 python3-pip
RUN pip3 install torch==2.2.2 torchvision --index-url https://download.pytorch.org/whl/cpu
RUN pip3 install intel-extension-for-pytorch==2.2.0
RUN pip3 install transformers
RUN pip3 install llmspec mosec

RUN cd /root/ && export HF_ENDPOINT=https://hf-mirror.com && huggingface-cli download --resume-download BAAI/bge-large-zh-v1.5 --local-dir /root/bge-large-zh-v1.5
RUN cd /home/user/ && export HF_ENDPOINT=https://hf-mirror.com && huggingface-cli download --resume-download BAAI/bge-large-zh-v1.5 --local-dir /home/user/bge-large-zh-v1.5

ENV EMB_MODEL="/root/bge-large-zh-v1.5/"
ENV EMB_MODEL="/home/user/bge-large-zh-v1.5/"

WORKDIR /root/comps/embeddings/langchain-mosec/mosec-docker
WORKDIR /home/user/comps/embeddings/langchain-mosec/mosec-docker

CMD ["python3", "server-ipex.py"]
1 change: 0 additions & 1 deletion comps/llms/text-generation/vllm-xft/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,3 @@ RUN chmod +x /root/comps/llms/text-generation/vllm-xft/run.sh
WORKDIR /root/comps/llms/text-generation/vllm-xft/

ENTRYPOINT ["/root/comps/llms/text-generation/vllm-xft/run.sh"]

11 changes: 6 additions & 5 deletions comps/llms/text-generation/vllm/docker/Dockerfile.hpu
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# FROM vault.habana.ai/gaudi-docker/1.15.1/ubuntu22.04/habanalabs/pytorch-installer-2.2.0:latest
FROM vault.habana.ai/gaudi-docker/1.16.0/ubuntu22.04/habanalabs/pytorch-installer-2.2.2:latest

RUN useradd -m -s /bin/bash user && \
mkdir -p /home/user && \
chown -R user /home/user/
ENV LANG=en_US.UTF-8

RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
service ssh restart
USER user
WORKDIR /root

RUN pip install --upgrade-strategy eager optimum[habana]
Expand All @@ -11,9 +15,6 @@ RUN pip install -v git+https://github.com/HabanaAI/vllm-fork.git@cf6952d

RUN pip install setuptools

RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
service ssh restart

ENV no_proxy=localhost,127.0.0.1

ENV PT_HPU_LAZY_ACC_PAR_MODE=0
Expand Down
6 changes: 4 additions & 2 deletions comps/llms/utils/lm-eval/Dockerfile.cpu
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
ARG UBUNTU_VER=22.04
FROM ubuntu:${UBUNTU_VER} as devel

RUN useradd -m -s /bin/bash user && \
mkdir -p /home/user && \
chown -R user /home/user/
ARG REPO_COMPS=https://github.com/opea-project/GenAIComps.git
ARG BRANCH=main
ENV LANG=C.UTF-8
Expand All @@ -16,7 +18,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends --fix-missing \
git \
vim \
wget

USER user
RUN git clone --single-branch --branch=${BRANCH} ${REPO_COMPS} /home/user/GenAIComps/ && \
cd /home/user/GenAIComps/ && python3 setup.py install && \
pip install --no-cache-dir -r /home/user/GenAIComps/comps/llms/utils/lm-eval/requirements.txt
Expand Down
13 changes: 8 additions & 5 deletions comps/lvms/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
# SPDX-License-Identifier: Apache-2.0

FROM python:3.11-slim

RUN useradd -m -s /bin/bash user && \
mkdir -p /home/user && \
chown -R user /home/user/
USER user
# Set environment variables
ENV LANG=en_US.UTF-8

COPY comps /home/comps
COPY comps /home/user/comps

RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r /home/comps/lvms/requirements.txt
pip install --no-cache-dir -r /home/user/comps/lvms/requirements.txt

ENV PYTHONPATH=$PYTHONPATH:/home
ENV PYTHONPATH=$PYTHONPATH:/home/user

WORKDIR /home/comps/lvms
WORKDIR /home/user/comps/lvms

ENTRYPOINT ["python", "lvm.py"]
13 changes: 8 additions & 5 deletions comps/lvms/llava/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
# SPDX-License-Identifier: Apache-2.0

FROM python:3.11-slim

RUN useradd -m -s /bin/bash user && \
mkdir -p /home/user && \
chown -R user /home/user/
USER user
# Set environment variables
ENV LANG=en_US.UTF-8
ENV PYTHONPATH=/home/user:/usr/lib/habanalabs/:/optimum-habana

COPY comps /home/comps
COPY comps /home/user/comps

RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r /home/comps/lvms/requirements.txt
pip install --no-cache-dir -r /home/user/comps/lvms/requirements.txt

ENV PYTHONPATH=$PYTHONPATH:/home
ENV PYTHONPATH=$PYTHONPATH:/home/user

WORKDIR /home/comps/lvms/llava
WORKDIR /home/user/comps/lvms/llava

ENTRYPOINT ["python", "llava_server.py", "--device", "cpu"]
14 changes: 9 additions & 5 deletions comps/lvms/llava/Dockerfile_hpu
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@

# HABANA environment
FROM vault.habana.ai/gaudi-docker/1.16.1/ubuntu22.04/habanalabs/pytorch-installer-2.2.2:latest AS hpu
RUN rm -rf /etc/ssh/ssh_host*
RUN useradd -m -s /bin/bash user && \
mkdir -p /home/user && \
chown -R user /home/user/

RUN rm -rf /etc/ssh/ssh_host*
USER user
# Set environment variables
ENV LANG=en_US.UTF-8
ENV PYTHONPATH=/home/user:/usr/lib/habanalabs/:/optimum-habana

COPY comps /home/comps
COPY comps /home/user/comps

# Install requirements and optimum habana
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r /home/comps/lvms/requirements.txt && \
pip install --no-cache-dir -r /home/user/comps/lvms/requirements.txt && \
pip install optimum[habana]

ENV PYTHONPATH=$PYTHONPATH:/home
ENV PYTHONPATH=$PYTHONPATH:/home/user

WORKDIR /home/comps/lvms/llava
WORKDIR /home/user/comps/lvms/llava

ENTRYPOINT ["python", "llava_server.py"]
12 changes: 8 additions & 4 deletions comps/reranks/langchain-mosec/mosec-docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@
# SPDX-License-Identifier: Apache-2.0

From ubuntu:22.04
RUN useradd -m -s /bin/bash user && \
mkdir -p /home/user && \
chown -R user /home/user/
ARG DEBIAN_FRONTEND=noninteractive

ENV GLIBC_TUNABLES glibc.cpu.x86_shstk=permissive

COPY comps /root/comps
COPY comps /home/user/comps

RUN apt update && apt install -y python3 python3-pip
USER user
RUN pip3 install torch==2.2.2 torchvision --trusted-host download.pytorch.org --index-url https://download.pytorch.org/whl/cpu
RUN pip3 install intel-extension-for-pytorch==2.2.0
RUN pip3 install transformers sentence-transformers
RUN pip3 install llmspec mosec

RUN cd /root/ && export HF_ENDPOINT=https://hf-mirror.com && huggingface-cli download --resume-download BAAI/bge-reranker-large --local-dir /root/bge-reranker-large
RUN cd /home/user/ && export HF_ENDPOINT=https://hf-mirror.com && huggingface-cli download --resume-download BAAI/bge-reranker-large --local-dir /home/user/bge-reranker-large

ENV EMB_MODEL="/root/bge-reranker-large/"
ENV EMB_MODEL="/home/user/bge-reranker-large/"

WORKDIR /root/comps/reranks/langchain-mosec/mosec-docker
WORKDIR /home/user/comps/reranks/langchain-mosec/mosec-docker

CMD ["python3", "server-ipex.py"]
13 changes: 8 additions & 5 deletions comps/tts/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
# SPDX-License-Identifier: Apache-2.0

FROM python:3.11-slim

RUN useradd -m -s /bin/bash user && \
mkdir -p /home/user && \
chown -R user /home/user/
USER user
ENV LANG=C.UTF-8

COPY comps /home/comps
COPY comps /home/user/comps

RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r /home/comps/tts/requirements.txt
pip install --no-cache-dir -r /home/user/comps/tts/requirements.txt

ENV PYTHONPATH=$PYTHONPATH:/home
ENV PYTHONPATH=$PYTHONPATH:/home/user

WORKDIR /home/comps/tts
WORKDIR /home/user/comps/tts

ENTRYPOINT ["python", "tts.py"]
13 changes: 9 additions & 4 deletions comps/tts/speecht5/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# SPDX-License-Identifier: Apache-2.0

FROM python:3.11-slim
RUN useradd -m -s /bin/bash user && \
mkdir -p /home/user && \
chown -R user /home/user/

# Set environment variables
ENV LANG=en_US.UTF-8
Expand All @@ -12,13 +15,15 @@ RUN apt-get update \
&& apt-get install -y ffmpeg \
&& apt-get install -y curl

COPY comps /home/comps
COPY --chown=user:user comps /home/user/comps

USER user

RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r /home/comps/tts/requirements.txt
pip install --no-cache-dir -r /home/user/comps/tts/requirements.txt

ENV PYTHONPATH=$PYTHONPATH:/home
ENV PYTHONPATH=$PYTHONPATH:/home/user

WORKDIR /home/comps/tts/speecht5
WORKDIR /home/user/comps/tts/speecht5

ENTRYPOINT ["python", "speecht5_server.py", "--device", "cpu"]
14 changes: 9 additions & 5 deletions comps/tts/speecht5/Dockerfile_hpu
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

# HABANA environment
FROM vault.habana.ai/gaudi-docker/1.16.1/ubuntu22.04/habanalabs/pytorch-installer-2.2.2:latest AS hpu

RUN useradd -m -s /bin/bash user && \
mkdir -p /home/user && \
chown -R user /home/user/
RUN rm -rf /etc/ssh/ssh_host*

# Set environment variables
Expand All @@ -15,15 +17,17 @@ RUN apt-get update \
&& apt-get install -y ffmpeg \
&& apt-get install -y curl

COPY comps /home/comps
COPY --chown=user:user comps /home/user/comps

USER user

# Install requirements and optimum habana
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r /home/comps/tts/requirements.txt && \
pip install --no-cache-dir -r /home/user/comps/tts/requirements.txt && \
pip install optimum[habana]

ENV PYTHONPATH=$PYTHONPATH:/home
ENV PYTHONPATH=$PYTHONPATH:/home/user

WORKDIR /home/comps/tts/speecht5
WORKDIR /home/user/comps/tts/speecht5

ENTRYPOINT ["python", "speecht5_server.py", "--device", "hpu"]
Loading

0 comments on commit 7c8030f

Please sign in to comment.