From 5d1fb6db10351ca5f5e58a074a06de4a289c85e9 Mon Sep 17 00:00:00 2001
From: Wouter Deconinck <wdconinc@gmail.com>
Date: Wed, 22 Feb 2023 00:24:35 +0000
Subject: [PATCH] feat: keep minimal spack in final image

---
 containers/jug/dev.Dockerfile | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/containers/jug/dev.Dockerfile b/containers/jug/dev.Dockerfile
index 43b8a9ae6..61b9c51f2 100644
--- a/containers/jug/dev.Dockerfile
+++ b/containers/jug/dev.Dockerfile
@@ -222,6 +222,13 @@ RUN cd /opt/spack-environment                                           \
  && spack env activate .                                                \
  && spack gc -y
 
+# Garbage collect in git
+RUN cd $SPACK_ROOT                                                      \
+ && du -sh $SPACK_ROOT                                                  \
+ && git fetch --depth=1                                                 \
+ && git gc --prune=all --aggressive                                     \
+ && du -sh $SPACK_ROOT
+
 ## Bugfix to address issues loading the Qt5 libraries on Linux kernels prior to 3.15
 ## See
 #https://askubuntu.com/questions/1034313/ubuntu-18-4-libqt5core-so-5-cannot-open-shared-object-file-no-such-file-or-dir
@@ -262,6 +269,7 @@ LABEL maintainer="Sylvester Joosten <sjoosten@anl.gov>" \
 ## copy over everything we need from staging in a single layer :-)
 RUN --mount=from=staging,target=/staging                                \
     rm -rf /usr/local                                                   \
+ && cp -r /staging/opt/spack /opt/spack                                 \
  && cp -r /staging/opt/spack-environment /opt/spack-environment         \
  && cp -r /staging/opt/software /opt/software                           \
  && cp -r /staging/usr/._local /usr/._local                             \
-- 
GitLab