Skip to content

Commit

Permalink
Merge branch 'feat/docker_test' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Bee committed Jul 7, 2023
2 parents 5162bba + 186de55 commit d1b152d
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 18 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,23 @@ $ catkin build

## Isolated Build with Docker

The docker image is published regularly with updates to [Dockerhub](https://hub.docker.com/r/aaucns/mars_ros_test_env).
If you want to build the image yourself, you can do so with

```sh
$ cd mars_ros # Enter the source directory
$ docker build --network=host -t mars_ros_test_env:latest . # Build the Docker image
$ docker build --network=host -t aaucns/mars_ros_test_env:latest . # Build the Docker image
```

Either way, you can then test your MaRS ROS wrapper by executing the following.

```sh
# The following runs the container, maps the source code (read only)
# and executes the script in 'docker/docker_application_test.sh'
$ docker run -it --rm \
--network=host \
-v "$(pwd)":/source:ro \
mars_ros_test_env:latest
aaucns/mars_ros_test_env:latest
```

# Usage
Expand Down
23 changes: 19 additions & 4 deletions docker/docker_application_test.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
#!/bin/bash -e
echo "Copy Source Files..."
cp -r /source/ /catkin_ws/src/mars_ros
echo "Building the Appliaction..."
cd /catkin_ws
echo "Copyiing Source Files..."
cp -r /source/ /catkin_build_ws/src/mars_ros
cp -r /source/ /catkin_make_ws/src/mars_ros

# build with catkin build
echo "Building the Appliaction with 'catkin build' ..."
cd /catkin_build_ws
catkin build -DCMAKE_BUILD_TYPE=Release
catkin build -DCMAKE_BUILD_TYPE=Debug
echo "Building the Appliaction with 'catkin build' - DONE"
# clean workspace to free up used disk space
catkin clean -y
rm -rf .catkin_tools

# build with catkin_make
echo "Building the Appliaction with 'catkin_make' ..."
cd /catkin_make_ws
catkin_make -DCMAKE_BUILD_TYPE=Release
catkin_make -DCMAKE_BUILD_TYPE=Debug
echo "Building the Appliaction with 'catkin_make' - DONE"
# clean workspace to free up used disk space
rm -rf build develop
43 changes: 31 additions & 12 deletions docker/dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,50 @@
FROM ros:noetic-ros-core
# Copyright (C) 2022 Christian Brommer and Martin Scheiber,
# Control of Networked Systems, University of Klagenfurt, Austria.
#
# All rights reserved.
#
# This software is licensed under the terms of the BSD-2-Clause-License with
# no commercial use allowed, the full terms of which are made available
# in the LICENSE file. No license in patents is granted.
#
# You can contact the author at <christian.brommer@ieee.org>
# and <martin.scheiber@ieee.org>.

FROM ros:noetic-ros-core as stage1
LABEL author="Christian Brommer <christian.brommer@aau.at>"
LABEL author="Martin Scheiber <martin.scheiber@aau.at>"
LABEL maintainer="Christian Brommer <christian.brommer@aau.at>"
LABEL description="Mars Ros Wrapper Test Environment"

ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install --no-install-recommends -y \
vim \
wget \
doxygen \
graphviz \
build-essential \
&& rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install --no-install-recommends -y \
libeigen3-dev \
&& rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install --no-install-recommends -y \
python3-catkin-tools \
ros-noetic-dynamic-reconfigure \
ros-noetic-tf2-ros \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /catkin_build_ws/src \
&& mkdir -p /catkin_make_ws/src

RUN mkdir -p /catkin_ws/src
WORKDIR /catkin_ws
RUN /bin/bash -c '. /opt/ros/noetic/setup.bash; catkin build'
WORKDIR /catkin_build_ws
RUN /bin/bash -c "source /opt/ros/noetic/setup.sh; rosdep init && rosdep update; \
source /opt/ros/noetic/setup.sh; catkin init; catkin config --extend /opt/ros/noetic; \
source /opt/ros/noetic/setup.sh; catkin build;"

WORKDIR /catkin_make_ws
RUN /bin/bash -c "source /opt/ros/noetic/setup.sh; catkin_make;"

COPY ./docker_application_test.sh /

# flatten image
FROM scratch as final
COPY --from=stage1 / /

ENTRYPOINT ["/bin/bash"]
CMD /docker_application_test.sh

0 comments on commit d1b152d

Please sign in to comment.