Skip to content

Commit 79ac41c

Browse files
committed
refactor(template_ws): Change gazebo cache directory to volume mount
Fixes: #31
1 parent f439bf4 commit 79ac41c

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

scripts/create_workspace.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ cp -r "${TEMPLATE_WS_DIR}" "${NEW_WS_DIR}"
3535
rm -rf "${NEW_WS_DIR}/.vscode"
3636
rm -rf "${NEW_WS_DIR}/build" "${NEW_WS_DIR}/install" "${NEW_WS_DIR}/log"
3737
rm -rf "${NEW_WS_DIR}/README.md"
38-
rm -rf "${NEW_WS_DIR}/docker/cache/.gazebo/*"
39-
touch "${NEW_WS_DIR}/docker/cache/.gazebo/.gitkeep"
4038
echo "# ${NEW_WS_NAME_UNDERSCORE}" > "${NEW_WS_DIR}/README.md"
4139

4240
# Replace the "template_ws" with new workspace name in each file.

template_ws/docker/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ RUN --mount=type=cache,target=/var/cache/apt \
5757

5858
# TODO: Add more commands here
5959

60-
COPY .bashrc /home/$USERNAME/.bashrc
61-
6260
USER $USERNAME
61+
COPY .bashrc /home/$USERNAME/.bashrc
62+
# Create Gazebo cache directory with correct ownership to avoid permission issues after volume mount
63+
RUN mkdir /home/$USERNAME/.gazebo
6364
ENTRYPOINT []
6465
CMD ["/bin/bash"]

template_ws/docker/cache/.gazebo/.gitkeep

Whitespace-only changes.

template_ws/docker/compose.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ services:
5151
# - /dev:/dev
5252
# Mount Gazebo models directory to reuse models downloaded during first launch.
5353
# Reference: https://answers.ros.org/question/365658
54-
- ./cache/.gazebo:/home/user/.gazebo
54+
# Note that this volume is shared among all workspaces.
55+
- gazebo-cache:/home/user/.gazebo
5556
# Mount root workspace to allow easy access to all workspaces.
5657
- ../..:/home/ros2-essentials
58+
volumes:
59+
gazebo-cache:
60+
name: ros2-gazebo-cache

0 commit comments

Comments
 (0)