Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker-compose.yaml template and include example of usage #42

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ ARG MOVEIT_STUDIO_BASE_IMAGE
ARG USERNAME=studio-user
ARG USER_UID=1000
ARG USER_GID=1000
ARG BASE=base

##################################################
# Starting from the specified MoveIt Pro release #
##################################################
# The image tag is specified in the argument itself.
# hadolint ignore=DL3006
FROM ${MOVEIT_STUDIO_BASE_IMAGE} AS base
FROM ${MOVEIT_STUDIO_BASE_IMAGE} AS base-base

# Create a non-root user
ARG USERNAME
Expand Down Expand Up @@ -49,18 +50,20 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
/home/${USERNAME}/.ros && \
chown -R $USER_UID:$USER_GID /home/${USERNAME} /opt/overlay_ws/

# IMPORTANT: Optionally install Nvidia drivers for improved simulator performance with Nvidia GPUs.
# To do this you must
# 1. Uncomment the ENV and RUN entries below
# 2. Replace the 'nvidia-driver-555' apt package with the Nvidia driver version on your host, e.g. nvidia-driver-535, nvidia-driver-555. Use nvidia-smi on your host to determine the driver version.
# After rebuilding via `moveit_pro build` verify the drivers are active in your container by running `nvidia_smi` inside of `moveit_pro shell`.
# ENV DEBIAN_FRONTEND=noninteractive
# RUN apt update && apt install -y software-properties-common
# RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
# --mount=type=cache,target=/var/lib/apt,sharing=locked \
# add-apt-repository ppa:graphics-drivers/ppa && \
# apt update && apt upgrade -y && apt install -y nvidia-driver-555
FROM base-base AS base-nvidia
ARG NVIDIA_DRIVER_PACKAGE
ENV DEBIAN_FRONTEND=noninteractive
# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y --no-install-recommends software-properties-common
# hadolint ignore=DL3008
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
add-apt-repository ppa:graphics-drivers/ppa && \
apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends "${NVIDIA_DRIVER_PACKAGE}"

ARG BASE
# hadolint ignore=DL3006
FROM base-${BASE} AS base
# Install additional dependencies
# You can also add any necessary apt-get install, pip install, etc. commands at this point.
# NOTE: The /opt/overlay_ws folder contains MoveIt Pro binary packages and the source file.
Expand Down
108 changes: 16 additions & 92 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,106 +1,30 @@
# Docker Compose file for user overlays of the MoveIt Pro images.
# Docker Compose file that will be merged with /opt/moveit_pro/docker-compose.yaml.
# For more details on how merging works, see https://docs.docker.com/compose/how-tos/multiple-compose-files/merge/#merging-rules.

# Services that are listed under `/opt/moveit_pro/docker-compose.yaml` are mirrored here for merging.
# Feel free to remove services here that are unmodified.
services:
# Sets common properties for other services. Should not be instantiated directly.
# The base image that all MoveIt Pro services extend off of. Builds the user workspace.
base:
# Extend the installed MoveIt Pro docker compose file.
# Change this to match your environment, if MoveIt Pro was installed to a different location.
extends:
file: /opt/moveit_pro/docker-compose.yaml
service: base
image: moveit-pro-overlay
build:
context: .
target: user-overlay
# List any arguments for building the user workspace here.
args:
- USER_UID=${STUDIO_USER_UID:-1000}
- USER_GID=${STUDIO_USER_GID:-1000}
- USERNAME=${STUDIO_USERNAME:-studio-user}
- MOVEIT_STUDIO_BASE_IMAGE=picknikciuser/moveit-studio:${STUDIO_DOCKER_TAG:-main}

# Starts the MoveIt Pro Agent and the Bridge between the Agent and the Web UI
# IMPORTANT: Optionally install Nvidia drivers for improved simulator performance with Nvidia GPUs.
# To do this you must
# 1. Uncomment the BASE and NVIDIA_DRIVER_PACKAGE build args below
# 2. Replace the 'nvidia-driver-555' apt package with the Nvidia driver version on your host, e.g. nvidia-driver-535, nvidia-driver-555. Use nvidia-smi on your host to determine the driver version.
# After rebuilding via `moveit_pro build` verify the drivers are active in your container by running `nvidia_smi` inside of `moveit_pro shell`.
# - BASE=nvidia
# - NVIDIA_DRIVER_PACKAGE=nvidia-driver-555

# Starts the MoveIt Pro Agent and the Bridge between the Agent and the Web UI.
agent_bridge:
extends: base
privileged: true
# This service relies on cgroup_rules defined in base which allow the user to use the host's network video4linux and usb_device devices.
depends_on:
rest_api:
condition: service_healthy
volumes:
# Allow the user to run graphical programs from within the docker container.
- /tmp/.X11-unix:/tmp/.X11-unix:ro
# Allow access to host hardware e.g. RealSense cameras
- /dev:/dev
deploy:
restart_policy:
condition: any
delay: 2s
command: agent_bridge.app

# Starts the REST API for the Web UI.
rest_api:
extends: base
healthcheck:
test: "curl -f http://localhost:3200/objectives"
interval: 5s
timeout: 1m
command: rest_api.app

# Starts the robot drivers.
drivers:
extends: base
privileged: true
# Ensures the drivers container has RT priority
ulimits:
rtprio: 99
devices:
- "/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:
- "80:80"
network_mode: host

# Starts RViz for visualization.
rviz:
extends: base
profiles:
- rviz
command: bash -c "ros2 launch moveit_studio_agent developer_rviz.launch.py"

# Starts MoveIt Setup Assistant for creating MoveIt configurations.
setup_assistant:
extends: base
profiles:
- setup_assistant
command: bash -c "ros2 launch moveit_setup_assistant setup_assistant.launch.py"

# Developer specific configuration
# Developer specific configuration when running `moveit_pro dev`.
dev:
extends: base
build:
target: user-overlay-dev
image: moveit-studio-overlay-dev
stdin_open: true
tty: true
privileged: true
volumes:
# Mount the source code, colcon generated artifacts, and ccache
- ./src/:/home/${STUDIO_USERNAME:-studio-user}/user_ws/src:rw
- ./build/:/home/${STUDIO_USERNAME:-studio-user}/user_ws/build:rw
- ./install/:/home/${STUDIO_USERNAME:-studio-user}/user_ws/install:rw
- ./log/:/home/${STUDIO_USERNAME:-studio-user}/user_ws/log:rw
- ./.ccache/:/home/${STUDIO_USERNAME:-studio-user}/.ccache:rw
- ${HOME}/.ros/log_moveit_pro:/home/${STUDIO_USERNAME:-studio-user}/.ros/log
# Allow access to host hardware e.g. RealSense cameras
- /dev:/dev
command: sleep infinity
# Making a separate profile prevents this service from being built when using `docker compose build`
# and launched when using `docker compose up`.
profiles: ["dev"]

volumes:
ignition_resources:
Loading