From: "Daniel P. Berrangé" <berrange@redhat.com>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-devel@nongnu.org, "Li-Wen Hsu" <lwhsu@freebsd.org>,
"Thomas Huth" <thuth@redhat.com>, "Kevin Wolf" <kwolf@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Michael Roth" <michael.roth@amd.com>,
"Qiuhao Li" <Qiuhao.Li@outlook.com>,
"Beraldo Leal" <bleal@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Cleber Rosa" <crosa@redhat.com>,
"Yonggang Luo" <luoyonggang@gmail.com>,
"Ed Maste" <emaste@freebsd.org>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Aurelien Jarno" <aurelien@aurel32.net>,
qemu-arm@nongnu.org, "Philippe Mathieu-Daudé" <philmd@linaro.org>,
qemu-block@nongnu.org,
"Bastian Koppelmann" <kbastian@mail.uni-paderborn.de>,
"John Snow" <jsnow@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Alexander Bulekov" <alxndr@bu.edu>,
"Hanna Reitz" <hreitz@redhat.com>, "Bandan Das" <bsd@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Darren Kenny" <darren.kenny@oracle.com>,
"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
"Pavel Dovgalyuk" <pavel.dovgaluk@ispras.ru>
Subject: Re: [PATCH 7/7] tests/gitlab: use kaniko to build images
Date: Tue, 28 Feb 2023 10:53:24 +0000 [thread overview]
Message-ID: <Y/3dJNGKgwByiR5U@redhat.com> (raw)
In-Reply-To: <20230224180857.1050220-8-alex.bennee@linaro.org>
On Fri, Feb 24, 2023 at 06:08:57PM +0000, Alex Bennée wrote:
> Apparently the docker-in-docker approach has some flaws including
> needing privileged mode to run and being quite slow. An alternative
> approach is to use Google's kaniko tool. It also works across
> different gitlab executors.
Interesting, I've not come across this tool before.
> Following the gitlab example code we drop all the direct docker calls
> and usage of the script and make a direct call to kaniko and hope the
> images are cacheable by others.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> .gitlab-ci.d/container-template.yml | 23 +++++++++--------------
> 1 file changed, 9 insertions(+), 14 deletions(-)
>
> diff --git a/.gitlab-ci.d/container-template.yml b/.gitlab-ci.d/container-template.yml
> index c434b9c8f3..c2d7950df8 100644
> --- a/.gitlab-ci.d/container-template.yml
> +++ b/.gitlab-ci.d/container-template.yml
> @@ -1,22 +1,17 @@
> .container_job_template:
> extends: .base_job_template
> - image: docker:stable
> + image:
> + name: gcr.io/kaniko-project/executor:v1.9.0-debug
> + entrypoint: [""]
> stage: containers
> - services:
> - - docker:dind
> before_script:
> - export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME:latest"
> - - export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/$NAME:latest"
> - - apk add python3
> - - docker info
> - - docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
> + - export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/qemu/$NAME:latest"
> script:
> - echo "TAG:$TAG"
> - echo "COMMON_TAG:$COMMON_TAG"
> - - ./tests/docker/docker.py --engine docker build
> - -t "qemu/$NAME" -f "tests/docker/dockerfiles/$NAME.docker"
> - -r $CI_REGISTRY/qemu-project/qemu
> - - docker tag "qemu/$NAME" "$TAG"
> - - docker push "$TAG"
> - after_script:
> - - docker logout
> + - /kaniko/executor
> + --reproducible
> + --context "${CI_PROJECT_DIR}"
> + --dockerfile "${CI_PROJECT_DIR}/tests/docker/dockerfiles/$NAME.docker"
> + --destination "${TAG}"
AFAICT from reading the docs, this does not allow for caching of layers
from the previous built image, so will always do a from scratch build.
This feels like it would kill any performance benefits over docker.
https://github.com/GoogleContainerTools/kaniko#caching
"Users can opt into caching by setting the --cache=true flag. A
remote repository for storing cached layers can be provided via
the --cache-repo flag. If this flag isn't provided, a cached
repo will be inferred from the --destination provided."
So it would sound like we need --cache=true adding to this command,
and in theory it should prime its cache from ${TAG}, but i'm not
entirely confident in that without testing. Also does not seem
like its psosible to have the dual cache COMMON_TAG + TAG, which
is particularly important for forks, since COMMON_TAG is more
likely to be up2date.
We could live with the latter restriction if we *always* used
COMMON_TAG as the cache, because 99% of the time forks are
going to just be using dockerfiles that match upstream. Only
those few contributors who have a branch that's changing
the dockerfiles would benefit from pointing the cache at
their fork.
So we could achieve that I believe using
- /kaniko/executor
--reproducible
--context "${CI_PROJECT_DIR}"
--cache=true
--cache-repo "${COMMON_TAG}"
--dockerfile "${CI_PROJECT_DIR}/tests/docker/dockerfiles/$NAME.docker"
--destination "${TAG}"
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2023-02-28 10:53 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-24 18:08 [PATCH 0/7] testing/next: docker.py removal and kaniko updates Alex Bennée
2023-02-24 18:08 ` [PATCH 1/7] configure: expose the direct container command Alex Bennée
2023-02-27 11:18 ` Daniel P. Berrangé
2023-02-28 11:54 ` Philippe Mathieu-Daudé
2023-02-24 18:08 ` [PATCH 2/7] tests/dockerfiles: unify debian-toolchain references Alex Bennée
2023-02-27 11:14 ` Daniel P. Berrangé
2023-02-28 11:38 ` Philippe Mathieu-Daudé
2023-02-24 18:08 ` [PATCH 3/7] tests/lcitool: append user setting stanza to dockerfiles Alex Bennée
2023-02-28 10:38 ` Daniel P. Berrangé
2023-02-24 18:08 ` [PATCH 4/7] tests/docker: add USER stanzas to non-lci images Alex Bennée
2023-02-28 10:40 ` Daniel P. Berrangé
2023-02-28 11:43 ` Philippe Mathieu-Daudé
2023-02-28 11:45 ` Daniel P. Berrangé
2023-02-28 12:18 ` Alex Bennée
2023-02-28 12:21 ` Philippe Mathieu-Daudé
2023-02-24 18:08 ` [PATCH 5/7] tests/docker: use direct RUNC call to build containers Alex Bennée
2023-02-28 10:40 ` Daniel P. Berrangé
2023-02-28 11:55 ` Philippe Mathieu-Daudé
2023-02-24 18:08 ` [PATCH 6/7] tests/docker: use direct RUNC call to run test jobs Alex Bennée
2023-02-28 10:45 ` Daniel P. Berrangé
2023-02-24 18:08 ` [PATCH 7/7] tests/gitlab: use kaniko to build images Alex Bennée
2023-02-28 10:53 ` Daniel P. Berrangé [this message]
2023-02-28 11:58 ` [PATCH 0/7] testing/next: docker.py removal and kaniko updates Philippe Mathieu-Daudé
2023-02-28 12:58 ` Daniel P. Berrangé
2023-02-28 13:29 ` Philippe Mathieu-Daudé
2023-02-28 13:34 ` Daniel P. Berrangé
2023-02-28 13:57 ` Alex Bennée
2023-02-28 14:33 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y/3dJNGKgwByiR5U@redhat.com \
--to=berrange@redhat.com \
--cc=Qiuhao.Li@outlook.com \
--cc=alex.bennee@linaro.org \
--cc=alxndr@bu.edu \
--cc=armbru@redhat.com \
--cc=aurelien@aurel32.net \
--cc=bleal@redhat.com \
--cc=bsd@redhat.com \
--cc=crosa@redhat.com \
--cc=darren.kenny@oracle.com \
--cc=emaste@freebsd.org \
--cc=hreitz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kbastian@mail.uni-paderborn.de \
--cc=kwolf@redhat.com \
--cc=luoyonggang@gmail.com \
--cc=lwhsu@freebsd.org \
--cc=marcandre.lureau@redhat.com \
--cc=michael.roth@amd.com \
--cc=pavel.dovgaluk@ispras.ru \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=thuth@redhat.com \
--cc=wainersm@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).