Skip to content

Commit

Permalink
Add "robot" container (#221)
Browse files Browse the repository at this point in the history
* Initial commit of _robot container and devcontainer

* Add xacro as an exec_depend for blue_description

* Update comments

* Remove unused Docker stage "blue_src_and_deps"

Renamed *.repos --> blue.repos and sim.repos

---------

Co-authored-by: Aaron Marburg <[email protected]>
  • Loading branch information
amarburg and amarburg authored Aug 5, 2024
1 parent 506be06 commit ba77c25
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 7 deletions.
31 changes: 31 additions & 0 deletions .devcontainer/robot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# Dockerfile for *-robot development container
#
ARG BLUE_GITHUB_REPO=Robotic-Decision-Making-Lab/blue
ARG ROS_DISTRO=rolling
FROM ${BLUE_GITHUB_REPO}:${ROS_DISTRO}-robot

# Install ROS dependencies
# This is done in a previous stage, but we include it again here in case anyone wants to
# add new dependencies during development
ENV USERNAME=blue
ENV USER_WORKSPACE=/home/$USERNAME/ws_blue
WORKDIR $USER_WORKSPACE

COPY --chown=$USER_UID:$USER_GID . src/blue
RUN sudo apt-get -q update \
&& sudo apt-get -q -y upgrade \
&& rosdep update \
&& rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --skip-keys="gz-transport12 gz-sim7 gz-math7 gz-msgs9 gz-plugin2" \
&& sudo apt-get autoremove -y \
&& sudo apt-get clean -y \
&& sudo rm -rf /var/lib/apt/lists/*

# Install debugging/linting Python packages
RUN python3 -m pip install \
pre-commit \
mypy

# Disable the setuputils installation warning
# This prevents us from needing to pin the setuputils version (which doesn't always work)
ENV PYTHONWARNINGS="ignore"
40 changes: 40 additions & 0 deletions .devcontainer/robot/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "Robot Dev Container",
"build": {
"dockerfile": "Dockerfile",
"context": "../..",
"args": {
"BLUE_GITHUB_REPO": "ghcr.io/robotic-decision-making-lab/blue",
"ROS_DISTRO": "rolling"
}
},
"workspaceMount": "source=${localWorkspaceFolder},target=/home/blue/ws_blue/src/blue,type=bind",
"workspaceFolder": "/home/blue/ws_blue/src/blue",
"remoteUser": "blue",
"runArgs": [
"--network=host",
"--cap-add=SYS_PTRACE",
"--security-opt=seccomp:unconfined",
"--security-opt=apparmor:unconfined",
"--volume=/dev:/dev",
"--privileged",
"--volume=/run/user/1000:/run/user/1000"
],
"containerEnv": {},
"customizations": {
"vscode": {
"extensions": [
"ms-azuretools.vscode-docker",
"ms-python.python",
"njpwerner.autodocstring",
"redhat.vscode-xml",
"redhat.vscode-yaml",
"smilerobotics.urdf",
"esbenp.prettier-vscode",
"charliermarsh.ruff",
"josetr.cmake-language-support-vscode",
"unifiedjs.vscode-mdx"
]
}
}
}
19 changes: 17 additions & 2 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ RUN apt-get -q update \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# Install all ROS dependencies
# Install all ROS dependencies for _just_ blue
# (we have not imported other repos from .repos files)
RUN apt-get -q update \
&& apt-get -q -y upgrade \
&& rosdep update \
Expand All @@ -36,6 +37,14 @@ RUN apt-get -q update \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# This stage includes
# - Switching to the non-root user
# - Copying 'blue' source from this repo into the non-root user's workspace
# - Installing blue deps using pip, apt and rosdep
# - Installs the remaining blue dependencies from blue_robot.repos
# - Installs deps from rosdep for all src dependencies
# - colcon build
#
FROM ci AS robot

# Configure a new non-root user
Expand Down Expand Up @@ -88,14 +97,20 @@ RUN sudo apt-get -q update \
&& sudo apt-get clean -y \
&& sudo rm -rf /var/lib/apt/lists/*

WORKDIR $USER_WORKSPACE
RUN sudo apt-get -q update \
&& sudo apt-get -q -y upgrade \
&& vcs import src < src/blue/blue.repos \
&& rosdep update \
&& rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} \
&& sudo apt-get autoremove -y \
&& sudo apt-get clean -y \
&& sudo rm -rf /var/lib/apt/lists/*

# Actually build workspace
RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
&& colcon build

RUN echo "source ${USER_WORKSPACE}/install/setup.bash" >> /home/$USERNAME/.bashrc \
&& echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/$USERNAME/.bashrc

Expand Down Expand Up @@ -161,7 +176,7 @@ RUN [ "/bin/bash" , "-c" , " \
WORKDIR $USER_WORKSPACE
RUN sudo apt-get -q update \
&& sudo apt-get -q -y upgrade \
&& vcs import src < src/blue/blue.repos \
&& vcs import src < src/blue/sim.repos \
&& rosdep update \
&& rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} \
&& sudo apt-get autoremove -y \
Expand Down
21 changes: 21 additions & 0 deletions .docker/compose/robot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
blue:
image: ghcr.io/robotic-decision-making-lab/blue:rolling-robot
build:
dockerfile: .docker/Dockerfile
target: robot
context: ../../
network_mode: host
privileged: true
cap_add:
- SYS_PTRACE
security_opt:
- seccomp:unconfined
- apparmor:unconfined
volumes:
- /dev:/dev
- /run/user/1000:/run/user/1000
- type: bind
source: ../../
target: /home/blue/ws_blue/src/blue
command: tail -f /dev/null
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
!blue_description
!blue_demos
!blue.repos
!sim.repos
!.docker/entrypoints
!requirements-build.txt
5 changes: 0 additions & 5 deletions blue.repos
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
repositories:

ros_gz:
type: git
url: https://github.com/gazebosim/ros_gz
version: ros2

hydrodynamics:
type: git
url: https://github.com/Robotic-Decision-Making-Lab/hydrodynamics.git
Expand Down
11 changes: 11 additions & 0 deletions sim.repos
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# Note this is _in addition to_ blue.repos
# (i.e. you need to vcs import both files independently)
#
repositories:

# ROS-Gazebo integration
ros_gz:
type: git
url: https://github.com/gazebosim/ros_gz
version: ros2

0 comments on commit ba77c25

Please sign in to comment.