Skip to content

Commit

Permalink
Jazzy: Fix docker permissions.
Browse files Browse the repository at this point in the history
Signed-off-by: Franco Cipollone <[email protected]>
  • Loading branch information
francocipollone committed Dec 19, 2024
1 parent 030c8f3 commit a5ba1bd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 3 additions & 1 deletion docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ OS_VERSION="noble"
IMAGE_NAME=${IMAGE_NAME:-ros2_jazzy_andino_gz}
DOCKERFILE_PATH=$SCRIPT_FOLDER_PATH/Dockerfile

USER=ubuntu
USERID=$(id -u)
USER=$(whoami)

sudo docker build -t $IMAGE_NAME \
--file $DOCKERFILE_PATH \
--build-arg USERID=$USERID \
--build-arg USER=$USER \
$CONTEXT_FOLDER_PATH
10 changes: 9 additions & 1 deletion docker/dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM osrf/ros:jazzy-desktop-full

# Arguments for building
ARG USER=ubuntu
ARG USERID
ARG USER

# Setup environment
ENV TERM=linux
Expand All @@ -13,6 +14,13 @@ COPY docker/requirements.txt .
RUN apt-get update && apt-get install --no-install-recommends -y $(cat requirements.txt)
RUN rm requirements.txt

# Create a user with passwordless sudo
RUN adduser --uid $USERID --gecos "ekumen developer" --disabled-password $USER
RUN adduser $USER sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN echo "export QT_X11_NO_MITSHM=1" >> /home/$USER/.bashrc
RUN echo "export IGN_IP=127.0.0.1" >> /home/$USER/.bashrc

#####################################
# ROS2 dependencies built from source
#####################################
Expand Down
6 changes: 2 additions & 4 deletions docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ done
IMAGE_NAME=${IMAGE_NAME:-ros2_jazzy_andino_gz}
CONTAINER_NAME=${CONTAINER_NAME:-ros2_jazzy_andino_gz_container}

USER=ubuntu

SSH_PATH=/home/$USER/.ssh
WORKSPACE_SRC_CONTAINER=/home/$USER/ws/src/$REPOSITORY_FOLDER_NAME
WORKSPACE_ROOT_CONTAINER=/home/$USER/ws
Expand All @@ -94,8 +92,8 @@ mkdir -p ${REPOSITORY_FOLDER_PATH}/.build
mkdir -p ${REPOSITORY_FOLDER_PATH}/.install

# Transfer the ownership to the user
# chown -R "$USER" ${REPOSITORY_FOLDER_PATH}/.build
# chown -R "$USER" ${REPOSITORY_FOLDER_PATH}/.install
chown -R "$USER" ${REPOSITORY_FOLDER_PATH}/.build
chown -R "$USER" ${REPOSITORY_FOLDER_PATH}/.install

# Check if name container is already taken.
if sudo -g docker docker container ls -a | grep "${CONTAINER_NAME}$" -c &> /dev/null; then
Expand Down

0 comments on commit a5ba1bd

Please sign in to comment.