Yocto is another tool that has particular dependencies that are likely to be different to whatever is on your system. It’s also something you probably want to duplicate on every computer building the same project.

This is my Yocto dockerfile based on the current getting started documentation:

FROM debian:10

RUN dpkg --add-architecture i386 \
  && DEBIAN_FRONTEND=noninteractive apt-get update -y -q \
  && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y -q \
  && DEBIAN_FRONTEND=noninteractive apt-get install -y -q \
    gawk \
    wget \
    git \
    diffstat \
    unzip \
    texinfo \
    gcc \
    build-essential \
    chrpath \
    socat \
    cpio \
    python3 \
    python3-pip \
    python3-pexpect \
    xz-utils \
    debianutils \
    iputils-ping \
    python3-git \
    python3-jinja2 \
    libegl1-mesa \
    libsdl1.2-dev \
    pylint3 \
    xterm \
    python3-subunit \
    mesa-common-dev \
  && sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \
  && locale-gen

ENV LANG=en_US.UTF-8
ENV LANGUAGE en_US:en

COPY entrypoint.sh /opt/entrypoint.sh

WORKDIR /yocto
VOLUME /yocto

ENTRYPOINT [ "/opt/entrypoint.sh" ]

Before running Bitbake you need to source the ‘oe-init-build-env’ script in the poky directory. I do this from entrypoint.sh like so:

#!/bin/bash

. /yocto/poky/oe-init-build-env build

exec "[email protected]"

A command for building a target looks like this:

docker run -ti --rm --user 1000:1000 -v $(pwd):/yocto:cached my-yocto bitbake core-image-minimal