From: Mark Hansen Date: Sat, 20 Feb 2021 04:01:25 +0000 (+1100) Subject: Reuse docker images where possible X-Git-Tag: 2.47.0~63^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3615d89bb08e2f01fccb00a0283bc6ea43fd449d;p=graphviz 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/ --- 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