diff --git a/Dockerfile b/Dockerfile index 9b0f39e4..5870a50f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,22 +18,19 @@ ARG USER_GID=1000 # hadolint ignore=DL3006 FROM ${MOVEIT_STUDIO_BASE_IMAGE} as base -# hadolint ignore=DL3002 -USER root - -# Copy source code from the workspace's ROS 2 packages to a workspace inside the container -ARG USER_OVERLAY_WS=/opt/user_overlay_ws -ENV USER_OVERLAY_WS $USER_OVERLAY_WS -RUN mkdir -p ${USER_OVERLAY_WS}/src ${USER_OVERLAY_WS}/build ${USER_OVERLAY_WS}/install ${USER_OVERLAY_WS}/log -COPY ./src ${USER_OVERLAY_WS}/src - # Create a non-root user ARG USERNAME ARG USER_UID ARG USER_GID +# Copy source code from the workspace's ROS 2 packages to a workspace inside the container +ARG USER_WS=/home/${USERNAME}/user_overlay_ws +ENV USER_WS=${USER_WS} +RUN mkdir -p ${USER_WS}/src ${USER_WS}/build ${USER_WS}/install ${USER_WS}/log +COPY ./src ${USER_WS}/src + # Also mkdir with user permission directories which will be mounted later to avoid docker creating them as root -WORKDIR $USER_OVERLAY_WS +WORKDIR $USER_WS # hadolint ignore=DL3008 RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ @@ -43,12 +40,14 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ apt-get install -q -y --no-install-recommends sudo && \ echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} && \ chmod 0440 /etc/sudoers.d/${USERNAME} && \ + cp -r /etc/skel/. /home/${USERNAME} && \ mkdir -p \ /home/${USERNAME}/.ccache \ /home/${USERNAME}/.config \ /home/${USERNAME}/.ignition \ - /home/${USERNAME}/.ros/log && \ - chown -R $USER_UID:$USER_GID /home/${USERNAME} ${USER_OVERLAY_WS} /opt/overlay_ws/ + /home/${USERNAME}/.colcon \ + /home/${USERNAME}/.ros && \ + chown -R $USER_UID:$USER_GID /home/${USERNAME} /opt/overlay_ws/ # Install additional dependencies # You can also add any necessary apt-get install, pip install, etc. commands at this point. @@ -62,9 +61,10 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ --from-paths src \ --ignore-src -# Remove .bashrc from parent image and create a new one -USER ${USERNAME} -RUN rm /home/${USERNAME}/.bashrc && touch /home/${USERNAME}/.bashrc +# Remove duplicated serial dependency install files, otherwise there will be a build error. +# NOTE: This can be removed when MoveIt Studio fully separates core and hardware capabilities. +WORKDIR /opt/overlay_ws +RUN rm -rf build/serial install/serial ######################################### # Target for compiled, deployable image # @@ -72,18 +72,18 @@ RUN rm /home/${USERNAME}/.bashrc && touch /home/${USERNAME}/.bashrc FROM base as user-overlay ARG USERNAME -USER ${USERNAME} +ARG USER_WS=/home/${USERNAME}/user_overlay_ws +ENV USER_WS=${USER_WS} # Compile the workspace +WORKDIR $USER_WS # hadolint ignore=SC1091 -RUN --mount=type=cache,target=/home/studio-user/.ccache \ +RUN --mount=type=cache,target=/home/${USERNAME}/.ccache \ . /opt/overlay_ws/install/setup.sh && \ colcon build -# Add the custom entrypoint -COPY ./entrypoint.sh /entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] -RUN echo "source /entrypoint.sh && set +e" >> ~/.bashrc +# Set up the user's .bashrc file and shell. +# RUN echo "source /moveit_studio_utils/setup_workspaces.sh && set +e" >> /home/${USERNAME}/.bashrc CMD ["/usr/bin/bash"] ################################################################### @@ -91,11 +91,9 @@ CMD ["/usr/bin/bash"] ################################################################### FROM base as user-overlay-dev -USER root - -# The location of the user's workspace inside the container -ARG USER_OVERLAY_WS=/opt/user_overlay_ws -ENV USER_OVERLAY_WS $USER_OVERLAY_WS +ARG USERNAME +ARG USER_WS=/home/${USERNAME}/user_overlay_ws +ENV USER_WS=${USER_WS} # Install any additional packages for development work # hadolint ignore=DL3008 @@ -107,10 +105,6 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ gdb \ nano -# Add the dev entrypoint -ARG USERNAME -USER ${USERNAME} -COPY ./entrypoint.sh /entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] -RUN echo "source /entrypoint.sh && set +e" >> ~/.bashrc +# Set up the user's .bashrc file and shell. +# RUN echo "source /moveit_studio_utils/setup_workspaces.sh && set +e" >> /home/${USERNAME}/.bashrc CMD ["/usr/bin/bash"] diff --git a/build/.gitkeep b/build/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/docker-compose.yaml b/docker-compose.yaml index 7c5ab22b..336f449a 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -19,6 +19,9 @@ services: - USER_GID=${STUDIO_USER_UID:-1000} - USERNAME=${USERNAME:-studio-user} - MOVEIT_STUDIO_BASE_IMAGE=picknikciuser/moveit-studio:${STUDIO_DOCKER_TAG:-main} + # Set the user workspace folder location. + environment: + - USER_WS=/home/${USERNAME:-studio-user}/user_overlay_ws # Starts the MoveIt Studio Agent and the Bridge between the Agent and the Web UI agent_bridge: @@ -44,12 +47,7 @@ services: delay: 2s command: agent_bridge.app - # Starts the frontend-agent - frontend_agent: - extends: base - command: /usr/lib/formant/agent/formant-agent - - # Starts the REST API for the Web UI + # Starts the REST API for the Web UI. rest_api: extends: base healthcheck: @@ -58,7 +56,7 @@ services: timeout: 1m command: rest_api.app - # Starts the robot drivers + # Starts the robot drivers. drivers: extends: base privileged: true @@ -69,6 +67,7 @@ services: - "/dev/ttyUSB0:/dev/ttyUSB0" # Allow access to the gripper. command: robot.app + # Starts the web UI frontend. web_ui: image: picknikciuser/moveit-studio-frontend:${STUDIO_DOCKER_TAG:-main} ports: @@ -100,12 +99,12 @@ services: privileged: true volumes: # Mount the source code, colcon generated artifacts, and ccache - - ./src/:/opt/user_overlay_ws/src:rw - - ./build/:/opt/user_overlay_ws/build:rw - - ./install/:/opt/user_overlay_ws/install:rw - - ./log/:/opt/user_overlay_ws/log:rw + - ./src/:/home/${USERNAME:-studio-user}/user_overlay_ws/src:rw + - ./build/:/home/${USERNAME:-studio-user}/user_overlay_ws/build:rw + - ./install/:/home/${USERNAME:-studio-user}/user_overlay_ws/install:rw + - ./log/:/home/${USERNAME:-studio-user}/user_overlay_ws/log:rw - ./.ccache/:/home/${USERNAME:-studio-user}/.ccache:rw - - ${HOME}/.ros/log_moveit_studio:/root/.ros/log:/root/.ros/log + - ${HOME}/.ros/log_moveit_studio:/home/${USERNAME:-studio-user}/.ros/log # Allow access to host hardware e.g. RealSense cameras - /dev:/dev command: sleep infinity diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100755 index eceb6b23..00000000 --- a/entrypoint.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# Custom entrypoint to start when running an image that overlays MoveIt Studio - -set +e - -# Source the MoveIt Studio binaries and your workspace -source "/opt/overlay_ws/install/setup.bash" -if [ -f "${USER_OVERLAY_WS}/install/local_setup.bash" ]; then - source "${USER_OVERLAY_WS}/install/local_setup.bash" -fi - -# Set the location for custom Behavior package generation -export STUDIO_GENERATE_PACKAGE_OUTPUT_PATH="${USER_OVERLAY_WS}/src" - -# Set the permissions for your non-root user at startup. -# shellcheck source=bin/docker/utils/change_permissions.sh -source /moveit_studio_utils/change_permissions.sh - -# Set the DDS configuration for ROS 2 inter-process communication. -# shellcheck source=bin/docker/utils/copy_dds_configs.sh -source /moveit_studio_utils/copy_dds_configs.sh - -exec "$@" diff --git a/install/.gitkeep b/install/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/log/.gitkeep b/log/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/src/external_dependencies/.clang-tidy b/src/external_dependencies/.clang-tidy new file mode 100644 index 00000000..395515ae --- /dev/null +++ b/src/external_dependencies/.clang-tidy @@ -0,0 +1,9 @@ +--- +# Disable all checks in this folder. +# At least one check must be enabled to avoid errors, though. +Checks: '-*, + cppcoreguidelines-avoid-goto, + ' +HeaderFilterRegex: '' +AnalyzeTemporaryDtors: false +...