]> granicus.if.org Git - graphviz/commitdiff
Reuse docker images where possible
authorMark Hansen <markhansen@google.com>
Sat, 20 Feb 2021 04:01:25 +0000 (15:01 +1100)
committerMark Hansen <markhansen@google.com>
Sat, 20 Feb 2021 04:01:25 +0000 (15:01 +1100)
Should speed up CI docker image building.

Inspiration from
https://blog.callr.tech/building-docker-images-with-gitlab-ci-best-practices/

.gitlab-ci.yml

index 9eda7bd006e50b017626a864006849b625667300..387f54bbda4e36f1a71538f4e0aac6d4ccd56a24 100644 (file)
@@ -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