├── 16.04 └── Dockerfile ├── 18.04 └── Dockerfile ├── LICENSE ├── README.md ├── build.sh └── run-shell.sh /16.04/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2019-2021, Burkhard Stubert (DBA Embedded Use) 2 | 3 | # The parent directory contains two helper scripts to build and run the Docker image. 4 | # 5 | # The script 6 | # build.sh 7 | # builds a Docker image with the name "dr-yocto" and the tag "" ("dr-yocto:", for 8 | # short) from the Dockerfile found in . If you are in the parent directory of this 9 | # file, you can call 10 | # ./build.sh 16.04 ./16.04 11 | # to build the image "dr-yocto:16.04". 12 | # 13 | # The script 14 | # run-shell.sh 15 | # runs the Docker image "dr-yocto:" just built. For example, 16 | # run-shell.sh 16.04 17 | # runs the Docker image "dr-yocto:16.04". 18 | # 19 | # Note that you can use any string for . It need not be the name of a Ubuntu version. 20 | 21 | # Use Ubuntu 16.04 LTS as the basis for the Docker image. 22 | FROM ubuntu:16.04 23 | 24 | # Install all Linux packages required for Yocto builds as given in section "Build Host Packages" 25 | # on https://www.yoctoproject.org/docs/3.0.2/brief-yoctoprojectqs/brief-yoctoprojectqs.html. 26 | # Without DEBIAN_FRONTEND=noninteractive, the image build hangs indefinitely 27 | # at "Configuring tzdata". Even if you answer the question about the time zone, it will 28 | # not proceed. 29 | RUN apt-get update 30 | RUN DEBIAN_FRONTEND=noninteractive apt-get -y install \ 31 | gawk wget git-core diffstat unzip texinfo gcc-multilib \ 32 | build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \ 33 | xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev \ 34 | pylint3 xterm 35 | 36 | # These packages are not needed for the Yocto build but in this file below. 37 | RUN DEBIAN_FRONTEND=noninteractive apt-get -y install \ 38 | locales sudo 39 | 40 | # By default, Ubuntu uses dash as an alias for sh. Dash does not support the source command 41 | # needed for setting up Yocto build environments. Use bash as an alias for sh. 42 | RUN which dash &> /dev/null && (\ 43 | echo "dash dash/sh boolean false" | debconf-set-selections && \ 44 | DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash) || \ 45 | echo "Skipping dash reconfigure (not applicable)" 46 | 47 | # Install the repo tool to handle git submodules (meta layers) comfortably. 48 | ADD https://storage.googleapis.com/git-repo-downloads/repo /usr/local/bin/ 49 | RUN chmod 755 /usr/local/bin/repo 50 | 51 | # Set the locale to en_US.UTF-8, because the Yocto build fails without any locale set. 52 | RUN locale-gen en_US.UTF-8 && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 53 | ENV LANG en_US.UTF-8 54 | ENV LC_ALL en_US.UTF-8 55 | 56 | # Add user "embeddeduse" to sudoers. Then, the user can install Linux packages in the container. 57 | ENV USER_NAME embeddeduse 58 | RUN echo "${USER_NAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${USER_NAME} && \ 59 | chmod 0440 /etc/sudoers.d/${USER_NAME} 60 | 61 | # The running container writes all the build artefacts to a host directory (outside the container). 62 | # The container can only write files to host directories, if it uses the same user ID and 63 | # group ID owning the host directories. The host_uid and group_uid are passed to the docker build 64 | # command with the --build-arg option. By default, they are both 1001. The docker image creates 65 | # a group with host_gid and a user with host_uid and adds the user to the group. The symbolic 66 | # name of the group and user is embeddeduse. 67 | ARG host_uid=1001 68 | ARG host_gid=1001 69 | RUN groupadd -g $host_gid $USER_NAME && useradd -g $host_gid -m -s /bin/bash -u $host_uid $USER_NAME 70 | 71 | # Perform the Yocto build as user embeddeduse (not as root). 72 | # By default, docker runs as root. However, Yocto builds should not be run as root, but as a 73 | # normal user. Hence, we switch to the newly created user embeddeduse. 74 | USER $USER_NAME 75 | 76 | WORKDIR /Work 77 | 78 | 79 | -------------------------------------------------------------------------------- /18.04/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2019-2020, Burkhard Stubert (DBA Embedded Use) 2 | 3 | # The parent directory contains two helper scripts to build and run the Docker image. 4 | # 5 | # The script 6 | # build.sh 7 | # builds a Docker image with the name "dr-yocto" and the tag "" ("dr-yocto:", for 8 | # short) from the Dockerfile found in . If you are in the parent directory of this 9 | # file, you can call 10 | # ./build.sh 18.04 ./18.04 11 | # to build the image "dr-yocto:18.04". 12 | # 13 | # The script 14 | # run-shell.sh 15 | # runs the Docker image "dr-yocto:" just built. For example, 16 | # run-shell.sh 18.04 17 | # runs the Docker image "dr-yocto:18.04". 18 | # 19 | # Note that you can use any string for . It need not be the name of a Ubuntu version. 20 | 21 | # Use Ubuntu 18.04 LTS (Bionic Beaver) as the basis for the Docker image. 22 | FROM ubuntu:18.04 23 | 24 | # Install all Linux packages required for Yocto builds as given in section "Build Host Packages" 25 | # on https://www.yoctoproject.org/docs/3.0.2/brief-yoctoprojectqs/brief-yoctoprojectqs.html. 26 | # I added the package git-lfs, which I found missing during a Yocto build. 27 | # Without DEBIAN_FRONTEND=noninteractive, the image build hangs indefinitely 28 | # at "Configuring tzdata". Even if you answer the question about the time zone, it will 29 | # not proceed. 30 | RUN apt-get update 31 | RUN DEBIAN_FRONTEND=noninteractive apt-get -y install \ 32 | gawk wget git-core diffstat unzip texinfo gcc-multilib \ 33 | build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \ 34 | xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev \ 35 | pylint3 xterm git-lfs 36 | 37 | # These packages are not needed for the Yocto build but in this file below. 38 | RUN DEBIAN_FRONTEND=noninteractive apt-get -y install \ 39 | locales sudo 40 | 41 | # By default, Ubuntu uses dash as an alias for sh. Dash does not support the source command 42 | # needed for setting up Yocto build environments. Use bash as an alias for sh. 43 | RUN which dash &> /dev/null && (\ 44 | echo "dash dash/sh boolean false" | debconf-set-selections && \ 45 | DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash) || \ 46 | echo "Skipping dash reconfigure (not applicable)" 47 | 48 | # Install the repo tool to handle git submodules (meta layers) comfortably. 49 | ADD https://storage.googleapis.com/git-repo-downloads/repo /usr/local/bin/ 50 | RUN chmod 755 /usr/local/bin/repo 51 | 52 | # Set the locale to en_US.UTF-8, because the Yocto build fails without any locale set. 53 | RUN locale-gen en_US.UTF-8 && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 54 | ENV LANG en_US.UTF-8 55 | ENV LC_ALL en_US.UTF-8 56 | 57 | # Add user "embeddeduse" to sudoers. Then, the user can install Linux packages in the container. 58 | ENV USER_NAME embeddeduse 59 | RUN echo "${USER_NAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${USER_NAME} && \ 60 | chmod 0440 /etc/sudoers.d/${USER_NAME} 61 | 62 | # The running container writes all the build artefacts to a host directory (outside the container). 63 | # The container can only write files to host directories, if it uses the same user ID and 64 | # group ID owning the host directories. The host_uid and group_uid are passed to the docker build 65 | # command with the --build-arg option. By default, they are both 1001. The docker image creates 66 | # a group with host_gid and a user with host_uid and adds the user to the group. The symbolic 67 | # name of the group and user is embeddeduse. 68 | ARG host_uid=1001 69 | ARG host_gid=1001 70 | RUN groupadd -g $host_gid $USER_NAME && useradd -g $host_gid -m -s /bin/bash -u $host_uid $USER_NAME 71 | 72 | # Perform the Yocto build as user embeddeduse (not as root). 73 | # By default, docker runs as root. However, Yocto builds should not be run as root, but as a 74 | # normal user. Hence, we switch to the newly created user embeddeduse. 75 | USER $USER_NAME 76 | 77 | WORKDIR /public/Work 78 | 79 | 80 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Burkhard Stubert 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker container for Yocto builds 2 | 3 | The script `build.sh` creates a Docker image, in which you can run a Yocto build. Calling 4 | 5 | build.sh 6 | 7 | builds the Docker image "dr-yocto:\" from the `Dockerfile` located in ``. 8 | This project provides a Dockerfile based on Ubuntu 18.04 in the subdirectory `./18.04`. 9 | Ubuntu 18.04 LTS is suited to build Yocto Thud, Warrior, Zeus and most likely Dunfell. 10 | You can build the Docker image with the command `build.sh 18.04 ./18.04` from the base 11 | directory of the repository. 12 | 13 | The script `run-shell.sh` runs the Docker image built before interactively. The syntax is 14 | 15 | run.sh 16 | 17 | For example, `run.sh 18.04` runs the Docker image `dr-yocto:18.04` and starts a shell. 18 | 19 | 20 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # argument 1: Ubuntu version (e.g. 18.04) used as container tag 4 | # argument 2: path to Dockerfile 5 | 6 | docker build --build-arg "host_uid=$(id -u)" --build-arg "host_gid=$(id -g)" --tag "dr-yocto:$1" $2 7 | 8 | -------------------------------------------------------------------------------- /run-shell.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # argument 1: Ubuntu version used as container tag 4 | 5 | docker run -it --rm -v $PWD:/public/Work dr-yocto:$1 6 | 7 | --------------------------------------------------------------------------------