-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af38697
commit 0141277
Showing
4 changed files
with
111 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
ARG ROS_DISTRO=humble | ||
FROM ros:$ROS_DISTRO AS base | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
# Install dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
curl \ | ||
git \ | ||
libclang-dev \ | ||
tmux \ | ||
htop \ | ||
vim \ | ||
python3-pip \ | ||
python3-vcstool \ | ||
bash-completion | ||
|
||
ARG USERNAME=developer | ||
ARG USER_UID=1000 | ||
ARG USER_GID=$USER_UID | ||
|
||
# Create the user | ||
RUN groupadd --gid "$USER_GID" "$USERNAME" \ | ||
&& useradd --uid "$USER_UID" --gid "$USER_GID" -m "$USERNAME" \ | ||
# Add sudo support | ||
&& apt-get update \ | ||
&& apt-get install -y sudo \ | ||
&& echo "$USERNAME" ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/"$USERNAME" \ | ||
&& chmod 0440 /etc/sudoers.d/"$USERNAME" | ||
|
||
USER $USERNAME | ||
|
||
# Install Rust and the cargo-ament-build plugin | ||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain 1.74.0 -y | ||
ENV PATH=/home/$USERNAME/.cargo/bin:$PATH | ||
RUN cargo install cargo-ament-build | ||
# Install autocompletion for rustup and cargo | ||
RUN mkdir -p ~/.local/share/bash-completion/completions | ||
RUN rustup completions bash >> ~/.local/share/bash-completion/completions/rustup | ||
RUN rustup completions bash cargo >> ~/.local/share/bash-completion/completions/cargo | ||
|
||
# Install the colcon-cargo and colcon-ros-cargo plugins | ||
RUN pip install git+https://github.com/colcon/colcon-cargo.git git+https://github.com/colcon/colcon-ros-cargo.git | ||
|
||
# Install ros2_rust and its dependencies | ||
RUN mkdir -p /home/"$USERNAME"/ros_deps/src | ||
WORKDIR /home/$USERNAME/ros_deps | ||
RUN git clone https://github.com/ros2-rust/ros2_rust.git src/ros2_rust | ||
RUN vcs import src < src/ros2_rust/ros2_rust_humble.repos | ||
RUN . /opt/ros/humble/setup.sh && colcon build | ||
|
||
RUN echo "source /opt/ros/humble/setup.sh" >> /home/"$USERNAME"/.bashrc | ||
RUN echo "source ~/ros_deps/install/setup.sh" >> /home/"$USERNAME"/.bashrc | ||
|
||
ENV CARGO_TERM_COLOR=always | ||
ENV SHELL /bin/bash | ||
|
||
RUN mkdir -p /home/"$USERNAME"/workspace | ||
WORKDIR /home/$USERNAME/workspace | ||
|
||
COPY --chmod=777 .devcontainer/entrypoint /usr/local/bin/ | ||
|
||
ENTRYPOINT ["bash", "entrypoint"] | ||
CMD ["/bin/bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "ROS2 Rust Dev Container", | ||
"remoteUser": "developer", | ||
"build": { | ||
"context": "..", | ||
"dockerfile": "Dockerfile" | ||
}, | ||
"workspaceMount": "source=${localWorkspaceFolder},target=/home/developer/workspace,type=bind", | ||
"workspaceFolder": "/home/developer/workspace", | ||
"overrideCommand": true, | ||
"postStartCommand": "entrypoint", | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"rust-lang.rust-analyzer" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
# Build the package mounted in the container | ||
echo "Building workspace with colcon" | ||
. /opt/ros/humble/setup.sh && . ~/ros_deps/install/setup.sh && colcon build | ||
echo "source ~/workspace/install/setup.sh" >> ~/.bashrc | ||
|
||
# Run the CMD (either the default from the Dockerfile or the one provided as docker run argument) | ||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters