Flint Weller
Published © Apache-2.0

Using Docker for Building NXP i. MX 8M Plus Yocto Project

Design a DockerFile for building a Docker Image that can build Yocto Project.

IntermediateFull instructions provided1 hour355
Using Docker for Building NXP i. MX 8M Plus Yocto Project

Story

Read more

Code

dockerfile-yocto18

Dockerfile
This is a DockerFile for building an Ubuntu image that can build Yocto Project
# dockerfile-yocto18
# Building NXP i.MX Yocto Project on Ubuntu 18.04 LTS "Bionic"

# INSTRUCTIONS
# Create Docker image from this dockerfile
# $ docker build --file ~/.dockerfile/dockerfile-yocto18 --tag yocto18 .
# Deploy a container with the working directory mounted
# SYNTAX: docker run -dit -P --name DockerContainerName -v WorkstationDirectory:DockerDirectory DockerImageName
# EXAMPLES:
# $ docker run -dit -P --name imx8-zeus -v /work/docker/zeus:/home/build/docker yocto18
# $ docker run -dit -P --name imx8-gatesgarth -v /work/docker/gatesgarth:/home/build/docker yocto18

# Ubuntu LTS release version numbers with code names
# Ubuntu 20.04 LTS = Focal Fossa
# Ubuntu 18.04 LTS = Bionic Beaver
# Ubuntu 16.04 LTS = Xenial Xerus
# Ubuntu 14.04 LTS = Trusty Tahr

# Specify Ubuntu digest to pull from
FROM ubuntu:bionic

# Install dependencies
RUN apt update && apt upgrade -y
# Handle the tzdata prompt
RUN ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
RUN DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends tzdata
# Put everything we want to install here
RUN apt install -y gawk wget git-core diffstat unzip texinfo \
gcc-multilib build-essential chrpath socat cpio python \
python3 python3-pip python3-pexpect xz-utils debianutils \
iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev \
pylint3 xterm rsync curl locales apt-utils sudo vim bash-completion screen
# Clean up
RUN apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Replace dash with bash (Ubuntu uses dash as /bin/sh for system shells)
# https://wiki.ubuntu.com/DashAsBinSh
# Note that using && below to chain commands is essential to avoid failure
RUN rm /bin/sh && ln -s bash /bin/sh

# Install repo utility
RUN curl -o /usr/local/bin/repo https://storage.googleapis.com/git-repo-downloads/repo 
RUN chmod a+x /usr/local/bin/repo

# Set up locales
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8

# Create user called build (because we can not run Yocto Project as root)
# Change uid and gid, to match my account on my workstation
# Username is not all that important
ENV UID=1000
ENV GID=1000
ENV USER=build
RUN groupadd -g $GID $USER && \
useradd -u $UID -g $GID -ms /bin/bash $USER && \
usermod -a -G sudo $USER && \
usermod -a -G users $USER 

# Change username and work directory
USER $USER
WORKDIR /home/$USER

# Create the docker directory
RUN mkdir /home/$USER/docker

# Configure git
RUN git config --global user.name "Flint Weller"
RUN git config --global user.email "flint.weller@hackster.io"

Credits

Flint Weller
24 projects • 22 followers
NXP Dedicated Applications Processor FAE

Comments