All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>,
	qemu-devel@nongnu.org
Cc: peterx@redhat.com, "Alex Bennée" <alex.bennee@linaro.org>,
	mjt@tls.msk.ru,
	"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
	"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>
Subject: Re: [PATCH v4 1/2] tests/docker/dockerfiles: add release.docker
Date: Wed, 28 Oct 2026 20:00:48 -0300	[thread overview]
Message-ID: <871p99juqn.fsf@suse.de> (raw)
In-Reply-To: <20261026210801.179790-2-pierrick.bouvier@oss.qualcomm.com>

Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> writes:

> This new dockerfile allows to build a distroless image containing only
> qemu stripped release binaries, their lib dependencies, and installed
> artifacts (roms, keymap, ...). There is no shell, no python, nothing
> else. This is achieved thanks to a multi-stage build, where we add qemu
> binaries, artifacts and libraries in a new scratch image. Image has
> the minimal size possible.
>
> This is based on Ubuntu, which has the advantage to have working
> containers available down to 14.04. Debian old old stable have broken
> apt sources for instance.
>
> This unique dockerfile works for all qemu versions >= 3.1.0 (2018).
> We could build down to v0.12.0, but it would require more tweaks in the
> dockerfile, so we keep it simple instead.
>
> To build the image, you need to provide a qemu and ubuntu version:
> $ podman build -f release.Dockerfile --build-arg QEMU_VERSION=v11.1.0 --build-arg UBUNTU_VERSION=24.04 -t qemu/v11.1.0
>
> To run it, as there is no shell, and no defined entrypoint, you need to
> choose the binary you want explicitely:
> $ podman run -it --rm qemu/v11.1.0 qemu-system-aarch64 --version
>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
> ---
>  tests/docker/dockerfiles/release.docker | 48 +++++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
>  create mode 100644 tests/docker/dockerfiles/release.docker
>
> diff --git a/tests/docker/dockerfiles/release.docker b/tests/docker/dockerfiles/release.docker
> new file mode 100644
> index 00000000000..ca6babde01e
> --- /dev/null
> +++ b/tests/docker/dockerfiles/release.docker
> @@ -0,0 +1,48 @@
> +ARG UBUNTU_VERSION="UBUNTU_VERSION_build_arg_must_be_set"
> +
> +FROM ubuntu:$UBUNTU_VERSION AS build
> +
> +# add deb-src for apt build-dep
> +RUN sed -e 's/Types: deb/Types: deb deb-src/' -i /etc/apt/sources.list.d/* || true
> +RUN sed -e 's/# deb-src/deb-src/' -i /etc/apt/sources.list
> +# archive.canonical.com is not reachable anymore, and cause a long timeout
> +RUN sed -e '/archive.canonical.com/d' -i /etc/apt/sources.list
> +
> +# build dependencies
> +RUN apt update && \
> +env DEBIAN_FRONTEND=noninteractive apt install -y git build-essential flex bison
> +RUN apt update && \
> +env DEBIAN_FRONTEND=noninteractive apt build-dep -y --arch-only qemu
> +
> +ARG QEMU_VERSION
> +RUN echo "QEMU_VERSION=${QEMU_VERSION:?QEMU_VERSION build arg must be set}"
> +ARG QEMU_REPO="https://gitlab.com/qemu-project/qemu.git"
> +
> +RUN cd /tmp && \
> +mkdir qemu && cd qemu && git init && \
> +git remote add origin "${QEMU_REPO}" && \
> +git fetch origin "${QEMU_VERSION}" --depth 1 && \
> +git checkout FETCH_HEAD && \
> +./configure --prefix=/opt/qemu --disable-docs --disable-werror && \
> +make install -j $(nproc) && \
> +strip /opt/qemu/bin/* && \
> +rm -rf /tmp/*
> +
> +# retrieve runtime dependencies (libs)
> +RUN ldd /opt/qemu/bin/* | grep '=>' | sed -e 's/.*=>//' -e 's/(.*//' | sort -u > /opt/qemu/libs
> +# store them in /deps/lib
> +RUN mkdir -p /deps/lib && cp --preserve --dereference $(cat /opt/qemu/libs) /deps/lib
> +# copy loader (with its original path)
> +RUN cp --preserve --parents --dereference /lib*/ld-linux* /deps/
> +
> +################################################################################
> +FROM scratch
> +
> +COPY --from=build /deps /
> +# copy qemu and all associated artifacts (roms, ...)
> +COPY --from=build /opt/qemu /usr
> +
> +# build with:
> +# podman build -f release.docker --build-arg QEMU_VERSION=v11.1.0 --build-arg UBUNTU_VERSION=24.04 -t qemu/v11.1.0
> +# run with:
> +# podman run -it --rm qemu/v11.1.0 qemu-system-aarch64 --version

Reviewed-by: Fabiano Rosas <farosas@suse.de>


  reply	other threads:[~2026-10-28 23:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 21:07 [PATCH v4 0/2] releases: build and run any QEMU release easily! Pierrick Bouvier
2026-10-26 21:08 ` [PATCH v4 1/2] tests/docker/dockerfiles: add release.docker Pierrick Bouvier
2026-10-28 23:00   ` Fabiano Rosas [this message]
2026-10-26 21:08 ` [PATCH v4 2/2] scripts: add build_release_container.sh Pierrick Bouvier
2026-10-28 23:00   ` Fabiano Rosas
2026-10-29  0:01     ` Pierrick Bouvier
2026-10-27  3:26 ` [PATCH v4 0/2] releases: build and run any QEMU release easily! Philippe Mathieu-Daudé
2026-10-29  0:10 ` Pierrick Bouvier

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=871p99juqn.fsf@suse.de \
    --to=farosas@suse.de \
    --cc=alex.bennee@linaro.org \
    --cc=mjt@tls.msk.ru \
    --cc=peterx@redhat.com \
    --cc=philmd@oss.qualcomm.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.