Yocto build container: Usage as docker cloud container

Signed-off-by: Thomas Klaehn <tkl@blackfinn.de>
This commit is contained in:
Thomas Klaehn 2019-02-24 09:06:20 +01:00
parent 8095bd2e6e
commit 19126870d1
3 changed files with 33 additions and 47 deletions

View File

@ -1,29 +1,35 @@
FROM debian:jessie
FROM debian:latest
LABEL maintainer="thomas.klaehn@u-blox.com"
LABEL maintainer="tkl@blackfinn.de"
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq 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 \
p7zip-full vim sssd libnss-sss libpam-sss && \
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 && \
DEBIAN_FRONTEND=noninteractive apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -yq install g++-multilib \
# Enable contrip section for "repo"
RUN sed -i -e 's/.main$/ main contrib/' /etc/apt/sources.list
# Install depencencies
RUN apt-get update && apt-get install -yq bash bc build-essential chrpath cpio \
debianutils default-jdk diffstat dos2unix g++-multilib gawk \
gcc-multilib git libc6-dev-i386 libsdl1.2-dev libssl-dev locales lzop \
p7zip-full python python3 python3-pexpect repo socat texinfo unzip \
wget vim-common xz-utils
# Reconfigure Dash
RUN echo "dash dash/sh boolean false" | debconf-set-selections && dpkg-reconfigure dash
# Add i386 arch
RUN dpkg --add-architecture i386 && apt-get update && apt-get -yq install \
libusb-1.0-0-dev:i386 libxml2:i386 jq
#RUN echo " IdentiyFile /.ssh/id_rsa" >> /etc/ssh/ssh_config
RUN echo -e "auth required pam_sss.so\naccount required pam_sss.so\npassword required pam_sss.so\nsession required pam_sss.so" > /etc/pam.d/sss_test
# Set UTF8 locale settings
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8
ENV LANG en_US.utf8
RUN useradd -ms /bin/bash jenkins
RUN echo "jenkins:jenkins" | chpasswd
ADD init.sh /usr/local/bin/init.sh
ENTRYPOINT ["/usr/local/bin/init.sh"]

View File

@ -3,17 +3,16 @@
A docker container used to build yocto images. It's based on Debian jessie.
## Prerequisites
Docker needs to be installed and the docker daemon needs to run. Also the user
needs to be member of the _docker_ group.
needs to be member of the docker group.
```sh
```shell
adduser <username> docker
```
## Build the container
```sh
```shell
docker build -t "<name>:<tag>" .
```
@ -21,7 +20,6 @@ docker build -t "<name>:<tag>" .
Run from HOME directory:
```sh
```shell
docker run -it --rm -v=/var/lib/sss/pipes/:/var/lib/sss/pipes/:rw -v $(pwd):$(pwd) -w $(pwd) -u $(id -u $USER):$(id -g $USER) <name>:<tag> /bin/bash
```

26
init.sh
View File

@ -1,27 +1,10 @@
#!/bin/bash
uid=$(id -u $USER)
if [ ${uid} -lt 100 ]
then
echo "Usage of system users isn't allowed (${uid})."
exit 1
fi
if [[ ! $(pwd) == /home/* ]]
then
echo "Only run it from any '/home/*' folder, not '$(pwd)'."
exit 2
fi
USERNAME=$(whoami | sed -e 's/@.*$//')
HOME=/home/$USERNAME
HOSTNAME=oe
# Determine parallel build capabilities.
parallel_build="$(nproc >&1)"
proc="$(nproc >&1)"
parallel_build=$((proc - 1))
if [ ${parallel_build} -gt 20 ]
if [ ${proc} -gt 20 ]
then
BB_NUMBER_THREADS=20
PARALLEL_MAKE="-j 20"
@ -35,7 +18,6 @@ BB_ENV_EXTRAWHITE="BB_NUMBER_THREADS PARALLEL_MAKE BB_NUMBER_PARSE_THREADS"
export BB_NUMBER_THREADS
export PARALLEL_MAKE
export BB_ENV_EXTRAWHITE
export HOME
export HOSTNAME
exec "$@"