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

Update docker #103

Merged
merged 1 commit into from
May 8, 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
67 changes: 36 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
ARG ros_distro=noetic
FROM ros:${ros_distro}-ros-base

SHELL ["/bin/bash", "-c"]

ENV DEBIAN_FRONTEND noninteractive

# ROS setting
ARG ros_distro
ENV ROS_DISTRO=${ros_distro}
RUN mkdir -p catkin_ws/src

RUN cd catkin_ws/src && \
source /opt/ros/${ROS_DISTRO}/setup.bash && \
catkin_init_workspace

COPY . /root/catkin_ws/src/repo

RUN cd /root/catkin_ws && \
apt-get update && \
rosdep update && \
rosdep install -i -r -y --from-paths src && \
source /opt/ros/${ROS_DISTRO}/setup.bash && \
catkin_make -DCMAKE_BUILD_TYPE=Release

RUN echo 'source /opt/ros/${ROS_DISTRO}/setup.bash && source /root/catkin_ws/devel/setup.bash && exec "$@"' \
> /root/ros_entrypoint.sh

WORKDIR /root/catkin_ws

ENTRYPOINT ["bash", "/root/ros_entrypoint.sh"]
ARG ROS_DISTRO=noetic
FROM ros:${ROS_DISTRO}
ARG USERNAME=user
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

RUN groupadd --gid ${USER_GID} ${USERNAME} \
&& useradd --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME} \
&& apt-get update \
&& apt-get install -y sudo git vim \
&& echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} \
&& chmod 0440 /etc/sudoers.d/${USERNAME}
RUN apt-get update && apt-get upgrade -y
RUN apt-get update && apt-get install -y --no-install-recommends \
ros-${ROS_DISTRO}-desktop \
python3-catkin-tools \
python3-vcstool \
ros-${ROS_DISTRO}-gazebo-ros-pkgs
RUN rm -rf /var/lib/apt/lists/*
RUN rm /etc/apt/apt.conf.d/docker-clean

# install and build
USER ${USERNAME}
RUN mkdir -p ~/ws/src
WORKDIR /home/${USERNAME}/ws/src
RUN git clone https://github.com/amslabtech/dwa_planner.git \
&& git clone -b ${ROS_DISTRO}-devel https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git \
&& git clone -b ${ROS_DISTRO}-devel https://github.com/ROBOTIS-GIT/turtlebot3.git \
&& git clone -b ${ROS_DISTRO}-devel https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
WORKDIR /home/${USERNAME}/ws
RUN sudo apt-get update && rosdep update && rosdep install -riy --from-paths src --rosdistro ${ROS_DISTRO}
RUN /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash && catkin build -DCMAKE_BUILD_TYPE=Release"

CMD ["/bin/bash"]
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "3.9"

services:
demo:
container_name: dwa_planner
build:
context: .
dockerfile: Dockerfile
tty: true
environment:
DISPLAY: $DISPLAY
TURTLEBOT3_MODEL: burger
volumes:
- type: bind
source: /tmp/.X11-unix
target: /tmp/.X11-unix
command: /bin/bash -c "source /opt/ros/noetic/setup.bash && source ~/ws/devel/setup.bash && roslaunch dwa_planner demo.launch"
Loading