Docker Buildx Caching on CI server

Docker build times can be improved on CI server with Docker BuildKit caching. Usually each pipeline run on the CI tool is ephermal hence the local image cache will not be saved.

# use some tool to restore a cache from previous builds
cache-restore /tmp/docker-cache
docker buildx \
  --cache-from type=local,dest=/tmp/docker-cache \
  --cache-to   type=local,dest=/tmp/docker-cache,mode=max \
  --tag your.registry/image:tag \
  --push .
# use some tool to save the cache for future use
cache-save /tmp/docker-cache