From 3615d89bb08e2f01fccb00a0283bc6ea43fd449d Mon Sep 17 00:00:00 2001 From: Mark Hansen Date: Sat, 20 Feb 2021 15:01:25 +1100 Subject: [PATCH] Reuse docker images where possible Should speed up CI docker image building. Inspiration from https://blog.callr.tech/building-docker-images-with-gitlab-ci-best-practices/ --- .gitlab-ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9eda7bd00..387f54bbd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -585,8 +585,10 @@ deployment: - tags script: - cd ci/$IMAGE - # Build and push with git commit SHA tag - - docker build -t $CI_REGISTRY/graphviz/graphviz/$IMAGE:$CI_COMMIT_SHA . + # fetches the :latest image (not failing if image is not found) for caching + - docker pull $CI_REGISTRY/graphviz/graphviz/$IMAGE:latest || true + # Build and push with git commit SHA tag, reusing layers from the :latest image if possible + - docker build -t $CI_REGISTRY/graphviz/graphviz/$IMAGE:$CI_COMMIT_SHA --cache-from $CI_REGISTRY/graphviz/graphviz/$IMAGE:latest . - docker push $CI_REGISTRY/graphviz/graphviz/$IMAGE:$CI_COMMIT_SHA # Re-tag, push to :latest tag - docker tag $CI_REGISTRY/graphviz/graphviz/$IMAGE:$CI_COMMIT_SHA $CI_REGISTRY/graphviz/graphviz:latest -- 2.40.0