[yocto] Writing a functional Dockerfile to run a container with a package revision (PR) server

Iván Castell icastell at nayarsystems.com
Fri May 4 06:57:31 PDT 2018


The purpose is deploying a yocto PR server using a docker container. More
info about PR server can be found in the following link:
https://wiki.yoctoproject.org/wiki/PR_Service

To try doing that I wrote this "Dockerfile" to generate a docker image:

FROM ubuntu:16.04
MAINTAINER Yocto <yocto at mydomain.com>

# Update, upgrade and install
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y gawk wget git git-core diffstat unzip texinfo
gcc-multilib build-essential chrpath socat xterm curl parted python python3
python3-pip python3-pexpect xz-utils debianutils iputils-ping libsdl1.2-dev
net-tools

# Set up locales
RUN apt-get -y install locales apt-utils sudo && dpkg-reconfigure locales
&& locale-gen en_US.UTF-8 && update-locale LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
ENV LANG en_US.utf8

# Clean up APT when done
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Replace dash with bash
RUN rm /bin/sh && ln -s bash /bin/sh

# Yocto user management
RUN groupadd -g 1000 yocto && useradd -u 1000 -g 1000 -ms /bin/bash yocto
&& usermod -a -G sudo yocto && usermod -a -G users yocto
ENV HOME /home/yocto
USER yocto

# Download poky
RUN git clone --branch rocko git://git.yoctoproject.org/poky
/home/yocto/poky

# Create some directories
RUN mkdir -p /home/yocto/build /home/yocto/prserv

# Make /home/yocto/poky the working directory
WORKDIR /home/yocto/poky

# Expose listen port
EXPOSE 8585

# Run PR-server
CMD /bin/sh -c " \
    source ./oe-init-build-env ../build \
    && bitbake-prserv --start --file /home/yocto/prserv/sqlite3.db --log
/tmp/prserv.log --port 8585 \
"
Using previous Dockerfile I build a docker image:

$ docker build -t docker-prserver .
[...]
Successfully built 362f4599b1b6
Successfully tagged docker-prserver:latest

As you can see before, the process ends successfully. After that, I run a
container:

$ docker run -ti docker-prserver
yocto at b3c9fd06d8af:~/poky$

The previous command creates a shell. I check if the process
“bitbake-prserver” is running:

$ netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State

As you can see, the “bitbake-prserver” process is not running (no listen
port). However, if I log into the container and execute the CMD command:

yocto at b3c9fd06d8af:~/poky/build$ source ./oe-init-build-env ../build/ &&
bitbake-prserv --start --file /home/yocto/prserv/sqlite3.db --log
/tmp/prserv.log --port 8585

Then it works fine:

yocto at b3c9fd06d8af:~$ netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address    State
tcp        0      0 0.0.0.0:8585            0.0.0.0:*          LISTEN

It’s supposed that CMD is executed when the container is instantiated, but
this is not happening. What is the right way to write a Dockerfile to run a
bitbake-prserv server listening on the exposed port?

Hope some of you have some experience on this and can provide some useful
feedback.

Thanks a lot in advance! :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20180504/03e39a20/attachment-0001.html>


More information about the yocto mailing list