I use GitLab's pipelines to describe the deployment process. And, as part of it, I build Docker images. For that purpose, I use Docker-in-Docker to build those images (i.e. download the Docker-in-Docker
image and do all the Docker-stuff, inside of it).
I also set to use Docker Buildkit features. And one of them is --cache-from
option (which decreases build time). Which seems doesn't work with Docker-in-Docker
(at least, for me).
Here's the pipeline's config:
stages:
- build
- purge
- deploy
variables:
DOCKER_HOST: tcp://localhost:2375
DOCKER_TLS_CERTDIR: ""
DOCKER_BUILDKIT: 1
LATEST: ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}:${CI_COMMIT_REF_SLUG}
IMAGE_COMMIT_TAG: ${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}:${CI_COMMIT_SHORT_SHA}
services:
- docker:dind
build:
stage: build
image: docker:stable
script:
- docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}
- docker build --cache-from ${LATEST} -t ${LATEST} -t ${IMAGE_COMMIT_TAG} .
- docker push ${IMAGE_COMMIT_TAG}
- docker push ${LATEST}
The log output shows the BuildKit
is engaged, but there's nothing about using of 'CACHE'. And, the result of it -- 'build' stage takes much more time.
Please, your suggestions, ideas?