Skip to content
This repository has been archived by the owner on Dec 13, 2024. It is now read-only.

Add overlay Docker image option #1

Merged
merged 2 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 20 additions & 0 deletions .docker/entrypoint-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Custom entrypoint to start when running a developer container.

set -e

# Allow aliases in noninteractive shells and source common MoveIt Studio aliases
shopt -s expand_aliases
source "/common_aliases.sh"

if [[ -f ${CUSTOM_WS}/install/setup.bash ]]
sea-bass marked this conversation as resolved.
Show resolved Hide resolved
then
echo "Sourcing custom workspace"
source "${CUSTOM_WS}/install/setup.bash"
/copy_dds_configs.sh
sea-bass marked this conversation as resolved.
Show resolved Hide resolved
else
echo -e "Custom workspace is not built. Please build it with: \ncolcon build\n"
fi

exec "$@"
11 changes: 11 additions & 0 deletions .docker/entrypoint-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Custom entrypoint to start when running a release image.

set -e

source "${CUSTOM_WS}/install/setup.bash"

/copy_dds_configs.sh
sea-bass marked this conversation as resolved.
Show resolved Hide resolved

exec "$@"
86 changes: 86 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Docker container image build for running MoveIt Studio with
# a custom overlay image
#
# Example build command (with defaults):
#
# docker build -f .docker/Dockerfile .
#

# Specify the MoveIt Studio release to build on top of. See,
# https://hub.docker.com/r/picknikciuser/moveit-studio-binaries/tags
ARG MOVEIT_STUDIO_BASE_IMAGE

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

# The location of the user's custom workspace inside the container
ARG CUSTOM_WS=/opt/custom_ws
sea-bass marked this conversation as resolved.
Show resolved Hide resolved
ENV CUSTOM_WS $CUSTOM_WS

# Copy site configuration packages and and dependencies
RUN mkdir -p ${CUSTOM_WS}/src
COPY ./src $CUSTOM_WS/src
WORKDIR $CUSTOM_WS

# Install additional ROS dependencies
# NOTE: The "OVERLAY_WS" contains MoveIt Studio binary packages and the source file.
# hadolint ignore=SC1091
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
. "${OVERLAY_WS}/install/setup.sh" && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Someday we should get on renaming this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah... overlay is such a loaded word. Giovanni was right all along and we shouldn't have used other ROS repos as precedent lol

apt-get update && \
rosdep install -q -y \
--from-paths src \
--ignore-src

#################################################
# Target for compiled, deployable release image #
#################################################
FROM base as release
sea-bass marked this conversation as resolved.
Show resolved Hide resolved

WORKDIR $CUSTOM_WS

# Compile the workspace
# hadolint ignore=SC1091
RUN --mount=type=cache,target=/root/.ccache \
. "${OVERLAY_WS}/install/setup.sh" && \
colcon build

# Add the custom entrypoint
COPY .docker/entrypoint-release.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/usr/bin/bash"]

###################################################################
# Target for the developer build which does not compile any code. #
###################################################################
# Expected to mount workspace and compile/test it
# inside of the resulting container.
FROM base as dev
sea-bass marked this conversation as resolved.
Show resolved Hide resolved

# The location of the user's workspace inside the container
ARG CUSTOM_WS=/opt/custom_ws
ENV CUSTOM_WS $CUSTOM_WS
WORKDIR $CUSTOM_WS

# Install any additional packages for development work
# hadolint ignore=DL3008
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && \
apt-get install -y --no-install-recommends \
less \
gdb \
gdbserver \
ros-humble-rclcpp-dbgsym

# Add the developer entrypoint
COPY .docker/entrypoint-dev.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
RUN echo "source /entrypoint.sh" >> ~/.bashrc && \
echo "set +e" >> ~/.bashrc
CMD ["/usr/bin/bash"]
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,32 @@ Replace ``ur10`` with the model of your choice ``[ur3,ur3e,ur5,ur5e,ur10,ur10e,u

## Start MoveIt Studio

``docker compose up``
``docker compose up``

## Using a custom Docker overlay image

### Release image

To build:

``docker compose -f docker-compose-overlay.yaml build``

To start:

``docker compose -f docker-compose-overlay.yaml up``

### Developer container

We use Docker profiles to have separate configuration for developers.

To build:

``docker compose -f docker-compose-overlay.yaml build dev``

To start:

``docker compose -f docker-compose-overlay.yaml up dev``

And in a new Terminal, you can access a dev shell:

``docker compose exec -it dev bash``
68 changes: 68 additions & 0 deletions docker-compose-overlay.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
version: "3.9"
services:
base:
extends:
file: docker-compose.yaml
service: base
# Optionally allow building this service from source with `docker compose build`
build:
context: .
target: release
sea-bass marked this conversation as resolved.
Show resolved Hide resolved
args:
MOVEIT_STUDIO_BASE_IMAGE: ghcr.io/picknikrobotics/moveit-studio:${STUDIO_DOCKER_TAG:-main}
command: sleep infinity

# Extend all the services from the base image
workspace_builder:
extends:
file: docker-compose.yaml
service: workspace_builder
workspace_test:
extends:
file: docker-compose.yaml
service: workspace_test
agent:
extends:
file: docker-compose.yaml
service: agent
bridge:
extends:
file: docker-compose.yaml
service: bridge
rest_api:
extends:
file: docker-compose.yaml
service: rest_api
drivers:
extends:
file: docker-compose.yaml
service: drivers

#####################################
# Developer specific configuration
# Uses the "dev" profile
#####################################
dev:
extends: base
build:
target: dev
# This image deliberately has no user prefix because it should not be pushed!
stdin_open: true
tty: true
privileged: true
# Allows use of gdbserver
security_opt:
- seccomp:unconfined
volumes:
- ${HOME}/.ros/log_moveit_studio:/root/.ros/log:/root/.ros/log
# Mount source code
- ./src/:/opt/custom_ws/src/:rw
MikeWrock marked this conversation as resolved.
Show resolved Hide resolved
# Mount anonymous volumes to build cache and artifacts
- /opt/custom_ws/build
- /opt/custom_ws/install
- /opt/custom_ws/log
- /root/.ccache
# Allow access to host hardware e.g. RealSense cameras
- /dev:/dev
command: sleep infinity
profiles: ["dev"]
13 changes: 0 additions & 13 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,18 @@ services:
# Allow the user to run graphical programs from within the docker container.
- /tmp/.X11-unix:/tmp/.X11-unix:ro
- ${XAUTHORITY:-$HOME/.Xauthority}:/root/.Xauthority
# Persist Ignition model download cache
- ignition_resources:/root/.ignition/
# Mount the host's DDS config(s) so we can talk to user's ROS tooling
- ${CYCLONEDDS_URI:-/dev/null}:/root/.ros/cyclonedds_host.xml
- ${FASTRTPS_DEFAULT_PROFILES_FILE:-/dev/null}:/root/.ros/fastdds_host.xml

workspace_builder:
container_name: "moveit_studio_workspace_builder"
extends: base
depends_on:
base:
condition: service_completed_successfully
command: bash -c "source /build_user_ws.sh"

workspace_test:
container_name: "moveit_studio_workspace_test"
extends: base
depends_on:
workspace_builder:
Expand All @@ -88,7 +84,6 @@ services:

# Starts the MoveIt Studio Agent
agent:
container_name: "moveit_studio"
extends: base
privileged: true
device_cgroup_rules:
Expand All @@ -109,7 +104,6 @@ services:

# Starts the Bridge between the Agent and the Web UI
bridge:
container_name: "moveit_studio_bridge"
extends: base
depends_on:
workspace_builder:
Expand All @@ -121,7 +115,6 @@ services:

# Starts the frontend-agent
frontend_agent:
container_name: "moveit_studio_frontend"
extends: base
depends_on:
workspace_builder:
Expand All @@ -130,7 +123,6 @@ services:

# Starts the REST API for the Web UI
rest_api:
container_name: "moveit_studio_rest_api"
extends: base
environment:
- LOG_LEVEL=DEBUG
Expand All @@ -146,7 +138,6 @@ services:

# Starts the robot drivers
drivers:
container_name: "moveit_studio_drivers"
extends: base
privileged: true
devices:
Expand All @@ -158,7 +149,6 @@ services:
command: bash -c "ros2 launch moveit_studio_agent robot_drivers_wrapper.launch.py 2>&1 | tee ~/.ros/log/robot_0_0.log"

web_ui:
container_name: "moveit_studio_web_ui"
image: ghcr.io/picknikrobotics/moveit-studio-frontend:${STUDIO_DOCKER_TAG:-main}
ports:
- "80:80"
Expand All @@ -170,6 +160,3 @@ services:
depends_on:
base:
condition: service_completed_successfully

volumes:
ignition_resources: