From 901389cfb8813ae70a9f3e092ddcf8de38c68003 Mon Sep 17 00:00:00 2001 From: Fiete Ostkamp Date: Thu, 12 Mar 2026 13:49:36 +0100 Subject: [PATCH] Reduce cassandra-init image - remove unnecessary packages (libffi,libxml,curl,perl,npt,apt-transport) - reduce sdctool.tar archive size (440MB -> 185MB) by excluding artifacts that are not used in the init image (zusammen-tools) - extract sdctool.tar in separate stage to avoid it being saved as it's own image layer - reduces image size from 2.7GB to 750MB Issue-ID: SDC-4803 Change-Id: I129052200c76906034b6c0ddb89b29ca1dddd89a Signed-off-by: Fiete Ostkamp --- .gitignore | 1 + asdctool/sdc-cassandra-init/Dockerfile | 72 ++++++++++++---------------------- asdctool/tarball.xml | 14 ++++++- pom.xml | 11 +++++- 4 files changed, 49 insertions(+), 49 deletions(-) diff --git a/.gitignore b/.gitignore index 8a7712bb67..9596ce172a 100644 --- a/.gitignore +++ b/.gitignore @@ -195,3 +195,4 @@ Vagrantfile *.xls node_modules node +*.tar diff --git a/asdctool/sdc-cassandra-init/Dockerfile b/asdctool/sdc-cassandra-init/Dockerfile index 093466de8a..52348a13d9 100644 --- a/asdctool/sdc-cassandra-init/Dockerfile +++ b/asdctool/sdc-cassandra-init/Dockerfile @@ -1,53 +1,33 @@ -# Base image +# The build stage is necessary here to avoid including the tar file +# in a separate image layer +FROM eclipse-temurin:11-jre-jammy AS builder +COPY sdctool.tar /tmp/sdctool.tar +RUN mkdir -p /opt && \ + tar -xf /tmp/sdctool.tar -C /opt && \ + rm /tmp/sdctool.tar + FROM eclipse-temurin:11-jre-jammy -# Create a new group and user -RUN addgroup --system sdc && \ - adduser --system --ingroup sdc --shell /bin/sh sdc -USER sdc -WORKDIR /home/sdc -# Create Cassandra configuration directory and file -RUN mkdir -p ~/.cassandra/ && \ - echo '[cql]' > ~/.cassandra/cqlshrc && \ - echo 'version=3.4.4' >> ~/.cassandra/cqlshrc && \ - chmod 600 ~/.cassandra/cqlshrc -# Switch to root to install necessary packages + USER root -RUN apt-get update --allow-releaseinfo-change && \ - apt-get install -y --no-install-recommends \ - python3-pip \ - libffi-dev \ - libxml2-dev \ - curl \ - wget \ - perl \ - ntp \ - apt-transport-https && \ - python3 -m pip install --upgrade pip && \ +RUN groupadd -r sdc && useradd -r -g sdc -m sdc + +RUN apt-get update && \ + apt-get install -y --no-install-recommends python3-pip && \ pip3 install --no-cache-dir cqlsh==6.1.0 && \ - apt-get purge -y python3-dev python3-apt && \ - apt-get clean && \ + apt-get purge -y python3-pip && \ rm -rf /var/lib/apt/lists/* /root/.cache/pip -# Switch back to system user for runtime + USER sdc WORKDIR /home/sdc -# Copy sdctool tar and startup -COPY --chown=sdc:sdc sdctool.tar /home/sdc/sdctool.tar -COPY --chown=sdc:sdc scripts /home/sdc/scripts -COPY --chown=sdc:sdc startup.sh /home/sdc -# Extract and prepare sdctool -RUN tar -xvf /home/sdc/sdctool.tar -C /home/sdc && \ - rm /home/sdc/sdctool.tar && \ - mkdir -p /home/sdc/tools && \ - cp -pr /home/sdc/sdctool/tools/* /home/sdc/tools && \ - chmod +x /home/sdc/sdctool/scripts/* && \ - chmod +x /home/sdc/tools/build/scripts/* && \ - chmod +x /home/sdc/tools/scripts/* && \ - chown -R sdc:sdc /home/sdc/tools/build/scripts/* && \ - chmod +x /home/sdc/startup.sh && \ - chmod +x /home/sdc/scripts/* && \ - cp -r /home/sdc/scripts/janusgraph.properties /home/sdc/sdctool/config && \ - cp -r /home/sdc/scripts/configuration.yaml /home/sdc/sdctool/config -# Ensure all scripts are executable and owned by sdc -RUN find /home/sdc -type f -name "*.sh" -exec chmod 750 {} \; && \ - chown -R sdc:sdc /home/sdc + +COPY --from=builder --chown=sdc:sdc /opt/sdctool ./sdctool +COPY --chown=sdc:sdc scripts ./scripts +COPY --chown=sdc:sdc startup.sh ./ + +RUN mkdir -p tools && \ + cp -pr sdctool/tools/* tools/ && \ + cp scripts/janusgraph.properties sdctool/config/ && \ + cp scripts/configuration.yaml sdctool/config/ && \ + find /home/sdc -type f -name "*.sh" -exec chmod 750 {} \; + ENTRYPOINT ["/bin/sh", "/home/sdc/startup.sh"] diff --git a/asdctool/tarball.xml b/asdctool/tarball.xml index e5fc2ecb71..145f5441e5 100644 --- a/asdctool/tarball.xml +++ b/asdctool/tarball.xml @@ -29,6 +29,18 @@ ${project.parent.basedir}/openecomp-be/tools tools + + + swagger-ui/** + + zusammen-tools/src/** + zusammen-tools/target/** + zusammen-tools/pom.xml + + migration/** + scripts/** + test.push/** + - \ No newline at end of file + diff --git a/pom.xml b/pom.xml index fa700c6e6f..bcda20f1da 100644 --- a/pom.xml +++ b/pom.xml @@ -283,13 +283,13 @@ Modifications copyright (c) 2018-2019 Nokia net.logstash.logback logstash-logback-encoder - ${logstash.encoder.version} + ${logstash.encoder.version} - + org.jacoco @@ -604,6 +604,13 @@ Modifications copyright (c) 2018-2019 Nokia parse-version + + parse-version-default + validate + + parse-version + + -- 2.16.6