-
I came across this while looking for
.gitlab-ci.yml
examples.Just FYI.
You are doing
docker push $CONTAINER_IMAGE:latest
before thetest
stage. You might want to do that in therelease
stage, to avoid pushing a brokenlatest
image.However, this is tricky, since the
dind
service is not shared between the different scripts and stages. On https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#using-the-gitlab-container-registry they are building and pushing a test image in thebuild
stage, which is then pulled in the differenttest
stages and finally pulled, renamed and pushed in thedeploy
stage.It would be great if services could be shared between different stages and scripts to be able to avoid this pushing and pulling back and forth, but AFAIK that's not possible so far.
Edited by Peter Billen -
@cmorty Apparently composite commands need to be put in parens, i.e.
(docker pull $CONTAINER_IMAGE:latest || true)
-
@trkoch: It works well for me. The braces start a sub-shell, which shouldn't be necessary, as every line is run in a separate shell (if I remember things right).
-
@cmorty I tried Kaniko when first setting up my pipeline, it was a complete nightmare, every action requires it to take a filesystem snapshot which end ups consuming ~20min in a single docker build. After that I migrated to d-in-d and now they take ~5min
-
@diestrin: Unfortunately Kaniko still has quite some issues. After multiple successful projects I had to migrate one back. Though for me it wasn't a performance issue, but the resulting image didn't work. Yet that does not make DinD less of a security hell - at least if you have a shared server.
-
@cmorty you can also deploy a pod with docker running on it and use that as your private docker daemon
-
💻 @lucas.ramage -
🚴🏻 @zengqingfuWhen with
DOCKER_BUILDKIT=1
, using--cache-from
on gitlab will report this error:#8 ERROR: invalid build cache from {MediaType:application/vnd.docker.distribution.manifest.v2+json Digest:sha256:1e015f8fbc156c3a9f5f353bd75da9a3701f2dcc144057c9e82625d11fcca0a3 Size:7221 URLs:[] Annotations:map[] Platform:<nil>} ... ... rpc error: code = Unknown desc = error on cache query: invalid build cache from {MediaType:application/vnd.docker.distribution.manifest.v2+json Digest:sha256:1e015f8fbc156c3a9f5f353bd75da9a3701f2dcc144057c9e82625d11fcca0a3 Size:7221 URLs:[] Annotations:map[] Platform:<nil>}
Is there any solutions?
-
@zengqingfu I just discovered you need to use
--build-arg BUILDKIT_INLINE_CACHE=1
, as detailed here.Edit: I think this is actually for layer level caching, but worth knowing. This is a useful article.
Edited by Toby Griffiths
Please register or sign in to comment