From 22123c8c53c5930bde9ef2a8ae1b2a02e0c025da Mon Sep 17 00:00:00 2001
From: Andreas Ellewsen <andreas@ellewsen.no>
Date: Wed, 22 Jun 2022 16:02:37 +0200
Subject: [PATCH] Stop copying node_modules into frontend image

By not having a .dockerignore file we are including the node_modules
directory in the frontend image, and then installing all the packages a
second time in the build phase when we run npm ci. We now let npm ci do
that work as it's supposed to.
---
 frontend/update-harbor-image.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/frontend/update-harbor-image.sh b/frontend/update-harbor-image.sh
index ef2723a2..c45ebc1c 100755
--- a/frontend/update-harbor-image.sh
+++ b/frontend/update-harbor-image.sh
@@ -10,6 +10,12 @@ APP_NAME="greg-frontend"
 CONTAINER="${REPO}/${PROJECT}/${APP_NAME}"
 IMAGE_TAG="${CONTAINER}:${GIT_BRANCH}-${GIT_SHA}"
 
+echo "Generating .dockerignore"
+echo ".*
+*" > .dockerignore
+git ls-tree --name-only HEAD | sed 's/^/!/' >> .dockerignore
+echo "**/node_modules" >> .dockerignore
+
 if command -v podman > /dev/null 2>&1; then
   BUILDER=$(command -v podman)
 else
-- 
GitLab