diff --git a/.github/workflows/github.yml b/.github/workflows/github.yml index 472329c..e99880f 100644 --- a/.github/workflows/github.yml +++ b/.github/workflows/github.yml @@ -1,6 +1,12 @@ name: GitHub -on: [push, pull_request] +on: + push: + branches: + - main + pull_request: + branches: + - main jobs: diff --git a/.github/workflows/gitlab.yml b/.github/workflows/gitlab.yml index f2bb271..9cf1ea9 100644 --- a/.github/workflows/gitlab.yml +++ b/.github/workflows/gitlab.yml @@ -1,6 +1,12 @@ name: GitLab -on: [push, pull_request] +on: + push: + branches: + - main + pull_request: + branches: + - main jobs: diff --git a/LICENSE b/LICENSE index 33d1c83..b579e18 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Institute for Automotive Engineering (ika), RWTH Aachen University +Copyright (c) 2023-2024 Institute for Automotive Engineering (ika), RWTH Aachen University Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 731e295..41dcfb1 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ + +

*docker-ros* automatically builds minimal container images of ROS applications. @@ -14,10 +16,8 @@ > [!IMPORTANT] > This repository is open-sourced and maintained by the [**Institute for Automotive Engineering (ika) at RWTH Aachen University**](https://www.ika.rwth-aachen.de/). > **DevOps, Containerization and Orchestration of Software-Defined Vehicles** are some of many research topics within our [*Vehicle Intelligence & Automated Driving*](https://www.ika.rwth-aachen.de/en/competences/fields-of-research/vehicle-intelligence-automated-driving.html) domain. -> If you would like to learn more about how we can support your DevOps or automated driving efforts, feel free to reach out to us! ->      *Timo Woopen - Manager Research Area Vehicle Intelligence & Automated Driving* ->      *+49 241 80 23549* ->      *timo.woopen@ika.rwth-aachen.de* +> If you would like to learn more about how we can support your advanced driver assistance and automated driving efforts, feel free to reach out to us! +> :email: ***opensource@ika.rwth-aachen.de*** - [About](#about) - [Prerequisites](#prerequisites) @@ -35,6 +35,8 @@ - [Extra System Dependencies (*pip*)](#extra-system-dependencies-pip) - [Custom Installation Script](#custom-installation-script) - [Extra Image Files](#extra-image-files) +- [Additional Information](#additional-information) + - [User Setup](#user-setup) - [Configuration Variables](#configuration-variables) We recommend to use *docker-ros* in combination with our other tools for Docker and ROS. @@ -332,6 +334,19 @@ If you need to have additional files present in the deployment image, you can us Create a folder `additional-files` in your `docker` folder (or configure a different `ADDITIONAL_FILES_DIR`) and place any files or directories in it. The contents will be copied to `/docker-ros/additional-files` in the image. +## Additional Information + +### User Setup + +Containers of the provided images start with `root` user by default. If the two environment variables `DOCKER_UID` and `DOCKER_GID` are passed, a new user with the corresponding UID/GID is created on the fly. Most importantly, this features allows to mount and edit files of the host user in the container without having to deal with permission issues. + +```bash +docker run --rm -it -e DOCKER_UID=$(id -u) -e DOCKER_GID=$(id -g) -e DOCKER_USER=$(id -un) rwthika/ros:latest +``` + +The password of the custom user is set to its username (`dockeruser:dockeruser` by default). + + ## Configuration Variables > **Note** diff --git a/docker/Dockerfile b/docker/Dockerfile index 5156887..0a9abfe 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -187,6 +187,10 @@ RUN apt-get update && \ ros-${ROS_DISTRO}-ros-core \ && rm -rf /var/lib/apt/lists/* +# configure pip +RUN mkdir -p ~/.config/pip && \ + echo -e "[global]\nbreak-system-packages = true" >> ~/.config/pip/pip.conf + # copy install script from dependencies stage COPY --from=dependencies $WORKSPACE/.install-dependencies.sh $WORKSPACE/.install-dependencies.sh diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 2456281..5b30c74 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -8,20 +8,26 @@ source /opt/ros/$ROS_DISTRO/setup.bash # exec as dockeruser with configured UID/GID if [[ $DOCKER_UID && $DOCKER_GID ]]; then - groupadd -g $DOCKER_GID $DOCKER_USER - useradd -s /bin/bash \ - -u $DOCKER_UID \ - -g $DOCKER_USER \ - --create-home \ - --home-dir /home/$DOCKER_USER \ - --groups sudo,video \ - --password "$(openssl passwd -1 $DOCKER_USER)" \ - $DOCKER_USER && \ - touch /home/$DOCKER_USER/.sudo_as_admin_successful - cp /root/.bashrc /home/$DOCKER_USER - ln -s $WORKSPACE /home/$DOCKER_USER/ws - chown -R $DOCKER_USER:$DOCKER_USER $WORKSPACE - chown -R $DOCKER_USER:$DOCKER_USER /home/$DOCKER_USER + if ! getent group $DOCKER_GID > /dev/null 2>&1; then + groupadd -g $DOCKER_GID $DOCKER_USER + fi + if ! getent passwd $DOCKER_UID > /dev/null 2>&1; then + useradd -s /bin/bash \ + -u $DOCKER_UID \ + -g $DOCKER_GID \ + --create-home \ + --home-dir /home/$DOCKER_USER \ + --groups sudo,video \ + --password "$(openssl passwd -1 $DOCKER_USER)" \ + $DOCKER_USER && \ + touch /home/$DOCKER_USER/.sudo_as_admin_successful + cp /root/.bashrc /home/$DOCKER_USER + ln -s $WORKSPACE /home/$DOCKER_USER/ws + chown -h $DOCKER_UID:$DOCKER_GID $WORKSPACE /home/$DOCKER_USER/ws /home/$DOCKER_USER/.sudo_as_admin_successful + if [[ -d $WORKSPACE/src ]]; then + chown -R $DOCKER_USER:$DOCKER_USER $WORKSPACE/src + fi + fi [[ $(pwd) == "$WORKSPACE" ]] && cd /home/$DOCKER_USER/ws exec gosu $DOCKER_USER "$@" else