Using Docker for OpenEmbedded builds

While updating the E300 file system build the "jethro" (Yocto Project release branches from Nov 2015), I found the build failed on a Fedora 25 machine. The host gccc is version 6.0 and the older recipes fail to build with that.

In the past, I've used virtual machines to deploy older Fedora releases to work around these problems, but this time I wanted to try Docker.

First, I should mention work by Cliff Brake at BEC Systems and the CROPS team at Intel. Thsese are good places for ideas how my work can be improved.

Second, I do not know what I am doing. Please drop me an email with improvements for this guide.

So lets get started by creating a directory oe-jethro containing a file called Dockerfile with the following text:

FROM fedora:22
MAINTAINER Philip Balister <philip@balister.org>

RUN dnf --setopt=deltarpm=0 -y update
RUN dnf --setopt=deltarpm=0 -y install gawk make wget tar bzip2 gzip \
    cpio file findutils python unzip perl patch which \
    diffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfo chrpath \
    ccache perl-Data-Dumper perl-Text-ParseWords perl-Thread-Queue SDL-devel \
    xterm sudo xz
RUN curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > repo
RUN chmod a+x repo
RUN mv repo /usr/local/bin
RUN useradd -ms /bin/bash -p foobar build -G wheel -u 1000

USER build
WORKDIR /home/build

The -u argument should match your user id on the machine you are using so you can easily use files from your home directory.

Now buld an image from your Dockerfile:

sudo docker build  -t="oe-jethro:22" .

The sudo is likely distro dependent.

Now we can run the image and get a prompt:

sudo docker run -i -t --rm -v $(pwd):$(pwd):z  oe-jethro:22 /bin/bash

then do this and you should be in the directory with the Dockerfile:

$ cd ../your-username

At this point, you should be able to build an image from my instructions. Skip step 1, the Dockerfile is setup to install repo for you.