Skip to content

Commit

Permalink
Update docker scripts so that CI can run them
Browse files Browse the repository at this point in the history
  • Loading branch information
katie-hughes committed Sep 6, 2024
1 parent c6e26cf commit 83b266a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions spaceros_gz_demos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ This package is built upon the base Space ROS docker image, with a few extra ins

One time setup: If you don't have Docker, install it with `sudo apt install docker.io`. You will have to add yourself to the Docker user group with `sudo usermod -aG docker $USER`, then run `newgrp docker` to avoid permission errors with Docker daemon. You will also to run `xhost +local:docker` on your first time to allow Docker to connect to gui-based application such as Gazebo and RViz. You will need to log out and log back in for these changes to take effect on your system.

1. Navigate to the `spaceros_gz_demos/docker` directory.
1. Navigate to the root `demos` directory. (You have to run the scripts from this directory, otherwise the Dockerfile won't be found -- this is needed for CI, which runs from this location.)

2. Build the Docker image locally with

```./build.sh```
```./spaceros_gz_demos/docker/build.sh```

3. Run the Docker container with

```./run.sh```
```./spaceros_gz_demos/docker/run.sh```

4. Once you have a running container, to get another shell, run

```./shell.sh```
```./spaceros_gz_demos/docker/shell.sh```

## Running code in the Docker container
1. Once you are in the Docker container, run `colcon build` (you should be in the `~/spaceros/ws` directory)
Expand Down
7 changes: 5 additions & 2 deletions spaceros_gz_demos/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM osrf/space-ros:latest

# Install Gazebo Harmonic:
# https://gazebosim.org/docs/harmonic/install_ubuntu/#binary-installation-on-ubuntu
RUN sudo apt-get update
RUN sudo apt-get install lsb-release gnupg
Expand All @@ -8,6 +9,7 @@ RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/p
RUN sudo apt-get update
RUN yes | sudo apt-get install gz-harmonic

# Install required packages
RUN sudo apt-get update \
&& sudo apt-get install -y --no-install-recommends \
bash \
Expand All @@ -17,15 +19,16 @@ RUN sudo apt-get update \
git \
python-is-python3 \
python3-pip \
ripgrep \
ros-humble-rviz2 \
ros-humble-ros-gzharmonic \
&& sudo apt-get autoremove -y

# Replace old entrypoint with current entrypoint that extends upon it
# Replace old entrypoint with an entrypoint that extends upon it
# This is necessary as Gazebo Harmonic has been installed as well as some new ROS packages.
RUN sudo mv /ros_entrypoint.sh /old_entrypoint.sh
COPY entrypoint.sh /ros_entrypoint.sh
RUN sudo chmod +x /ros_entrypoint.sh

# Set up workspace
RUN mkdir -p /home/spaceros-user/spaceros/ws/src/spaceros_gz_demos
WORKDIR /home/spaceros-user/spaceros/ws
2 changes: 1 addition & 1 deletion spaceros_gz_demos/docker/build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
echo "Building docker image..."
docker build . --tag "spaceros_gz_demos"
docker build spaceros_gz_demos/docker --tag "spaceros_gz_demos"
2 changes: 1 addition & 1 deletion spaceros_gz_demos/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ docker run -it \
-e ROS_DOMAIN_ID=$ROS_DOMAIN_ID \
-e QT_X11_NO_MITSHM=1 \
--device /dev/dri \
--mount type=bind,source="$(pwd)/../spaceros_gz_demos",target=/home/spaceros-user/spaceros/ws/src/spaceros_gz_demos \
--mount type=bind,source="$(pwd)/spaceros_gz_demos",target=/home/spaceros-user/spaceros/ws/src/spaceros_gz_demos \
spaceros_gz_demos:latest

0 comments on commit 83b266a

Please sign in to comment.