PYNQ v2.7.0 image build in Docker

Hi there,

In an older post it was mentioned that the PYNQ team “use containers inside [their] Jenkins flows for automated building of SD Card images” so I thought I would try to do the same.

Previously I ported the PYNQ v2.7.0 image to a custom Zynq US+ building inside an Ubuntu 18.04 VM created using the provided Vagrant file. Now I am trying to move the build process inside a Docker image where I mount my local AMD Xilinx 2020.2 tools.

I can build Overlays inside Docker, however, when I try to build the PYNQ image I get this error when installing XRT:

+ '[' -e /workspace/PYNQ/sdbuild/packages/xrt/qemu.sh ']'
+ cp /workspace/PYNQ/sdbuild/packages/xrt/qemu.sh /workspace/PYNQ/sdbuild/build/focal.ADM-XRC-9Z1
+ sudo -E chroot /workspace/PYNQ/sdbuild/build/focal.ADM-XRC-9Z1 bash qemu.sh
chroot: failed to run command ‘bash’: Exec format error

This is the content of my Dockerfile to build the Image on Jenkins. It is inspired by this pull request for PYNQ 3.0.1, downgraded to Ubuntu 18.04.6 LTS for PYNQ 2.7.0.

FROM docker.io/ubuntu:18.04

USER root

RUN dpkg --add-architecture i386
RUN apt update && apt upgrade -y --force-yes && \
    DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y \
    software-properties-common lsb-core cmake wget sudo git \
    subversion locales cpio nano \
    libxtst6 libx11-6 libtinfo-dev libxrender-dev libfreetype6 libxi6 \
    libncurses5  xterm \
    libncurses5-dev libncursesw5-dev \
    autoconf libtool \
    texinfo gcc-multilib

# Setup host for PYNQ - using file from master branch to get updates for old links
WORKDIR /tmp/work
RUN wget https://raw.githubusercontent.com/Xilinx/PYNQ/refs/heads/master/sdbuild/scripts/setup_host.sh
RUN chmod +x setup_host.sh
RUN bash -c "source /tmp/work/setup_host.sh"
RUN rm -r /tmp/work/*

ENV PATH /opt/qemu/bin:/opt/crosstool-ng/bin:$PATH

RUN echo "dash dash/sh boolean false" | debconf-set-selections
RUN DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash

WORKDIR /workspace

# Preload libudev for Vivado when running in Docker
ENV LD_PRELOAD /lib/x86_64-linux-gnu/libudev.so.1:$LD_PRELOAD

# Extra config for petalinux
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

RUN groupadd -g 1001 jenkins
RUN useradd -u 1001 -g 1001 -ms /bin/bash jenkins
RUN usermod -aG sudo jenkins
RUN echo '%jenkins ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN chown jenkins:jenkins /workspace
USER jenkins

Has anyone encountered this issue or know what could be the cause of this?

Any help would be highly appreciated!

Many thanks,
Mario