Skip to contentSkip to conversation

testing/next: docker.py removal and kaniko updates

PATCH In review Alex Bennée 3 participants 28 messages Feb 24, 2023 – Feb 28, 2023 RISC-V

lore
Share & tools
lore
#0 lore raw

cover testing/next: docker.py removal and kaniko updates

This series attempts to remove our dependence on the docker.py script and build things directly with the appropriate tool. I've been noodling around with how we build images on gitlab to see if they can cache better because the normal case should be we don't need to rebuild everything if the upstream distro hasn't updated its package list.

Anyway what do people think?

Alex Bennée (7):
configure: expose the direct container command tests/dockerfiles: unify debian-toolchain references tests/lcitool: append user setting stanza to dockerfiles tests/docker: add USER stanzas to non-lci images tests/docker: use direct RUNC call to build containers tests/docker: use direct RUNC call to run test jobs tests/gitlab: use kaniko to build images

 configure                                     |  3 +++
 .gitlab-ci.d/cirrus/freebsd-12.vars           |  5 ++++
 .gitlab-ci.d/cirrus/freebsd-13.vars           |  5 ++++
 .gitlab-ci.d/cirrus/macos-12.vars             |  5 ++++
 .gitlab-ci.d/container-template.yml           | 23 +++++++---------
 tests/docker/Makefile.include                 | 27 +++++++++++--------
 tests/docker/dockerfiles/alpine.docker        |  5 ++++
 tests/docker/dockerfiles/centos8.docker       |  5 ++++
 .../dockerfiles/debian-all-test-cross.docker  |  5 ++++
 .../dockerfiles/debian-alpha-cross.docker     |  5 ++++
 .../dockerfiles/debian-amd64-cross.docker     |  5 ++++
 tests/docker/dockerfiles/debian-amd64.docker  |  5 ++++
 .../dockerfiles/debian-arm64-cross.docker     |  5 ++++
 .../dockerfiles/debian-armel-cross.docker     |  5 ++++
 .../dockerfiles/debian-armhf-cross.docker     |  5 ++++
 .../dockerfiles/debian-hexagon-cross.docker   |  5 ++++
 .../dockerfiles/debian-hppa-cross.docker      |  5 ++++
 .../dockerfiles/debian-loongarch-cross.docker |  5 ++++
 .../dockerfiles/debian-m68k-cross.docker      |  5 ++++
 .../dockerfiles/debian-mips-cross.docker      |  5 ++++
 .../dockerfiles/debian-mips64-cross.docker    |  5 ++++
 .../dockerfiles/debian-mips64el-cross.docker  |  5 ++++
 .../dockerfiles/debian-mipsel-cross.docker    |  5 ++++
 tests/docker/dockerfiles/debian-native.docker |  5 ++++
 .../debian-powerpc-test-cross.docker          |  6 ++++-
 .../dockerfiles/debian-ppc64el-cross.docker   |  5 ++++
 .../dockerfiles/debian-riscv64-cross.docker   |  5 ++++
 .../debian-riscv64-test-cross.docker          |  5 ++++
 .../dockerfiles/debian-s390x-cross.docker     |  5 ++++
 .../dockerfiles/debian-sh4-cross.docker       |  5 ++++
 .../dockerfiles/debian-sparc64-cross.docker   |  5 ++++
 .../dockerfiles/debian-toolchain.docker       |  9 +++++--
 .../dockerfiles/debian-tricore-cross.docker   |  5 ++++
 .../dockerfiles/debian-xtensa-cross.docker    |  5 ++++
 .../dockerfiles/fedora-cris-cross.docker      |  5 ++++
 .../dockerfiles/fedora-i386-cross.docker      |  5 ++++
 .../dockerfiles/fedora-win32-cross.docker     |  5 ++++
 .../dockerfiles/fedora-win64-cross.docker     |  5 ++++
 tests/docker/dockerfiles/fedora.docker        |  5 ++++
 tests/docker/dockerfiles/opensuse-leap.docker |  5 ++++
 tests/docker/dockerfiles/python.docker        |  5 ++++
 tests/docker/dockerfiles/ubuntu2004.docker    |  5 ++++
 tests/docker/dockerfiles/ubuntu2204.docker    |  5 ++++
 tests/lcitool/refresh                         | 11 +++++++-
 44 files changed, 240 insertions(+), 29 deletions(-)
Signature · 1 line
2.39.1
#1 lore raw

PATCH 1/7 configure: expose the direct container command

In the process of migrating away from using docker.py to build our containers we need to expose the command to the build environment. The script is still a useful way to probe which command works though.

---
 configure | 3 +++
 1 file changed, 3 insertions(+)
configure +3 -0
index cf6db3d551..b6a1cebad9 100755
@@ -1744,6 +1744,7 @@ fi
 # functions to probe cross compilers
 
 container="no"
+runc=""
 if test $use_containers = "yes" && (has "docker" || has "podman"); then
     case $($python "$source_path"/tests/docker/docker.py probe) in
         *docker) container=docker ;;
@@ -1752,6 +1753,7 @@ if test $use_containers = "yes" && (has "docker" || has "podman"); then
     esac
     if test "$container" != "no"; then
         docker_py="$python $source_path/tests/docker/docker.py --engine $container"
+        runc=$($python "$source_path"/tests/docker/docker.py probe)
     fi
 fi
 
@@ -2351,6 +2353,7 @@ fi
 
 if test "$container" != no; then
     echo "ENGINE=$container" >> $config_host_mak
+    echo "RUNC=$runc" >> $config_host_mak
 fi
 echo "ROMS=$roms" >> $config_host_mak
 echo "MAKE=$make" >> $config_host_mak
Signature · 1 line
2.39.1
Reviewed-by on v1 1/7
#2 lore raw

Re: [PATCH 1/7] configure: expose the direct container command

Quoted 8 lines · Alex Bennée

In the process of migrating away from using docker.py to build our containers we need to expose the command to the build environment. The script is still a useful way to probe which command works though.

---
 configure | 3 +++
 1 file changed, 3 insertions(+)

With regards,
Daniel

Signature · 3 lines
|: 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 :|
Reviewed-by on v1 1/7
#3 lore raw

Re: [PATCH 1/7] configure: expose the direct container command

In reply to Alex Bennée
Quoted 8 lines · Alex Bennée

In the process of migrating away from using docker.py to build our containers we need to expose the command to the build environment. The script is still a useful way to probe which command works though.

---
  configure | 3 +++
  1 file changed, 3 insertions(+)
#4 lore raw

PATCH 2/7 tests/dockerfiles: unify debian-toolchain references

In reply to Alex Bennée

We use the debian release number elsewhere so fix it for consistency along with the broken comment.

---
 tests/docker/dockerfiles/debian-toolchain.docker | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/docker/dockerfiles/debian-toolchain.docker +2 -2
index 6c73408b34..dc9545857f 100644
@@ -30,7 +30,7 @@ ADD build-toolchain.sh /root/build-toolchain.sh
 RUN cd /root && ./build-toolchain.sh
 
 # Throw away the extra toolchain build deps, the downloaded source,
-# and the build trees by restoring the original debian10 image,
+# and the build trees by restoring the original image,
 # then copying the built toolchain from stage 0.
-FROM docker.io/library/debian:bullseye-slim
+FROM docker.io/library/debian:11-slim
 COPY --from=0 /usr/local /usr/local
Signature · 1 line
2.39.1
Reviewed-by on v1 2/7
#5 lore raw

Re: [PATCH 2/7] tests/dockerfiles: unify debian-toolchain references

Quoted 7 lines · Alex Bennée

We use the debian release number elsewhere so fix it for consistency along with the broken comment.

---
 tests/docker/dockerfiles/debian-toolchain.docker | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

With regards,
Daniel

Signature · 3 lines
|: 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 :|
Reviewed-by on v1 2/7
#6 lore raw

Re: [PATCH 2/7] tests/dockerfiles: unify debian-toolchain references

In reply to Alex Bennée
Quoted 7 lines · Alex Bennée

We use the debian release number elsewhere so fix it for consistency along with the broken comment.

---
  tests/docker/dockerfiles/debian-toolchain.docker | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
#7 lore raw

PATCH 3/7 tests/lcitool: append user setting stanza to dockerfiles

In reply to Alex Bennée

For the cross-compilation use-case it is important to add the host user to the dockerfile so we can map them to the docker environment when cross-building files.

---
 .gitlab-ci.d/cirrus/freebsd-12.vars                   |  5 +++++
 .gitlab-ci.d/cirrus/freebsd-13.vars                   |  5 +++++
 .gitlab-ci.d/cirrus/macos-12.vars                     |  5 +++++
 tests/docker/dockerfiles/alpine.docker                |  5 +++++
 tests/docker/dockerfiles/centos8.docker               |  5 +++++
 tests/docker/dockerfiles/debian-amd64-cross.docker    |  5 +++++
 tests/docker/dockerfiles/debian-amd64.docker          |  5 +++++
 tests/docker/dockerfiles/debian-arm64-cross.docker    |  5 +++++
 tests/docker/dockerfiles/debian-armel-cross.docker    |  5 +++++
 tests/docker/dockerfiles/debian-armhf-cross.docker    |  5 +++++
 tests/docker/dockerfiles/debian-mips64el-cross.docker |  5 +++++
 tests/docker/dockerfiles/debian-mipsel-cross.docker   |  5 +++++
 tests/docker/dockerfiles/debian-ppc64el-cross.docker  |  5 +++++
 tests/docker/dockerfiles/debian-s390x-cross.docker    |  5 +++++
 tests/docker/dockerfiles/fedora-win32-cross.docker    |  5 +++++
 tests/docker/dockerfiles/fedora-win64-cross.docker    |  5 +++++
 tests/docker/dockerfiles/fedora.docker                |  5 +++++
 tests/docker/dockerfiles/opensuse-leap.docker         |  5 +++++
 tests/docker/dockerfiles/ubuntu2004.docker            |  5 +++++
 tests/docker/dockerfiles/ubuntu2204.docker            |  5 +++++
 tests/lcitool/refresh                                 | 11 ++++++++++-
 21 files changed, 110 insertions(+), 1 deletion(-)
.gitlab-ci.d/cirrus/freebsd-12.vars +5 -0
index 44d8a2a511..0bff53be44 100644
@@ -14,3 +14,8 @@ PIP3='/usr/local/bin/pip-3.8'
 PKGS='alsa-lib bash bison bzip2 ca_root_nss capstone4 ccache cdrkit-genisoimage cmocka ctags curl cyrus-sasl dbus diffutils dtc flex fusefs-libs3 gettext git glib gmake gnutls gsed gtk3 json-c libepoxy libffi libgcrypt libjpeg-turbo libnfs libslirp libspice-server libssh libtasn1 llvm lzo2 meson ncurses nettle ninja opencv pixman pkgconf png py39-numpy py39-pillow py39-pip py39-sphinx py39-sphinx_rtd_theme py39-yaml python3 rpm2cpio sdl2 sdl2_image snappy sndio socat spice-protocol tesseract usbredir virglrenderer vte3 zstd'
 PYPI_PKGS=''
 PYTHON='/usr/local/bin/python3'
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
.gitlab-ci.d/cirrus/freebsd-13.vars +5 -0
index 7622c849b2..235d08a5ee 100644
@@ -14,3 +14,8 @@ PIP3='/usr/local/bin/pip-3.8'
 PKGS='alsa-lib bash bison bzip2 ca_root_nss capstone4 ccache cdrkit-genisoimage cmocka ctags curl cyrus-sasl dbus diffutils dtc flex fusefs-libs3 gettext git glib gmake gnutls gsed gtk3 json-c libepoxy libffi libgcrypt libjpeg-turbo libnfs libslirp libspice-server libssh libtasn1 llvm lzo2 meson ncurses nettle ninja opencv pixman pkgconf png py39-numpy py39-pillow py39-pip py39-sphinx py39-sphinx_rtd_theme py39-yaml python3 rpm2cpio sdl2 sdl2_image snappy sndio socat spice-protocol tesseract usbredir virglrenderer vte3 zstd'
 PYPI_PKGS=''
 PYTHON='/usr/local/bin/python3'
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
.gitlab-ci.d/cirrus/macos-12.vars +5 -0
index da6aa6469b..599e210707 100644
@@ -14,3 +14,8 @@ PIP3='/opt/homebrew/bin/pip3'
 PKGS='bash bc bison bzip2 capstone ccache cmocka ctags curl dbus diffutils dtc flex gcovr gettext git glib gnu-sed gnutls gtk+3 jemalloc jpeg-turbo json-c libepoxy libffi libgcrypt libiscsi libnfs libpng libslirp libssh libtasn1 libusb llvm lzo make meson ncurses nettle ninja pixman pkg-config python3 rpm2cpio sdl2 sdl2_image snappy socat sparse spice-protocol tesseract usbredir vde vte3 zlib zstd'
 PYPI_PKGS='PyYAML numpy pillow sphinx sphinx-rtd-theme'
 PYTHON='/opt/homebrew/bin/python3'
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
tests/docker/dockerfiles/alpine.docker +5 -0
index 56cf14e553..7b82dec8e5 100644
@@ -124,3 +124,8 @@ ENV LANG "en_US.UTF-8"
 ENV MAKE "/usr/bin/make"
 ENV NINJA "/usr/bin/ninja"
 ENV PYTHON "/usr/bin/python3"
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
tests/docker/dockerfiles/centos8.docker +5 -0
index 1291ae1b04..2cca33e730 100644
@@ -134,3 +134,8 @@ ENV LANG "en_US.UTF-8"
 ENV MAKE "/usr/bin/make"
 ENV NINJA "/usr/bin/ninja"
 ENV PYTHON "/usr/bin/python3"
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
tests/docker/dockerfiles/debian-amd64-cross.docker +5 -0
index 856db95100..50a2b34c62 100644
@@ -169,3 +169,8 @@ ENV ABI "x86_64-linux-gnu"
 ENV MESON_OPTS "--cross-file=x86_64-linux-gnu"
 ENV QEMU_CONFIGURE_OPTS --cross-prefix=x86_64-linux-gnu-
 ENV DEF_TARGET_LIST x86_64-softmmu,x86_64-linux-user,i386-softmmu,i386-linux-user
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
tests/docker/dockerfiles/debian-amd64.docker +5 -0
index e3dba71ad5..d77e3d169a 100644
@@ -155,3 +155,8 @@ RUN git clone https://github.com/luigirizzo/netmap.git /usr/src/netmap
 RUN cd /usr/src/netmap && git checkout v11.3
 RUN cd /usr/src/netmap/LINUX && ./configure --no-drivers --no-apps --kernel-dir=$(ls -d /usr/src/linux-headers-*-amd64) && make install
 ENV QEMU_CONFIGURE_OPTS --enable-netmap
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
tests/docker/dockerfiles/debian-arm64-cross.docker +5 -0
index b00e9e9bcf..5288435da1 100644
@@ -168,3 +168,8 @@ ENV ABI "aarch64-linux-gnu"
 ENV MESON_OPTS "--cross-file=aarch64-linux-gnu"
 ENV QEMU_CONFIGURE_OPTS --cross-prefix=aarch64-linux-gnu-
 ENV DEF_TARGET_LIST aarch64-softmmu,aarch64-linux-user
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
tests/docker/dockerfiles/debian-armel-cross.docker +5 -0
index fb1129f256..95ce5bbfd0 100644
@@ -167,3 +167,8 @@ ENV ABI "arm-linux-gnueabi"
 ENV MESON_OPTS "--cross-file=arm-linux-gnueabi"
 ENV QEMU_CONFIGURE_OPTS --cross-prefix=arm-linux-gnueabi-
 ENV DEF_TARGET_LIST arm-softmmu,arm-linux-user,armeb-linux-user
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
tests/docker/dockerfiles/debian-armhf-cross.docker +5 -0
index 7a2b864a38..20f6074d5e 100644
@@ -168,3 +168,8 @@ ENV ABI "arm-linux-gnueabihf"
 ENV MESON_OPTS "--cross-file=arm-linux-gnueabihf"
 ENV QEMU_CONFIGURE_OPTS --cross-prefix=arm-linux-gnueabihf-
 ENV DEF_TARGET_LIST arm-softmmu,arm-linux-user
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
tests/docker/dockerfiles/debian-mips64el-cross.docker +5 -0
index 5a3340e964..15f8568cb1 100644
@@ -165,3 +165,8 @@ ENV ABI "mips64el-linux-gnuabi64"
 ENV MESON_OPTS "--cross-file=mips64el-linux-gnuabi64"
 ENV QEMU_CONFIGURE_OPTS --cross-prefix=mips64el-linux-gnuabi64-
 ENV DEF_TARGET_LIST mips64el-softmmu,mips64el-linux-user
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
tests/docker/dockerfiles/debian-mipsel-cross.docker +5 -0
index 422fdebe8f..cc6a44dbe7 100644
@@ -165,3 +165,8 @@ ENV ABI "mipsel-linux-gnu"
 ENV MESON_OPTS "--cross-file=mipsel-linux-gnu"
 ENV QEMU_CONFIGURE_OPTS --cross-prefix=mipsel-linux-gnu-
 ENV DEF_TARGET_LIST mipsel-softmmu,mipsel-linux-user
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
tests/docker/dockerfiles/debian-ppc64el-cross.docker +5 -0
index 78d7ae6211..7ff1e44b88 100644
@@ -167,3 +167,8 @@ ENV ABI "powerpc64le-linux-gnu"
 ENV MESON_OPTS "--cross-file=powerpc64le-linux-gnu"
 ENV QEMU_CONFIGURE_OPTS --cross-prefix=powerpc64le-linux-gnu-
 ENV DEF_TARGET_LIST ppc64-softmmu,ppc64-linux-user
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
tests/docker/dockerfiles/debian-s390x-cross.docker +5 -0
index d06ea3605a..d084f34cb1 100644
@@ -166,3 +166,8 @@ ENV ABI "s390x-linux-gnu"
 ENV MESON_OPTS "--cross-file=s390x-linux-gnu"
 ENV QEMU_CONFIGURE_OPTS --cross-prefix=s390x-linux-gnu-
 ENV DEF_TARGET_LIST s390x-softmmu,s390x-linux-user
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
tests/docker/dockerfiles/fedora-win32-cross.docker +5 -0
index 21ed1c6081..87d91a6759 100644
@@ -100,3 +100,8 @@ ENV ABI "i686-w64-mingw32"
 ENV MESON_OPTS "--cross-file=/usr/share/mingw/toolchain-mingw32.meson"
 ENV QEMU_CONFIGURE_OPTS --cross-prefix=i686-w64-mingw32-
 ENV DEF_TARGET_LIST i386-softmmu
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
tests/docker/dockerfiles/fedora-win64-cross.docker +5 -0
index 95d30e7936..877766ec6b 100644
@@ -100,3 +100,8 @@ ENV ABI "x86_64-w64-mingw32"
 ENV MESON_OPTS "--cross-file=/usr/share/mingw/toolchain-mingw64.meson"
 ENV QEMU_CONFIGURE_OPTS --cross-prefix=x86_64-w64-mingw32-
 ENV DEF_TARGET_LIST x86_64-softmmu
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
tests/docker/dockerfiles/fedora.docker +5 -0
index 8e06d080b8..4a7a986dfd 100644
@@ -146,3 +146,8 @@ ENV LANG "en_US.UTF-8"
 ENV MAKE "/usr/bin/make"
 ENV NINJA "/usr/bin/ninja"
 ENV PYTHON "/usr/bin/python3"
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
tests/docker/dockerfiles/opensuse-leap.docker +5 -0
index 568c1c979f..f5f8d4714d 100644
@@ -137,3 +137,8 @@ ENV LANG "en_US.UTF-8"
 ENV MAKE "/usr/bin/make"
 ENV NINJA "/usr/bin/ninja"
 ENV PYTHON "/usr/bin/python3"
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
tests/docker/dockerfiles/ubuntu2004.docker +5 -0
index 75233064de..4d257b922b 100644
@@ -146,3 +146,8 @@ ENV LANG "en_US.UTF-8"
 ENV MAKE "/usr/bin/make"
 ENV NINJA "/usr/bin/ninja"
 ENV PYTHON "/usr/bin/python3"
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
tests/docker/dockerfiles/ubuntu2204.docker +5 -0
index 30b9e56793..41c2d2878e 100644
@@ -145,3 +145,8 @@ ENV LANG "en_US.UTF-8"
 ENV MAKE "/usr/bin/make"
 ENV NINJA "/usr/bin/ninja"
 ENV PYTHON "/usr/bin/python3"
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file
tests/lcitool/refresh +10 -1
index cc9e34ac87..88bf33fb74 100755
@@ -40,6 +40,15 @@ def atomic_write(filename, content):
         tmp.unlink()
         raise
 
+# Optional user setting, this will always be the last thing added
+# so maximise the number of layers that are cached
+add_user_mapping = [
+    "# As a final step configure the user (if env is defined)",
+    "ARG USER",
+    "ARG UID",
+    "RUN if [ \"${USER}\" ]; then \\",
+    "  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi"
+]
 
 def generate(filename, cmd, trailer):
     print("Generate %s" % filename)
@@ -51,9 +60,9 @@ def generate(filename, cmd, trailer):
     content = lcitool.stdout.decode("utf8")
     if trailer is not None:
         content += trailer
+    content += "\n".join(add_user_mapping)
     atomic_write(filename, content)
 
-
 def generate_dockerfile(host, target, cross=None, trailer=None):
     filename = Path(src_dir, "tests", "docker", "dockerfiles", host + ".docker")
     cmd = lcitool_cmd + ["dockerfile"]
Signature · 1 line
2.39.1
#8 lore raw

Re: [PATCH 3/7] tests/lcitool: append user setting stanza to dockerfiles

Quoted 36 lines · Alex Bennée

For the cross-compilation use-case it is important to add the host user to the dockerfile so we can map them to the docker environment when cross-building files.

---
 .gitlab-ci.d/cirrus/freebsd-12.vars                   |  5 +++++
 .gitlab-ci.d/cirrus/freebsd-13.vars                   |  5 +++++
 .gitlab-ci.d/cirrus/macos-12.vars                     |  5 +++++
 tests/docker/dockerfiles/alpine.docker                |  5 +++++
 tests/docker/dockerfiles/centos8.docker               |  5 +++++
 tests/docker/dockerfiles/debian-amd64-cross.docker    |  5 +++++
 tests/docker/dockerfiles/debian-amd64.docker          |  5 +++++
 tests/docker/dockerfiles/debian-arm64-cross.docker    |  5 +++++
 tests/docker/dockerfiles/debian-armel-cross.docker    |  5 +++++
 tests/docker/dockerfiles/debian-armhf-cross.docker    |  5 +++++
 tests/docker/dockerfiles/debian-mips64el-cross.docker |  5 +++++
 tests/docker/dockerfiles/debian-mipsel-cross.docker   |  5 +++++
 tests/docker/dockerfiles/debian-ppc64el-cross.docker  |  5 +++++
 tests/docker/dockerfiles/debian-s390x-cross.docker    |  5 +++++
 tests/docker/dockerfiles/fedora-win32-cross.docker    |  5 +++++
 tests/docker/dockerfiles/fedora-win64-cross.docker    |  5 +++++
 tests/docker/dockerfiles/fedora.docker                |  5 +++++
 tests/docker/dockerfiles/opensuse-leap.docker         |  5 +++++
 tests/docker/dockerfiles/ubuntu2004.docker            |  5 +++++
 tests/docker/dockerfiles/ubuntu2204.docker            |  5 +++++
 tests/lcitool/refresh                                 | 11 ++++++++++-
 21 files changed, 110 insertions(+), 1 deletion(-)
.gitlab-ci.d/cirrus/freebsd-12.vars +0 -0
index 44d8a2a511..0bff53be44 100644

.gitlab-ci.d/cirrus/freebsd-12.vars PIP3='/usr/local/bin/pip-3.8' · line 21

Quoted 9 lines
.gitlab-ci.d/cirrus/freebsd-12.vars +5 -0
@@ -14,3 +14,8 @@ PIP3='/usr/local/bin/pip-3.8'
 PKGS='alsa-lib bash bison bzip2 ca_root_nss capstone4 ccache cdrkit-genisoimage cmocka ctags curl cyrus-sasl dbus diffutils dtc flex fusefs-libs3 gettext git glib gmake gnutls gsed gtk3 json-c libepoxy libffi libgcrypt libjpeg-turbo libnfs libslirp libspice-server libssh libtasn1 llvm lzo2 meson ncurses nettle ninja opencv pixman pkgconf png py39-numpy py39-pillow py39-pip py39-sphinx py39-sphinx_rtd_theme py39-yaml python3 rpm2cpio sdl2 sdl2_image snappy sndio socat spice-protocol tesseract usbredir virglrenderer vte3 zstd'
 PYPI_PKGS=''
 PYTHON='/usr/local/bin/python3'
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file

The cirrus/*.vars files aren't dockerfiles, they're shell scripts, so don't modify them

Quoted 5 lines
tests/docker/dockerfiles/alpine.docker +0 -0
index 56cf14e553..7b82dec8e5 100644

tests/docker/dockerfiles/alpine.docker ENV LANG "en_US.UTF-8" · line 131

Quoted 9 lines
tests/docker/dockerfiles/alpine.docker +5 -0
@@ -124,3 +124,8 @@ ENV LANG "en_US.UTF-8"
 ENV MAKE "/usr/bin/make"
 ENV NINJA "/usr/bin/ninja"
 ENV PYTHON "/usr/bin/python3"
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
\ No newline at end of file

Add a trailing newline to these perhaps ?

Quoted 21 lines
tests/lcitool/refresh +9 -0
index cc9e34ac87..88bf33fb74 100755
@@ -40,6 +40,15 @@ def atomic_write(filename, content):
         tmp.unlink()
         raise
 
+# Optional user setting, this will always be the last thing added
+# so maximise the number of layers that are cached
+add_user_mapping = [
+    "# As a final step configure the user (if env is defined)",
+    "ARG USER",
+    "ARG UID",
+    "RUN if [ \"${USER}\" ]; then \\",
+    "  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi"
+]
 
 def generate(filename, cmd, trailer):
     print("Generate %s" % filename)

tests/lcitool/refresh def generate(filename, cmd, trailer): · line 63

Quoted 4 lines
tests/lcitool/refresh +1 -0
@@ -51,9 +60,9 @@ def generate(filename, cmd, trailer):
     content = lcitool.stdout.decode("utf8")
     if trailer is not None:
         content += trailer
+    content += "\n".join(add_user_mapping)

if filename.endswith(".docker"):

       content += "\n".join(add_user_mapping)

to avoid splattering the cirrus vars files

With regards,
Daniel

Signature · 3 lines
|: 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 :|
#9 lore raw

PATCH 4/7 tests/docker: add USER stanzas to non-lci images

In reply to Alex Bennée

These are flat but not generated by lcitool so we need to manually update them with the useradd stanza.

---
 tests/docker/dockerfiles/debian-all-test-cross.docker     | 5 +++++
 tests/docker/dockerfiles/debian-alpha-cross.docker        | 5 +++++
 tests/docker/dockerfiles/debian-hexagon-cross.docker      | 5 +++++
 tests/docker/dockerfiles/debian-hppa-cross.docker         | 5 +++++
 tests/docker/dockerfiles/debian-loongarch-cross.docker    | 5 +++++
 tests/docker/dockerfiles/debian-m68k-cross.docker         | 5 +++++
 tests/docker/dockerfiles/debian-mips-cross.docker         | 5 +++++
 tests/docker/dockerfiles/debian-mips64-cross.docker       | 5 +++++
 tests/docker/dockerfiles/debian-native.docker             | 5 +++++
 tests/docker/dockerfiles/debian-powerpc-test-cross.docker | 6 +++++-
 tests/docker/dockerfiles/debian-riscv64-cross.docker      | 5 +++++
 tests/docker/dockerfiles/debian-riscv64-test-cross.docker | 5 +++++
 tests/docker/dockerfiles/debian-sh4-cross.docker          | 5 +++++
 tests/docker/dockerfiles/debian-sparc64-cross.docker      | 5 +++++
 tests/docker/dockerfiles/debian-toolchain.docker          | 5 +++++
 tests/docker/dockerfiles/debian-tricore-cross.docker      | 5 +++++
 tests/docker/dockerfiles/debian-xtensa-cross.docker       | 5 +++++
 tests/docker/dockerfiles/fedora-cris-cross.docker         | 5 +++++
 tests/docker/dockerfiles/fedora-i386-cross.docker         | 5 +++++
 tests/docker/dockerfiles/python.docker                    | 5 +++++
 20 files changed, 100 insertions(+), 1 deletion(-)
tests/docker/dockerfiles/debian-all-test-cross.docker +5 -0
index 8dc5e1b5de..981e9bdc7b 100644
@@ -61,3 +61,8 @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \
 
 ENV QEMU_CONFIGURE_OPTS --disable-system --disable-docs --disable-tools
 ENV DEF_TARGET_LIST aarch64-linux-user,alpha-linux-user,arm-linux-user,hppa-linux-user,i386-linux-user,m68k-linux-user,mips-linux-user,mips64-linux-user,mips64el-linux-user,mipsel-linux-user,ppc-linux-user,ppc64-linux-user,ppc64le-linux-user,riscv64-linux-user,s390x-linux-user,sh4-linux-user,sparc64-linux-user
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/docker/dockerfiles/debian-alpha-cross.docker +5 -0
index 4eeb43c78a..7fa7bf1bde 100644
@@ -12,3 +12,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
     eatmydata apt-get install --no-install-recommends -y \
         gcc-alpha-linux-gnu \
         libc6.1-dev-alpha-cross
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/docker/dockerfiles/debian-hexagon-cross.docker +5 -0
index 8a0d748343..5308ccb8fe 100644
@@ -33,3 +33,8 @@ ENV TOOLCHAIN_URL https://codelinaro.jfrog.io/artifactory/codelinaro-toolchain-f
 
 RUN curl -#SL "$TOOLCHAIN_URL" | tar -xJC "$TOOLCHAIN_INSTALL"
 ENV PATH $PATH:${TOOLCHAIN_INSTALL}/${TOOLCHAIN_BASENAME}/x86_64-linux-gnu/bin
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/docker/dockerfiles/debian-hppa-cross.docker +5 -0
index af1c8403d8..dd47ffdfa4 100644
@@ -12,3 +12,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
     eatmydata apt-get install --no-install-recommends -y \
         gcc-hppa-linux-gnu \
         libc6-dev-hppa-cross
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/docker/dockerfiles/debian-loongarch-cross.docker +5 -0
index a8e8e98909..9d957547b5 100644
@@ -25,3 +25,8 @@ RUN curl -#SL https://github.com/loongson/build-tools/releases/download/2022.05.
 
 ENV PATH $PATH:/opt/cross-tools/bin
 ENV LD_LIBRARY_PATH /opt/cross-tools/lib:/opt/cross-tools/loongarch64-unknown-linux-gnu/lib:$LD_LIBRARY_PATH
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/docker/dockerfiles/debian-m68k-cross.docker +5 -0
index dded71c5d2..25dd1c1e68 100644
@@ -12,3 +12,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
     eatmydata apt-get install --no-install-recommends -y \
         gcc-m68k-linux-gnu \
         libc6-dev-m68k-cross
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/docker/dockerfiles/debian-mips-cross.docker +5 -0
index 7b55f0f3b2..2cbc568ed1 100644
@@ -12,3 +12,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
     eatmydata apt-get install --no-install-recommends -y \
             gcc-mips-linux-gnu \
             libc6-dev-mips-cross
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/docker/dockerfiles/debian-mips64-cross.docker +5 -0
index afcff9726f..ba965cf564 100644
@@ -12,3 +12,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
     eatmydata apt-get install --no-install-recommends -y \
         gcc-mips64-linux-gnuabi64 \
         libc6-dev-mips64-cross
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/docker/dockerfiles/debian-native.docker +5 -0
index 8dd033097c..abac7d7cd7 100644
@@ -47,3 +47,8 @@ RUN apt update && \
 
 ENV QEMU_CONFIGURE_OPTS $QEMU_CONFIGURE_OPTS
 ENV DEF_TARGET_LIST "none"
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/docker/dockerfiles/debian-powerpc-test-cross.docker +5 -1
index d6b2909cc4..23779413d3 100644
@@ -16,4 +16,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
         libc6-dev-ppc64-cross \
         gcc-10-powerpc64le-linux-gnu \
         libc6-dev-ppc64el-cross
-
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/docker/dockerfiles/debian-riscv64-cross.docker +5 -0
index 3daf93968a..803afb9573 100644
@@ -50,3 +50,8 @@ RUN apt update && \
 # Specify the cross prefix for this image (see tests/docker/common.rc)
 ENV QEMU_CONFIGURE_OPTS --cross-prefix=riscv64-linux-gnu-
 ENV DEF_TARGET_LIST riscv64-softmmu,riscv64-linux-user
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/docker/dockerfiles/debian-riscv64-test-cross.docker +5 -0
index e5f83a5aeb..6e631295bc 100644
@@ -12,3 +12,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
     eatmydata apt-get install --no-install-recommends -y \
         gcc-riscv64-linux-gnu \
         libc6-dev-riscv64-cross
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/docker/dockerfiles/debian-sh4-cross.docker +5 -0
index d48ed9065f..6bd8171d33 100644
@@ -12,3 +12,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
     eatmydata apt-get install --no-install-recommends -y \
         gcc-sh4-linux-gnu \
         libc6-dev-sh4-cross
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/docker/dockerfiles/debian-sparc64-cross.docker +5 -0
index 8d3d306bc1..1ef735f223 100644
@@ -12,3 +12,8 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
     eatmydata apt-get install --no-install-recommends -y \
         gcc-sparc64-linux-gnu \
         libc6-dev-sparc64-cross
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/docker/dockerfiles/debian-toolchain.docker +5 -0
index dc9545857f..687a97fec4 100644
@@ -34,3 +34,8 @@ RUN cd /root && ./build-toolchain.sh
 # then copying the built toolchain from stage 0.
 FROM docker.io/library/debian:11-slim
 COPY --from=0 /usr/local /usr/local
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/docker/dockerfiles/debian-tricore-cross.docker +5 -0
index 82e4576485..cfd2faf9a8 100644
@@ -41,3 +41,8 @@ RUN curl -#SL https://github.com/bkoppelmann/package_940/releases/download/trico
 # This image can only build a very minimal QEMU as well as the tests
 ENV DEF_TARGET_LIST tricore-softmmu
 ENV QEMU_CONFIGURE_OPTS --disable-user --disable-tools --disable-fdt
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/docker/dockerfiles/debian-xtensa-cross.docker +5 -0
index 2f11b3b7bc..082b50da19 100644
@@ -27,3 +27,8 @@ RUN for cpu in $CPU_LIST; do \
     done
 
 ENV PATH $PATH:/opt/$TOOLCHAIN_RELEASE/xtensa-dc232b-elf/bin:/opt/$TOOLCHAIN_RELEASE/xtensa-dc233c-elf/bin:/opt/$TOOLCHAIN_RELEASE/xtensa-de233_fpu-elf/bin:/opt/$TOOLCHAIN_RELEASE/xtensa-dsp3400-elf/bin
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/docker/dockerfiles/fedora-cris-cross.docker +5 -0
index 91c373fdd3..f2899af410 100644
@@ -6,3 +6,8 @@ FROM registry.fedoraproject.org/fedora:33
 ENV PACKAGES gcc-cris-linux-gnu
 RUN dnf install -y $PACKAGES
 RUN rpm -q $PACKAGES | sort > /packages.txt
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/docker/dockerfiles/fedora-i386-cross.docker +5 -0
index f58b64dc3e..14c1fb2c93 100644
@@ -32,3 +32,8 @@ ENV PKG_CONFIG_LIBDIR /usr/lib/pkgconfig
 
 RUN dnf update -y && dnf install -y $PACKAGES
 RUN rpm -q $PACKAGES | sort > /packages.txt
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/docker/dockerfiles/python.docker +5 -0
index 56d88417df..708ebbed75 100644
@@ -16,3 +16,8 @@ ENV PACKAGES \
 
 RUN dnf install -y $PACKAGES
 RUN rpm -q $PACKAGES | sort > /packages.txt
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
Signature · 1 line
2.39.1
Reviewed-by on v1 4/7
#10 lore raw

Re: [PATCH 4/7] tests/docker: add USER stanzas to non-lci images

Quoted 16 lines · Alex Bennée

These are flat but not generated by lcitool so we need to manually update them with the useradd stanza.

---
 tests/docker/dockerfiles/debian-all-test-cross.docker     | 5 +++++
 tests/docker/dockerfiles/debian-alpha-cross.docker        | 5 +++++
 tests/docker/dockerfiles/debian-hexagon-cross.docker      | 5 +++++
 tests/docker/dockerfiles/debian-hppa-cross.docker         | 5 +++++
 tests/docker/dockerfiles/debian-loongarch-cross.docker    | 5 +++++
 tests/docker/dockerfiles/debian-m68k-cross.docker         | 5 +++++
 tests/docker/dockerfiles/debian-mips-cross.docker         | 5 +++++
 tests/docker/dockerfiles/debian-mips64-cross.docker       | 5 +++++
 tests/docker/dockerfiles/debian-native.docker             | 5 +++++
 tests/docker/dockerfiles/debian-powerpc-test-cross.docker | 6 +++++-
 tests/docker/dockerfiles/debian-riscv64-cross.docker      | 5 +++++
Quoted 8 lines
 tests/docker/dockerfiles/debian-riscv64-test-cross.docker | 5 +++++
 tests/docker/dockerfiles/debian-sh4-cross.docker          | 5 +++++
 tests/docker/dockerfiles/debian-sparc64-cross.docker      | 5 +++++
 tests/docker/dockerfiles/debian-toolchain.docker          | 5 +++++
 tests/docker/dockerfiles/debian-tricore-cross.docker      | 5 +++++
 tests/docker/dockerfiles/debian-xtensa-cross.docker       | 5 +++++
 tests/docker/dockerfiles/fedora-cris-cross.docker         | 5 +++++
 tests/docker/dockerfiles/fedora-i386-cross.docker         | 5 +++++

Unrelated to this, but I mentioned in another thread, that we should really drop the fedora-i386 and tell lcitool to generate a debian-i386 docker file one day. There's no compelling reason for it to be an exception and use Fedora instead of Debian.

Quoted 2 lines
 tests/docker/dockerfiles/python.docker                    | 5 +++++
 20 files changed, 100 insertions(+), 1 deletion(-)

With regards,
Daniel

Signature · 3 lines
|: 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 :|
#11 lore raw

Re: [PATCH 4/7] tests/docker: add USER stanzas to non-lci images

In reply to Alex Bennée
Quoted 32 lines · Alex Bennée

These are flat but not generated by lcitool so we need to manually update them with the useradd stanza.

---
  tests/docker/dockerfiles/debian-all-test-cross.docker     | 5 +++++
  tests/docker/dockerfiles/debian-alpha-cross.docker        | 5 +++++
  tests/docker/dockerfiles/debian-hexagon-cross.docker      | 5 +++++
  tests/docker/dockerfiles/debian-hppa-cross.docker         | 5 +++++
  tests/docker/dockerfiles/debian-loongarch-cross.docker    | 5 +++++
  tests/docker/dockerfiles/debian-m68k-cross.docker         | 5 +++++
  tests/docker/dockerfiles/debian-mips-cross.docker         | 5 +++++
  tests/docker/dockerfiles/debian-mips64-cross.docker       | 5 +++++
  tests/docker/dockerfiles/debian-native.docker             | 5 +++++
  tests/docker/dockerfiles/debian-powerpc-test-cross.docker | 6 +++++-
  tests/docker/dockerfiles/debian-riscv64-cross.docker      | 5 +++++
  tests/docker/dockerfiles/debian-riscv64-test-cross.docker | 5 +++++
  tests/docker/dockerfiles/debian-sh4-cross.docker          | 5 +++++
  tests/docker/dockerfiles/debian-sparc64-cross.docker      | 5 +++++
  tests/docker/dockerfiles/debian-toolchain.docker          | 5 +++++
  tests/docker/dockerfiles/debian-tricore-cross.docker      | 5 +++++
  tests/docker/dockerfiles/debian-xtensa-cross.docker       | 5 +++++
  tests/docker/dockerfiles/fedora-cris-cross.docker         | 5 +++++
  tests/docker/dockerfiles/fedora-i386-cross.docker         | 5 +++++
  tests/docker/dockerfiles/python.docker                    | 5 +++++
  20 files changed, 100 insertions(+), 1 deletion(-)
tests/docker/dockerfiles/debian-all-test-cross.docker +0 -0
index 8dc5e1b5de..981e9bdc7b 100644

tests/docker/dockerfiles/debian-all-test-cross.docker RUN DEBIAN_FRONTEND=noninteractive eatmydata \ · line 68

Quoted 8 lines
tests/docker/dockerfiles/debian-all-test-cross.docker +5 -0
@@ -61,3 +61,8 @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \
 
  ENV QEMU_CONFIGURE_OPTS --disable-system --disable-docs --disable-tools
  ENV DEF_TARGET_LIST aarch64-linux-user,alpha-linux-user,arm-linux-user,hppa-linux-user,i386-linux-user,m68k-linux-user,mips-linux-user,mips64-linux-user,mips64el-linux-user,mipsel-linux-user,ppc-linux-user,ppc64-linux-user,ppc64le-linux-user,riscv64-linux-user,s390x-linux-user,sh4-linux-user,sparc64-linux-user
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi

Is that intended for local image building?

Personally I only use the image built by gitlab and mount the containers with -u $UID -v $HOME/.ccache -v $HOME/source/qemu. Would that still keep working, or do I have to map from gitlab user to mine?

#12 lore raw

Re: [PATCH 4/7] tests/docker: add USER stanzas to non-lci images

Quoted 43 lines · Philippe Mathieu-Daudé
Quoted 32 lines · Alex Bennée

These are flat but not generated by lcitool so we need to manually update them with the useradd stanza.

---
  tests/docker/dockerfiles/debian-all-test-cross.docker     | 5 +++++
  tests/docker/dockerfiles/debian-alpha-cross.docker        | 5 +++++
  tests/docker/dockerfiles/debian-hexagon-cross.docker      | 5 +++++
  tests/docker/dockerfiles/debian-hppa-cross.docker         | 5 +++++
  tests/docker/dockerfiles/debian-loongarch-cross.docker    | 5 +++++
  tests/docker/dockerfiles/debian-m68k-cross.docker         | 5 +++++
  tests/docker/dockerfiles/debian-mips-cross.docker         | 5 +++++
  tests/docker/dockerfiles/debian-mips64-cross.docker       | 5 +++++
  tests/docker/dockerfiles/debian-native.docker             | 5 +++++
  tests/docker/dockerfiles/debian-powerpc-test-cross.docker | 6 +++++-
  tests/docker/dockerfiles/debian-riscv64-cross.docker      | 5 +++++
  tests/docker/dockerfiles/debian-riscv64-test-cross.docker | 5 +++++
  tests/docker/dockerfiles/debian-sh4-cross.docker          | 5 +++++
  tests/docker/dockerfiles/debian-sparc64-cross.docker      | 5 +++++
  tests/docker/dockerfiles/debian-toolchain.docker          | 5 +++++
  tests/docker/dockerfiles/debian-tricore-cross.docker      | 5 +++++
  tests/docker/dockerfiles/debian-xtensa-cross.docker       | 5 +++++
  tests/docker/dockerfiles/fedora-cris-cross.docker         | 5 +++++
  tests/docker/dockerfiles/fedora-i386-cross.docker         | 5 +++++
  tests/docker/dockerfiles/python.docker                    | 5 +++++
  20 files changed, 100 insertions(+), 1 deletion(-)
tests/docker/dockerfiles/debian-all-test-cross.docker +0 -0
index 8dc5e1b5de..981e9bdc7b 100644

tests/docker/dockerfiles/debian-all-test-cross.docker RUN DEBIAN_FRONTEND=noninteractive eatmydata \ · line 67

Quoted 7 lines
tests/docker/dockerfiles/debian-all-test-cross.docker +5 -0
@@ -61,3 +61,8 @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \
  ENV QEMU_CONFIGURE_OPTS --disable-system --disable-docs --disable-tools
  ENV DEF_TARGET_LIST aarch64-linux-user,alpha-linux-user,arm-linux-user,hppa-linux-user,i386-linux-user,m68k-linux-user,mips-linux-user,mips64-linux-user,mips64el-linux-user,mipsel-linux-user,ppc-linux-user,ppc64-linux-user,ppc64le-linux-user,riscv64-linux-user,s390x-linux-user,sh4-linux-user,sparc64-linux-user
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi

Is that intended for local image building?

Quoted 3 lines

Personally I only use the image built by gitlab and mount the containers with -u $UID -v $HOME/.ccache -v $HOME/source/qemu. Would that still keep working, or do I have to map from gitlab user to mine?

The images fetched from gitlab already have this present, as the current docker.py adds it to all our containers. So this should essentially be a no functional change.

With regards,
Daniel

Signature · 3 lines
|: 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 :|
#13 lore raw

Re: [PATCH 4/7] tests/docker: add USER stanzas to non-lci images

In reply to Philippe Mathieu-Daudé
Quoted 34 lines · Philippe Mathieu-Daudé
Quoted 33 lines · Alex Bennée

These are flat but not generated by lcitool so we need to manually update them with the useradd stanza.

---
  tests/docker/dockerfiles/debian-all-test-cross.docker     | 5 +++++
  tests/docker/dockerfiles/debian-alpha-cross.docker        | 5 +++++
  tests/docker/dockerfiles/debian-hexagon-cross.docker      | 5 +++++
  tests/docker/dockerfiles/debian-hppa-cross.docker         | 5 +++++
  tests/docker/dockerfiles/debian-loongarch-cross.docker    | 5 +++++
  tests/docker/dockerfiles/debian-m68k-cross.docker         | 5 +++++
  tests/docker/dockerfiles/debian-mips-cross.docker         | 5 +++++
  tests/docker/dockerfiles/debian-mips64-cross.docker       | 5 +++++
  tests/docker/dockerfiles/debian-native.docker             | 5 +++++
  tests/docker/dockerfiles/debian-powerpc-test-cross.docker | 6 +++++-
  tests/docker/dockerfiles/debian-riscv64-cross.docker      | 5 +++++
  tests/docker/dockerfiles/debian-riscv64-test-cross.docker | 5 +++++
  tests/docker/dockerfiles/debian-sh4-cross.docker          | 5 +++++
  tests/docker/dockerfiles/debian-sparc64-cross.docker      | 5 +++++
  tests/docker/dockerfiles/debian-toolchain.docker          | 5 +++++
  tests/docker/dockerfiles/debian-tricore-cross.docker      | 5 +++++
  tests/docker/dockerfiles/debian-xtensa-cross.docker       | 5 +++++
  tests/docker/dockerfiles/fedora-cris-cross.docker         | 5 +++++
  tests/docker/dockerfiles/fedora-i386-cross.docker         | 5 +++++
  tests/docker/dockerfiles/python.docker                    | 5 +++++
  20 files changed, 100 insertions(+), 1 deletion(-)
tests/docker/dockerfiles/debian-all-test-cross.docker +0 -1
index 8dc5e1b5de..981e9bdc7b 100644
@@ -61,3 +61,8 @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \
    ENV QEMU_CONFIGURE_OPTS --disable-system --disable-docs
--disable-tools
Quoted 8 lines

tests/docker/dockerfiles/debian-all-test-cross.docker RUN DEBIAN_FRONTEND=noninteractive eatmydata \ · line 68

Quoted 6 lines
tests/docker/dockerfiles/debian-all-test-cross.docker +5 -0
  ENV DEF_TARGET_LIST aarch64-linux-user,alpha-linux-user,arm-linux-user,hppa-linux-user,i386-linux-user,m68k-linux-user,mips-linux-user,mips64-linux-user,mips64el-linux-user,mipsel-linux-user,ppc-linux-user,ppc64-linux-user,ppc64le-linux-user,riscv64-linux-user,s390x-linux-user,sh4-linux-user,sparc64-linux-user
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi

Is that intended for local image building?

For building tests. When we run the compilers inside the docker container we want to ensure the final binary is visible and accessible outside the container.

Quoted 3 lines

Personally I only use the image built by gitlab and mount the containers with -u $UID -v $HOME/.ccache -v $HOME/source/qemu. Would that still keep working, or do I have to map from gitlab user to mine?

Its only added on for local builds so in theory you should cache all the layers apart from the last one.

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#14 lore raw

Re: [PATCH 4/7] tests/docker: add USER stanzas to non-lci images

Quoted 50 lines · Alex Bennée
Quoted 34 lines · Philippe Mathieu-Daudé
Quoted 33 lines · Alex Bennée

These are flat but not generated by lcitool so we need to manually update them with the useradd stanza.

---
   tests/docker/dockerfiles/debian-all-test-cross.docker     | 5 +++++
   tests/docker/dockerfiles/debian-alpha-cross.docker        | 5 +++++
   tests/docker/dockerfiles/debian-hexagon-cross.docker      | 5 +++++
   tests/docker/dockerfiles/debian-hppa-cross.docker         | 5 +++++
   tests/docker/dockerfiles/debian-loongarch-cross.docker    | 5 +++++
   tests/docker/dockerfiles/debian-m68k-cross.docker         | 5 +++++
   tests/docker/dockerfiles/debian-mips-cross.docker         | 5 +++++
   tests/docker/dockerfiles/debian-mips64-cross.docker       | 5 +++++
   tests/docker/dockerfiles/debian-native.docker             | 5 +++++
   tests/docker/dockerfiles/debian-powerpc-test-cross.docker | 6 +++++-
   tests/docker/dockerfiles/debian-riscv64-cross.docker      | 5 +++++
   tests/docker/dockerfiles/debian-riscv64-test-cross.docker | 5 +++++
   tests/docker/dockerfiles/debian-sh4-cross.docker          | 5 +++++
   tests/docker/dockerfiles/debian-sparc64-cross.docker      | 5 +++++
   tests/docker/dockerfiles/debian-toolchain.docker          | 5 +++++
   tests/docker/dockerfiles/debian-tricore-cross.docker      | 5 +++++
   tests/docker/dockerfiles/debian-xtensa-cross.docker       | 5 +++++
   tests/docker/dockerfiles/fedora-cris-cross.docker         | 5 +++++
   tests/docker/dockerfiles/fedora-i386-cross.docker         | 5 +++++
   tests/docker/dockerfiles/python.docker                    | 5 +++++
   20 files changed, 100 insertions(+), 1 deletion(-)
tests/docker/dockerfiles/debian-all-test-cross.docker +0 -1
index 8dc5e1b5de..981e9bdc7b 100644
@@ -61,3 +61,8 @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \
     ENV QEMU_CONFIGURE_OPTS --disable-system --disable-docs
--disable-tools
Quoted 8 lines

tests/docker/dockerfiles/debian-all-test-cross.docker RUN DEBIAN_FRONTEND=noninteractive eatmydata \ · line 68

Quoted 6 lines
tests/docker/dockerfiles/debian-all-test-cross.docker +5 -0
   ENV DEF_TARGET_LIST aarch64-linux-user,alpha-linux-user,arm-linux-user,hppa-linux-user,i386-linux-user,m68k-linux-user,mips-linux-user,mips64-linux-user,mips64el-linux-user,mipsel-linux-user,ppc-linux-user,ppc64-linux-user,ppc64le-linux-user,riscv64-linux-user,s390x-linux-user,sh4-linux-user,sparc64-linux-user
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then \
+  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi

Is that intended for local image building?

For building tests. When we run the compilers inside the docker container we want to ensure the final binary is visible and accessible outside the container.

Quoted 6 lines
Quoted 3 lines

Personally I only use the image built by gitlab and mount the containers with -u $UID -v $HOME/.ccache -v $HOME/source/qemu. Would that still keep working, or do I have to map from gitlab user to mine?

Its only added on for local builds so in theory you should cache all the layers apart from the last one.

OK.

#15 lore raw

PATCH 5/7 tests/docker: use direct RUNC call to build containers

In reply to Alex Bennée

We don't really need stuff from docker.py to do the build as we have everything we need with a direct call. We do rely on the dockerfiles being able to tweak the UID/name mapping as the last step.

---
 tests/docker/Makefile.include | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
tests/docker/Makefile.include +13 -9
index bfb0dcac21..9e73ff5cf3 100644
@@ -7,6 +7,8 @@ SPACE := $(NULL) #
 COMMA := ,
 
 HOST_ARCH = $(if $(ARCH),$(ARCH),$(shell uname -m))
+USER = $(if $(NOUSER),,$(shell id -un))
+UID = $(if $(NOUSER),,$(shell id -u))
 
 DOCKER_FILES_DIR := $(SRC_PATH)/tests/docker/dockerfiles
 ifeq ($(HOST_ARCH),x86_64)
@@ -14,6 +16,7 @@ DOCKER_DEFAULT_REGISTRY := registry.gitlab.com/qemu-project/qemu
 endif
 DOCKER_REGISTRY := $(if $(REGISTRY),$(REGISTRY),$(DOCKER_DEFAULT_REGISTRY))
 
+RUNC ?= docker
 ENGINE ?= auto
 DOCKER_SCRIPT=$(SRC_PATH)/tests/docker/docker.py --engine $(ENGINE)
 
@@ -35,15 +38,16 @@ docker-qemu-src: $(DOCKER_SRC_COPY)
 
 # General rule for building docker images.
 docker-image-%: $(DOCKER_FILES_DIR)/%.docker
-	$(call quiet-command,\
-		$(DOCKER_SCRIPT) build -t qemu/$* -f $< \
-		$(if $V,,--quiet) \
-		$(if $(NOCACHE),--no-cache, \
-			$(if $(DOCKER_REGISTRY),--registry $(DOCKER_REGISTRY))) \
-		$(if $(NOUSER),,--add-current-user) \
-		$(if $(EXTRA_FILES),--extra-files $(EXTRA_FILES))\
-		$(if $(EXECUTABLE),--include-executable=$(EXECUTABLE)),\
-		"BUILD","$*")
+	  $(call quiet-command,			\
+		$(RUNC) build				\
+		$(if $V,,--quiet)			\
+		$(if $(NOCACHE),--no-cache,		\
+			$(if $(DOCKER_REGISTRY),--cache-from $(DOCKER_REGISTRY)/qemu/$*)) \
+		$(if $(NOUSER),,			\
+			--build-arg USER=$(USER)	\
+			--build-arg UID=$(UID))	\
+		-t qemu/$* - < $<, 			\
+		"BUILD", $1)
 
 # Special rule for debootstraped binfmt linux-user images
 docker-binfmt-image-debian-%: $(DOCKER_FILES_DIR)/debian-bootstrap.docker
Signature · 1 line
2.39.1
Reviewed-by on v1 5/7
#16 lore raw

Re: [PATCH 5/7] tests/docker: use direct RUNC call to build containers

Quoted 8 lines · Alex Bennée

We don't really need stuff from docker.py to do the build as we have everything we need with a direct call. We do rely on the dockerfiles being able to tweak the UID/name mapping as the last step.

---
 tests/docker/Makefile.include | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

With regards,
Daniel

Signature · 3 lines
|: 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 :|
Reviewed-by on v1 5/7
#17 lore raw

Re: [PATCH 5/7] tests/docker: use direct RUNC call to build containers

In reply to Alex Bennée
Quoted 8 lines · Alex Bennée

We don't really need stuff from docker.py to do the build as we have everything we need with a direct call. We do rely on the dockerfiles being able to tweak the UID/name mapping as the last step.

---
  tests/docker/Makefile.include | 22 +++++++++++++---------
  1 file changed, 13 insertions(+), 9 deletions(-)
#18 lore raw

PATCH 6/7 tests/docker: use direct RUNC call to run test jobs

In reply to Alex Bennée

If we build them without the script we can certainly run them without it.

---
 tests/docker/Makefile.include | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tests/docker/Makefile.include +3 -2
index 9e73ff5cf3..cee1b34703 100644
@@ -223,8 +223,9 @@ docker-run: docker-qemu-src
 			$(IMAGE) --executable $(EXECUTABLE),		\
 			"  COPYING $(EXECUTABLE) to $(IMAGE)"))
 	$(call quiet-command,						\
-		$(DOCKER_SCRIPT) run 					\
-			$(if $(NOUSER),,--run-as-current-user) 		\
+		$(RUNC) run 						\
+			--rm						\
+			$(if $(NOUSER),,-u $(UID)) 			\
 			--security-opt seccomp=unconfined		\
 			$(if $(DEBUG),-ti,)				\
 			$(if $(NETWORK),$(if $(subst $(NETWORK),,1),--net=$(NETWORK)),--net=none) \
Signature · 1 line
2.39.1
Reviewed-by on v1 6/7
#19 lore raw

Re: [PATCH 6/7] tests/docker: use direct RUNC call to run test jobs

Quoted 7 lines · Alex Bennée

If we build them without the script we can certainly run them without it.

---
 tests/docker/Makefile.include | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

With regards,
Daniel

Signature · 3 lines
|: 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 :|
#20 lore raw

PATCH 7/7 tests/gitlab: use kaniko to build images

In reply to Alex Bennée

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.

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.

---
 .gitlab-ci.d/container-template.yml | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)
.gitlab-ci.d/container-template.yml +9 -14
index c434b9c8f3..c2d7950df8 100644
@@ -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}"
Signature · 1 line
2.39.1
#21 lore raw

Re: [PATCH 7/7] tests/gitlab: use kaniko to build images

Quoted 4 lines · Alex Bennée

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.

Quoted 38 lines

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.

---
 .gitlab-ci.d/container-template.yml | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)
.gitlab-ci.d/container-template.yml +4 -9
index c434b9c8f3..c2d7950df8 100644
@@ -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"

.gitlab-ci.d/container-template.yml line 17

Quoted 10 lines
.gitlab-ci.d/container-template.yml +5 -5
-          -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

Signature · 3 lines
|: 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 :|
#22 lore raw
In reply to Alex Bennée
Quoted 8 lines · Alex Bennée

This series attempts to remove our dependence on the docker.py script and build things directly with the appropriate tool. I've been noodling around with how we build images on gitlab to see if they can cache better because the normal case should be we don't need to rebuild everything if the upstream distro hasn't updated its package list.

Anyway what do people think?

Removing dind limitation is interesting.

Unrelated, can we tag registry.gitlab.com/qemu-project's docker images along with releases?

#23 lore raw
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Alex Bennée

This series attempts to remove our dependence on the docker.py script and build things directly with the appropriate tool. I've been noodling around with how we build images on gitlab to see if they can cache better because the normal case should be we don't need to rebuild everything if the upstream distro hasn't updated its package list.

Quoted 6 lines
Quoted 1 line

Anyway what do people think?

Removing dind limitation is interesting.

Unrelated, can we tag registry.gitlab.com/qemu-project's docker images along with releases?

Can you elaborate on this ?

We're only using the images for CI purposes and they must always reflect the current state of git master. We're using a fixed docker tag 'latest', as that avoids the container registry growing arbitrarily large.

Our CI rules should prevent the pipelines running on stable branches, so we shouldn't need container tags for stable.

With regards,
Daniel

Signature · 3 lines
|: 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 :|
#24 lore raw
Quoted 16 lines · Daniel P. Berrangé
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Alex Bennée

This series attempts to remove our dependence on the docker.py script and build things directly with the appropriate tool. I've been noodling around with how we build images on gitlab to see if they can cache better because the normal case should be we don't need to rebuild everything if the upstream distro hasn't updated its package list.

Quoted 6 lines
Quoted 1 line

Anyway what do people think?

Removing dind limitation is interesting.

Unrelated, can we tag registry.gitlab.com/qemu-project's docker images along with releases?

Quoted 8 lines

Can you elaborate on this ?

We're only using the images for CI purposes and they must always reflect the current state of git master. We're using a fixed docker tag 'latest', as that avoids the container registry growing arbitrarily large.

Our CI rules should prevent the pipelines running on stable branches, so we shouldn't need container tags for stable.

I'm not suggesting keeping jobs to build, but doing a snapshot of the released containers.

I.e. when we release 8.0, we should tag qemu/fedora:v8.0 and never touch it again. This is useful when bisecting pre-v8, but also to build pre-v8 and do performance comparison. One shouldn't have to upgrade such container (in particular when package mirror disappear), since it already contains all we need.

Personally I'd like to keep generic and problematic ones:
- qemu/fedora
- qemu/fedora-win64-cross
- qemu/debian-xtensa-cross

#25 lore raw
Quoted 26 lines · Philippe Mathieu-Daudé
Quoted 16 lines · Daniel P. Berrangé
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Alex Bennée

This series attempts to remove our dependence on the docker.py script and build things directly with the appropriate tool. I've been noodling around with how we build images on gitlab to see if they can cache better because the normal case should be we don't need to rebuild everything if the upstream distro hasn't updated its package list.

Quoted 6 lines
Quoted 1 line

Anyway what do people think?

Removing dind limitation is interesting.

Unrelated, can we tag registry.gitlab.com/qemu-project's docker images along with releases?

Quoted 8 lines

Can you elaborate on this ?

We're only using the images for CI purposes and they must always reflect the current state of git master. We're using a fixed docker tag 'latest', as that avoids the container registry growing arbitrarily large.

Our CI rules should prevent the pipelines running on stable branches, so we shouldn't need container tags for stable.

Quoted 8 lines

I'm not suggesting keeping jobs to build, but doing a snapshot of the released containers.

I.e. when we release 8.0, we should tag qemu/fedora:v8.0 and never touch it again. This is useful when bisecting pre-v8, but also to build pre-v8 and do performance comparison. One shouldn't have to upgrade such container (in particular when package mirror disappear), since it already contains all we need.

The main risk with this is the impact on our storage quota. With the OSS Program membership IIUC we get Ultimate level features which is 250 GB of storage, across git repos, pipeline cache/artifacts/logs, container registry.

Currently they have no way to enforce that since their accounting of usage is not accurate enough. They're working on fixing that so at somepoint we'll be subject to the 250 GB limit.

What I don't know is how much storage we're currently using across the /qemu-project namespace, and what extra is implied by taking a snapshot of our container registry 3 times a year. I'm expecting it to probably be in the high 10's of GB though for the container registry.

With regards,
Daniel

Signature · 3 lines
|: 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 :|
#26 lore raw
Quoted 45 lines · Daniel P. Berrangé
Quoted 26 lines · Philippe Mathieu-Daudé
Quoted 16 lines · Daniel P. Berrangé
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Alex Bennée

This series attempts to remove our dependence on the docker.py script and build things directly with the appropriate tool. I've been noodling around with how we build images on gitlab to see if they can cache better because the normal case should be we don't need to rebuild everything if the upstream distro hasn't updated its package list.

Quoted 6 lines
Quoted 1 line

Anyway what do people think?

Removing dind limitation is interesting.

Unrelated, can we tag registry.gitlab.com/qemu-project's docker images along with releases?

Quoted 8 lines

Can you elaborate on this ?

We're only using the images for CI purposes and they must always reflect the current state of git master. We're using a fixed docker tag 'latest', as that avoids the container registry growing arbitrarily large.

Our CI rules should prevent the pipelines running on stable branches, so we shouldn't need container tags for stable.

Quoted 8 lines

I'm not suggesting keeping jobs to build, but doing a snapshot of the released containers.

I.e. when we release 8.0, we should tag qemu/fedora:v8.0 and never touch it again. This is useful when bisecting pre-v8, but also to build pre-v8 and do performance comparison. One shouldn't have to upgrade such container (in particular when package mirror disappear), since it already contains all we need.

The main risk with this is the impact on our storage quota. With the OSS Program membership IIUC we get Ultimate level features which is 250 GB of storage, across git repos, pipeline cache/artifacts/logs, container registry.

Currently they have no way to enforce that since their accounting of usage is not accurate enough. They're working on fixing that so at somepoint we'll be subject to the 250 GB limit.

Quoted 5 lines

What I don't know is how much storage we're currently using across the /qemu-project namespace, and what extra is implied by taking a snapshot of our container registry 3 times a year. I'm expecting it to probably be in the high 10's of GB though for the container registry.

Currently we are using:

86.6 Gb of artefacts
28.5 Gb of containers
220 Mb of file uploads
24.8Mb of git repo

We could probably cut down a lot of usage of artefacts by either not building full fat ones with debug symbols and passing between layers or tweaking the build system to prevent re-building of object files if the final binary is present in the file system.

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#27 lore raw
Quoted 48 lines · Alex Bennée
Quoted 45 lines · Daniel P. Berrangé
Quoted 26 lines · Philippe Mathieu-Daudé
Quoted 16 lines · Daniel P. Berrangé
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Alex Bennée

This series attempts to remove our dependence on the docker.py script and build things directly with the appropriate tool. I've been noodling around with how we build images on gitlab to see if they can cache better because the normal case should be we don't need to rebuild everything if the upstream distro hasn't updated its package list.

Quoted 6 lines
Quoted 1 line

Anyway what do people think?

Removing dind limitation is interesting.

Unrelated, can we tag registry.gitlab.com/qemu-project's docker images along with releases?

Quoted 8 lines

Can you elaborate on this ?

We're only using the images for CI purposes and they must always reflect the current state of git master. We're using a fixed docker tag 'latest', as that avoids the container registry growing arbitrarily large.

Our CI rules should prevent the pipelines running on stable branches, so we shouldn't need container tags for stable.

Quoted 8 lines

I'm not suggesting keeping jobs to build, but doing a snapshot of the released containers.

I.e. when we release 8.0, we should tag qemu/fedora:v8.0 and never touch it again. This is useful when bisecting pre-v8, but also to build pre-v8 and do performance comparison. One shouldn't have to upgrade such container (in particular when package mirror disappear), since it already contains all we need.

The main risk with this is the impact on our storage quota. With the OSS Program membership IIUC we get Ultimate level features which is 250 GB of storage, across git repos, pipeline cache/artifacts/logs, container registry.

Currently they have no way to enforce that since their accounting of usage is not accurate enough. They're working on fixing that so at somepoint we'll be subject to the 250 GB limit.

Quoted 5 lines
Quoted 5 lines

What I don't know is how much storage we're currently using across the /qemu-project namespace, and what extra is implied by taking a snapshot of our container registry 3 times a year. I'm expecting it to probably be in the high 10's of GB though for the container registry.

Maybe we can keep (a subset of) the stable release container images and store them on a registry outside of gitlab. That would be nice, but if I'm the only one interested and nobody felt this was useful before, no need to spend more energy on this topic.

Quoted 3 lines

Currently we are using:

86.6 Gb of artefacts

^ transient

Quoted 1 line

28.5 Gb of containers

^ constant

Quoted 8 lines

220 Mb of file uploads
24.8Mb of git repo

We could probably cut down a lot of usage of artefacts by either not building full fat ones with debug symbols and passing between layers or tweaking the build system to prevent re-building of object files if the final binary is present in the file system.