From 2126a686a97c1cc82a9a48b7bc80ffe730e6ca5f Mon Sep 17 00:00:00 2001
From: Andreas <andreksv@ntnu.no>
Date: Thu, 18 Apr 2024 09:27:55 +0200
Subject: [PATCH] refactor/Updated .gitlab-ci.yml by improving job
 install_dependencies

---
 .gitlab-ci.yml | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a3db6c2..9992bcb 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -6,26 +6,24 @@ stages:
   - build_project
 
 cache:
-  key: "node repository" # Static Cache Key to keep cache across branches 
-  paths:
+    key: "${CI_COMMIT_REF_SLUG}" # Branch-specific cache keys to have separate caches across branches.
+    paths:
     - node_modules/
 
 install_dependencies:
   stage: install_dependencies
-  image: node:latest
   script:
-    - npm install
+    - apk add --no-cache git # For instances where installations require git
+    - npm ci --prefer-offline  # --prefer-offline to make it prefer using locally cached packages rather than downloading
 
 lint:
   stage: lint
-  image: node:latest
   script:
     - npm run lint    
   allow_failure: true  
 
 build_project:
   stage: build_project
-  image: node:latest
   script:
     - npm run build
 
-- 
GitLab