From 33f7fafa22942eef00b198121d700f7c8fb8bbe7 Mon Sep 17 00:00:00 2001 From: zhihang Date: Sat, 26 Jul 2025 03:39:32 +0000 Subject: [PATCH] update CodeTrans Signed-off-by: zhihang --- AI/opea/codetrans-ui/1.2/24.03-lts/Dockerfile | 18 ++++-- AI/opea/codetrans/1.2/24.03-lts/Dockerfile | 60 ++++++++++++------- 2 files changed, 52 insertions(+), 26 deletions(-) diff --git a/AI/opea/codetrans-ui/1.2/24.03-lts/Dockerfile b/AI/opea/codetrans-ui/1.2/24.03-lts/Dockerfile index 5e36d9fc..f37953ed 100644 --- a/AI/opea/codetrans-ui/1.2/24.03-lts/Dockerfile +++ b/AI/opea/codetrans-ui/1.2/24.03-lts/Dockerfile @@ -1,22 +1,28 @@ # Copyright (C) 2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 +ARG BASE=openeuler/node:20.11.1-oe2403lts +ARG VERSION=v1.2 # Use node 20.11.1 as the base image -FROM openeuler/openeuler:24.03-lts +FROM $BASE +ARG VERSION # Update package manager and install Git RUN yum update -y && \ - yum install -y \ - npm \ - git + yum install -y git && \ + yum clean all && \ + rm -rf /var/cache/yum WORKDIR /home/user +ARG GENAIEXAMPLES_REPO=https://github.com/opea-project/GenAIExamples.git # Copy the front-end code repository -RUN git clone -b v1.2 https://github.com/opea-project/GenAIExamples.git +RUN git clone -b $VERSION $GENAIEXAMPLES_REPO && \ + cp -r GenAIExamples/CodeTrans/ui/svelte /home/user/svelte && \ + rm -rf GenAIExamples # Set the working directory -WORKDIR /home/user/GenAIExamples/CodeTrans/ui/svelte +WORKDIR /home/user/svelte # Install front-end dependencies RUN npm install diff --git a/AI/opea/codetrans/1.2/24.03-lts/Dockerfile b/AI/opea/codetrans/1.2/24.03-lts/Dockerfile index 48d960ee..e57a5253 100644 --- a/AI/opea/codetrans/1.2/24.03-lts/Dockerfile +++ b/AI/opea/codetrans/1.2/24.03-lts/Dockerfile @@ -1,36 +1,56 @@ # Copyright (C) 2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 - -FROM openeuler/openeuler:24.03-lts +ARG BASE=openeuler/python:3.11.13-oe2403lts +ARG VERSION=v1.2 +# Stage 1: base setup used by other stages +FROM $BASE AS base # get security updates RUN yum update -y && \ - yum install -y \ - python-pip python \ - git + yum install -y shadow && \ + yum clean all && \ + rm -rf /var/cache/yum + +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 -b v1.2 https://github.com/opea-project/GenAIComps.git +# Stage 2: latest GenAIComps sources +FROM base AS 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 +ARG VERSION -WORKDIR /home/user -RUN git clone -b v1.2 https://github.com/opea-project/GenAIExamples.git -RUN cp GenAIExamples/CodeTrans/code_translation.py . -RUN rm -rf GenAIExamples +RUN yum update -y && \ + yum install -y git && \ + yum clean all && \ + rm -rf /var/cache/yum -ENV PYTHONPATH=$PYTHONPATH:/home/user/GenAIComps +ARG GENAICOMPS_REPO=https://github.com/opea-project/GenAIComps.git +RUN git clone -b $VERSION $GENAICOMPS_REPO -USER user +ARG GENAIEXAMPLES_REPO=https://github.com/opea-project/GenAIExamples.git +RUN git clone -b $VERSION $GENAIEXAMPLES_REPO + +# Stage 3: common layer shared by services using GenAIComps +FROM base AS comps-base -WORKDIR /home/user +# copy just relevant parts +COPY --from=git $HOME/GenAIComps/comps $HOME/GenAIComps/comps +COPY --from=git $HOME/GenAIComps/*.* $HOME/GenAIComps/LICENSE $HOME/GenAIComps/ +COPY --from=git $HOME/GenAIExamples/CodeTrans/code_translation.py $HOME/code_translation.py + +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 -ENTRYPOINT ["python", "code_translation.py"] +ENTRYPOINT ["python", "code_translation.py"] \ No newline at end of file -- Gitee