From: Monosij Ghosh Date: Tue, 26 Nov 2024 08:12:54 +0000 (+0530) Subject: TM module docker file optimisation X-Git-Tag: 3.0.0~16^2 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F80%2F13780%2F2;p=aiml-fw%2Fawmf%2Ftm.git TM module docker file optimisation Memmory optimisation for docker image Change-Id: Ic8947e9179e0ca5e05cd0816276a5260bd5679a4 Signed-off-by: Monosij Ghosh --- diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8839a47 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.git +*.log +__pycache__/ +*.pyc +*.pyo diff --git a/Dockerfile b/Dockerfile index f16cde0..77eee87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Base Image -FROM python:3.10 AS builder +FROM python:3.10-slim AS builder # Location in the container @@ -7,28 +7,28 @@ WORKDIR /app # Install dependencies RUN apt-get update && \ - apt-get install -y --no-install-recommends python3-pip apt-utils && \ + apt-get install -y --no-install-recommends python3-pip apt-utils git && \ + apt-get clean && \ rm -rf /var/lib/apt/lists/* + # Copy sources into the container COPY . . - # Install dependencies RUN pip3 install --no-cache-dir -r requirements.txt -# Clone SDK repositories -RUN git clone "https://gerrit.o-ran-sc.org/r/aiml-fw/athp/sdk/feature-store" /SDK/featurestoresdk_main -RUN git clone "https://gerrit.o-ran-sc.org/r/aiml-fw/athp/sdk/model-storage" /SDK/modelmetricssdk_main - -# Install SDKs -RUN pip3 install --no-cache-dir /SDK/featurestoresdk_main/. -RUN pip3 install --no-cache-dir /SDK/modelmetricssdk_main/. +# Clone SDK repositories and install SDKs +RUN git clone --depth 1 "https://gerrit.o-ran-sc.org/r/aiml-fw/athp/sdk/feature-store" /SDK/featurestoresdk_main && \ + git clone --depth 1 "https://gerrit.o-ran-sc.org/r/aiml-fw/athp/sdk/model-storage" /SDK/modelmetricssdk_main && \ + pip3 install --no-cache-dir /SDK/featurestoresdk_main/. && \ + pip3 install --no-cache-dir /SDK/modelmetricssdk_main/. && \ + rm -rf /SDK # Final stage FROM python:3.10-slim # Location in the container -ENV TA_DIR /app +ENV TA_DIR=/app WORKDIR ${TA_DIR} COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages @@ -36,13 +36,13 @@ COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/pytho # Copy the application code COPY --from=builder ${TA_DIR} ${TA_DIR} -RUN pip3 install . +RUN pip3 install --no-cache-dir . + # Expose the ports EXPOSE 5050 # COPY model-storage /SDK/featurestoresdk_main - WORKDIR ${TA_DIR}/trainingmgr # Start the application -CMD ["python3", "trainingmgr_main.py"] \ No newline at end of file +CMD ["python3", "trainingmgr_main.py"]