[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 07:29:10 PDT 2018


I found the right way to fix my issue. First I wrote this script:

    $ cat start.sh
    #! /bin/sh

    cd /home/yocto/poky
    source ./oe-init-build-env ../build
    bitbake-prserv --start --file /home/yocto/prserv/sqlite3.db --log
/tmp/prserv.log --port 8585
    tail -f /tmp/prserv.log

And after modified the Dockerfile adding this stuff:

    ADD start.sh /home/yocto/start.sh
    RUN chmod 755 /home/yocto/start.sh
    RUN chown yocto.yocto /home/yocto/start.sh
    ...
    CMD /home/yocto/start.sh

Now it works as expected. Hope this helps somebody else!



2018-05-04 15:57 GMT+02:00 Iván Castell <icastell at nayarsystems.com>:

> 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! :)
>
>


-- 




*NOTA LEGAL*
Este correo electrónico y, en su caso, cualquier fichero anexo al mismo,
contiene información de carácter confidencial exclusivamente dirigida a su
destinatario y se encuentra protegido por Ley. Cualquier persona distinta
de su destinataria tiene prohibida su reproducción, uso, divulgación, copia
o impresión total o parcial. Si ha recibido este correo electrónico por
error, se ruega lo notifique de inmediato al remitente borrando el mensaje
original juntamente con sus ficheros anexos. Gracias.

De conformidad con lo establecido en la LOPD, NAYAR SYSTEMS SL garantiza la
adopción de las medidas necesarias para asegurar el tratamiento
confidencial de los datos de carácter personal. Así mismo le informamos de
la inclusión de sus datos en un fichero bajo la responsabilidad de NAYAR
SYSTEMS SL, con la finalidad de poder atender los compromisos derivados de
la relación que mantenemos con usted. Si lo desea, puede ejercer sus
derechos de acceso, rectificación, cancelación y oposición mediante un
escrito a la siguiente dirección: info at nayarsystems.com

*LEGAL NOTE*
This email and any attachments to it contains is confidential information
exclusively intended for the recipients. Any divulgation, copy or
distribution to third parties is prohibited without written permission of
NAYAR SYSTEMS SL. If you have received this e-mail in error, please notify
the sender immediately. In accordance with Law 15/1999 of 13 December on
the Protection of Personal Data, the NAYAR SYSTEMS SL guarantees that it
has adopted the necessary measures to ensure the confidential treatment of
personal information. We also inform you that you can exercise your access,
rectification, cancellation and opposition rights by send us a mail to:
info at nayarsystems.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20180504/16aa32aa/attachment.html>


More information about the yocto mailing list