From 1dcdda56dbadb690578c14b6ae779ad0d23bc4fb Mon Sep 17 00:00:00 2001 From: defensivedepth Date: Tue, 19 Sep 2023 17:07:38 -0400 Subject: [PATCH] Refactor regex for endpoint and beta releases --- so-elastic-fleet-package-registry/Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/so-elastic-fleet-package-registry/Dockerfile b/so-elastic-fleet-package-registry/Dockerfile index f680400e..a93c82a0 100644 --- a/so-elastic-fleet-package-registry/Dockerfile +++ b/so-elastic-fleet-package-registry/Dockerfile @@ -17,10 +17,11 @@ ARG VERSION FROM docker.elastic.co/package-registry/distribution:$VERSION as original_image # Cleanup unneeded packages, keeping the two most recent versons of each one +# Except for endpoint packages, keep all versions RUN cd /packages/package-storage/ \ -&& rm -rf suricata-* zeek-* snort-* dga-* endpoint*preview* endpoint*dev* endpoint*next* \ -&& cd /packages/package-storage/ && LIST=$(ls | awk -F'[-]' '{print $1}' | sort | uniq ) \ -&& for item in $LIST; do ls $item-*.zip | cut -d '-' -f 2 | tr - \~ | sort -V | tr \~ - | head -n-2 | xargs -I {} echo "$item-"{} | xargs rm -r; done +&& rm -rf suricata-* zeek-* snort-* dga-* endpoint*dev* endpoint*next* *preview* *beta* \ +&& cd /packages/package-storage/ && LIST=$(ls --ignore="endpoint-*" | awk -F'[-]' '{print $1}' | sort | uniq ) \ +&& for item in $LIST; do ls $item-*.zip | cut -d '-' -f 2 | tr - \~ | sort -V | tr \~ - | head -n-2 | xargs -I {} echo "$item-"{} | xargs -r rm -fr; done FROM scratch