From ab5a03226995f9b0133a1b4efdf87f79b74cd476 Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Sat, 8 Apr 2023 16:33:03 -0500 Subject: [PATCH] Updated CI/CD to use cache --- .gitlab-ci.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 590491b..8993faa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,10 @@ docker-build-main: before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY script: - - docker build --pull -t "$CI_REGISTRY_IMAGE:develop" . + - docker pull "$CI_REGISTRY_IMAGE:develop-depsonly" || true + - docker build --cache-from "$CI_REGISTRY_IMAGE:develop-depsonly" --target build -t "$CI_REGISTRY_IMAGE:develop-depsonly" . + - docker push "$CI_REGISTRY_IMAGE:develop-depsonly" + - docker build -t "$CI_REGISTRY_IMAGE:develop" . - docker push "$CI_REGISTRY_IMAGE:develop" rules: - if: $CI_COMMIT_BRANCH != "main" @@ -25,8 +28,12 @@ docker-build-tag: before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY script: - - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" -t "$CI_REGISTRY_IMAGE" . - - docker push --all-tags "$CI_REGISTRY_IMAGE" + - docker pull "$CI_REGISTRY_IMAGE:develop-depsonly" || true + - docker build --cache-from "$CI_REGISTRY_IMAGE:develop-depsonly" -t "$CI_REGISTRY_IMAGE:develop-depsonly" + - docker push "$CI_REGISTRY_IMAGE:develop-depsonly" + - docker build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" -t "$CI_REGISTRY_IMAGE" . + - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + - docker push "$CI_REGISTRY_IMAGE:latest" rules: - if: $CI_COMMIT_BRANCH != "main" when: never