From ca828c2821b05a551196656863b489dca7216fcc Mon Sep 17 00:00:00 2001 From: Bin Yang Date: Mon, 7 Nov 2022 14:51:20 +0800 Subject: [PATCH] Reduce image footprint Issue-ID: INF-335 Signed-off-by: Bin Yang Change-Id: I452d523586bd6816adec9560d1e5ca2619cbdf68 --- Dockerfile | 109 +++++++++++++++++---------- charts/resources/scripts/init/o2api_start.sh | 2 +- requirements-stx.txt | 11 ++- requirements.txt | 4 +- 4 files changed, 79 insertions(+), 47 deletions(-) diff --git a/Dockerfile b/Dockerfile index e837ed4..5cf60ee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,58 +1,85 @@ -FROM python:3.10-slim-buster - -RUN apt-get update && apt-get install -y git gcc procps vim curl ssh - -# in case git repo is not accessable -# RUN mkdir -p /cgtsclient -# COPY temp/config /cgtsclient/ -RUN git clone --depth 1 --branch r/stx.7.0 https://opendev.org/starlingx/config.git /cgtsclient -RUN pip install -e /cgtsclient/sysinv/cgts-client/cgts-client/ - -# RUN mkdir -p /distcloud-client -# COPY temp/distcloud-client /distcloud-client/ -RUN git clone --depth 1 --branch r/stx.7.0 https://opendev.org/starlingx/distcloud-client.git /distcloud-client/ -RUN pip install -e /distcloud-client/distributedcloud-client -# in case git repo is not accessable - -# RUN git clone --depth 1 --branch master https://github.com/cloudify-incubator/cloudify-helm-plugin.git /helmsdk -RUN git clone --depth 1 --branch r/stx.7.0 https://opendev.org/starlingx/fault.git /faultclient -RUN pip install -e /faultclient/python-fmclient/fmclient/ - +FROM nexus3.onap.org:10001/onap/integration-python:10.1.0 +# https://nexus3.onap.org/#browse/search=keyword%3Dintegration-python:d406d405e4cfbf1186265b01088caf9a +# https://git.onap.org/integration/docker/onap-python/tree/Dockerfile + +USER root + +RUN set -ex \ + && mkdir -p /src \ + && mkdir -p /configs/ \ + && mkdir -p /src/o2app/ \ + && mkdir -p /src/helm_sdk/ + +ARG user=orano2 +ARG group=orano2 +# Create a group and user +RUN addgroup -S $group && adduser -S -D -h /home/$user $user $group && \ + chown -R $user:$group /home/$user && \ + mkdir /var/log/$user && \ + chown -R $user:$group /var/log/$user && \ + chown -R $user:$group /src COPY requirements.txt /tmp/ COPY requirements-stx.txt /tmp/ COPY constraints.txt /tmp/ -RUN pip install -r /tmp/requirements.txt -c /tmp/constraints.txt -# RUN pip install -r /tmp/requirements-stx.txt - -COPY requirements-test.txt /tmp/ -RUN pip install -r /tmp/requirements-test.txt - - -RUN mkdir -p /src COPY o2ims/ /src/o2ims/ COPY o2dms/ /src/o2dms/ COPY o2common/ /src/o2common/ - -RUN mkdir -p /src/helm_sdk/ -COPY helm_sdk/ /src/helm_sdk/ - -RUN mkdir -p /configs/ -COPY configs/ /configs/ - -RUN mkdir -p /src/o2app/ COPY o2app/ /src/o2app/ COPY setup.py /src/ -RUN pip install -e /src +COPY helm_sdk/ /src/helm_sdk/ COPY configs/ /etc/o2/ +COPY configs/ /configs/ -COPY tests/ /tests/ - -RUN curl -O https://get.helm.sh/helm-v3.3.1-linux-amd64.tar.gz; -RUN tar -zxvf helm-v3.3.1-linux-amd64.tar.gz; cp linux-amd64/helm /usr/local/bin +RUN set -ex \ + && apk add --no-cache bash \ + && apk add --no-cache --virtual .fetch2-deps \ + git curl \ + && apk add --no-cache --virtual .build2-deps \ + bluez-dev \ + bzip2-dev \ + dpkg-dev dpkg \ + expat-dev \ + gcc \ + libc-dev \ + libffi-dev \ + libnsl-dev \ + libtirpc-dev \ + linux-headers \ + make \ + ncurses-dev \ + openssl-dev \ + pax-utils \ + sqlite-dev \ + tcl-dev \ + tk \ + tk-dev \ + util-linux-dev \ + xz-dev \ + zlib-dev \ + && pip install -r /tmp/requirements.txt -r /tmp/requirements-stx.txt -c /tmp/constraints.txt \ + && curl -O https://get.helm.sh/helm-v3.3.1-linux-amd64.tar.gz; \ + tar -zxvf helm-v3.3.1-linux-amd64.tar.gz; \ + cp linux-amd64/helm /usr/local/bin; \ + rm -f helm-v3.3.1-linux-amd64.tar.gz \ + && pip install -e /src \ + && apk del --no-network .fetch2-deps \ + && apk del --no-network .build2-deps + +# && pip install -r /tmp/requirements.txt -r /tmp/requirements-stx.txt -c /tmp/constraints.txt +# RUN apt-get update && apt-get install -y git gcc procps vim curl ssh +# && git clone --depth 1 --branch r/stx.7.0 https://opendev.org/starlingx/config.git /cgtsclient \ +# && git clone --depth 1 --branch r/stx.7.0 https://opendev.org/starlingx/distcloud-client.git /distcloud-client/ \ +# && git clone --depth 1 --branch r/stx.7.0 https://opendev.org/starlingx/fault.git /faultclient \ +# && pip install -e /cgtsclient/sysinv/cgts-client/cgts-client \ +# && pip install -e /distcloud-client/distributedcloud-client \ +# && pip install -e /faultclient/python-fmclient/fmclient \ +# && rm -rf /cgtsclient /distcloud-client /faultclient WORKDIR /src + +USER $user diff --git a/charts/resources/scripts/init/o2api_start.sh b/charts/resources/scripts/init/o2api_start.sh index 9b376f4..6c7ebbf 100644 --- a/charts/resources/scripts/init/o2api_start.sh +++ b/charts/resources/scripts/init/o2api_start.sh @@ -22,7 +22,7 @@ # pip install retry # pip install -e /root/o2 -pip install -e /src +# pip install -e /src cat <>/etc/hosts 127.0.0.1 api diff --git a/requirements-stx.txt b/requirements-stx.txt index 31b4dab..77555c6 100644 --- a/requirements-stx.txt +++ b/requirements-stx.txt @@ -1,4 +1,7 @@ --e git+https://opendev.org/starlingx/distcloud-client.git@master#egg=distributedcloud-client&subdirectory=distributedcloud-client --e git+https://opendev.org/starlingx/config.git@master#egg=cgtsclient&subdirectory=sysinv/cgts-client/cgts-client -# -e git+https://github.com/cloudify-incubator/cloudify-helm-plugin.git@master#egg=helmsdk&subdirectory=helm_sdk --e git+https://opendev.org/starlingx/fault.git@master#egg=fmclient&subdirectory=python-fmclient/fmclient +# -e git+https://opendev.org/starlingx/distcloud-client.git@master#egg=distributedcloud-client&subdirectory=distributedcloud-client +# -e git+https://opendev.org/starlingx/config.git@master#egg=cgtsclient&subdirectory=sysinv/cgts-client/cgts-client +# -e git+https://opendev.org/starlingx/fault.git@master#egg=fmclient&subdirectory=python-fmclient/fmclient + +-e git+https://opendev.org/starlingx/distcloud-client.git@r/stx.7.0#egg=distributedcloud-client&subdirectory=distributedcloud-client +-e git+https://opendev.org/starlingx/config.git@r/stx.7.0#egg=cgtsclient&subdirectory=sysinv/cgts-client/cgts-client +-e git+https://opendev.org/starlingx/fault.git@r/stx.7.0#egg=fmclient&subdirectory=python-fmclient/fmclient diff --git a/requirements.txt b/requirements.txt index 3d03fdd..33350d5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,4 +17,6 @@ ruamel.yaml==0.17.17 # https://github.com/python-restx/flask-restx/issues/460 # Workaround for this issue -werkzeug<=2.1.2 \ No newline at end of file +werkzeug<=2.1.2 + +pyOpenSSL -- 2.16.6