commit d64c9e41b1fcff5f21812dd358a509cabe6170d3 Author: Thomas Klaehn Date: Thu Nov 16 09:12:46 2017 +0100 Yocto build container: initial commit Signed-off-by: Thomas Klaehn diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c430624 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM debian:jessie + +MAINTAINER Thomas Klaehn + +RUN apt-get update && \ + apt-get install -yq sudo build-essential git python python3 man bash diffstat \ + gawk chrpath wget cpio texinfo lzop apt-utils bc screen libncurses5-dev \ + locales libc6-dev-i386 doxygen libssl-dev dos2unix unzip gcc-multilib socat \ + python3-pip python3-pexpect xz-utils debianutils iputils-ping libsdl1.2-dev \ + xterm p7zip-full && \ + rm -rf /var/lib/apt-lists/* && \ + echo "dash dash/sh boolean false" | debconf-set-selections && \ + DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash && \ + dpkg --add-architecture i386 && \ + apt-get update && \ + apt-get -yq install g++-multilib libusb-1.0-0-dev:i386 + +RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen + +ENV LANG en_US.utf8 + +RUN mkdir -p /var/build + +WORKDIR /var/build + +ADD init.sh /usr/local/bin/init.sh + +ENTRYPOINT ["/usr/local/bin/init.sh"] + diff --git a/init.sh b/init.sh new file mode 100755 index 0000000..e30e59f --- /dev/null +++ b/init.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +username=builduser +usergroup=buildgroup +builddir=/var/build +homedir=/home/${username} +sshdir=${homedir}/.ssh + +# figure out the uid/gid we need to use by integrating the path that has +# been bind mounted in. this is then used for the builduser. +BUILD_UID=$(stat --printf=%u ${builddir} 2> /dev/null) +BUILD_GID=$(stat --printf=%g ${builddir} 2> /dev/null) + +# create a group +groupadd --gid ${BUILD_GID} --non-unique ${usergroup} + +# add user +useradd -s /bin/bash --home ${homedir} --non-unique --uid ${BUILD_UID} \ + --gid ${BUILD_GID} --groups sudo ${username} + +# give users in the sudo group sudo access in the container +echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +# copy ssh key files +mkdir -p ${homedir} +mkdir -p ${sshdir} +cp /var/ssh/* ${sshdir}/ +chown -R ${username}:${usergroup} ${homedir} + +exec "$@" +