diff --git a/docker/Dockerfile b/docker/Dockerfile index 131e4ccbf..7d63139cf 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,54 +4,56 @@ ARG branch="development" ARG robocomp_version="dsr" FROM ${base_image}:${base_tag} AS dependencies-version +ARG USERNAME=demo +ARG USER_UID=1000 +ARG USER_GID=$USER_UID # Disable Prompt During Packages Installation ARG DEBIAN_FRONTEND=noninteractive ENV TZ=Europe/Madrid RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone ARG branch -# DEFAULT LD_LIBRARY_PATH vaiables from the nvidia/opengl image confuses pyside2 about the qt5 Library paths +# DEFAULT LD_LIBRARY_PATH variables from the nvidia/opengl image confuses pyside2 about the qt5 Library paths ENV LD_LIBRARY_PATH="/lib:/usr/lib" RUN export LD_LIBRARY_PATH="/lib:/usr/lib" +# Create the user +RUN groupadd --gid $USER_GID $USERNAME \ + && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME --create-home \ + && apt-get update \ + && apt-get install -y sudo \ + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ + && chmod 0440 /etc/sudoers.d/$USERNAME +# Install main dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ curl \ - sudo \ && rm -rf /var/lib/apt/lists/* RUN cd ~ && export branch=$branch \ && curl -sL https://raw.githubusercontent.com/grupo-avispa/robocomp/$branch/tools/install/resources/robocomp_prerequisites_install.sh | bash -s $branch -RUN export uid=1000 gid=1000 && \ - mkdir -p /home/demo && \ - echo "demo:x:${uid}:${gid}:demo,,,:/home/demo:/bin/bash" >> /etc/passwd && \ - echo "demo:x:${uid}:" >> /etc/group && \ - echo "demo:demo"|chpasswd && \ - echo "demo ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/demo-user && \ - chown ${uid}:${gid} -R /home/demo -USER demo -WORKDIR /home/demo/ +USER $USERNAME +WORKDIR /home/$USERNAME/ FROM dependencies-version AS base-version ARG branch +ARG USERNAME=demo # Using robocomp installation script -RUN cd ~ && export branch=$branch \ +RUN cd $HOME && export branch=$branch \ && curl -sL https://raw.githubusercontent.com/grupo-avispa/robocomp/$branch/tools/install/robocomp_install.sh | bash -s $branch -ENV PATH=$PATH:/opt/robocomp/bin/:'/home/demo/.local/bin' -ENV ROBOCOMP=/home/demo/robocomp -RUN export ROBOCOMP=/home/demo/robocomp -RUN export PATH=$PATH:/opt/robocomp/bin/:'/home/demo/.local/bin' -USER demo -RUN cd /home/demo/robocomp && mkdir -p build && cd build && cmake .. && make -j$(nproc) +RUN export ROBOCOMP=/home/$USERNAME/robocomp +USER $USERNAME +WORKDIR /home/$USERNAME/robocomp +RUN mkdir -p build && cd build && cmake .. && make -j$(nproc) USER root -RUN cd /home/demo/robocomp/build && make install -USER demo -WORKDIR robocomp +RUN cd build && make install +USER $USERNAME +WORKDIR /home/$USERNAME/robocomp RUN git annex get \ files/innermodel/simpleworld.xml \ files/osgModels/textures/wood.jpg \ files/innermodel/tar36h11-*.png \ files/osgModels/textures/Metal.jpg \ files/osgModels/robex/robex.ive -RUN cp -r -L files /home/demo/files 2>/dev/null || : +RUN cp -r -L files /home/$USERNAME/files 2>/dev/null || : FROM base-version AS dsr-version USER root @@ -68,9 +70,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ # ICE fix COPY Connection.h /usr/include/Ice/Connection.h -### Third party dependencies +# Third party dependencies RUN curl -S https://raw.githubusercontent.com/grupo-avispa/cortex/development/installation.sh | bash -x -USER demo +USER $USERNAME FROM ${robocomp_version}-version AS final