Skip to content

Commit 0a7a75a

Browse files
committed
Docker for ubuntu
Signed-off-by: Piotr Jaroszek <[email protected]>
1 parent 9ac12ac commit 0a7a75a

File tree

7 files changed

+116
-1
lines changed

7 files changed

+116
-1
lines changed

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ done
5353

5454
if [ $CLEAN_INSTALL == 1 ]; then
5555
echo "Cleaning install directory..."
56-
rm -rf "$SCRIPTPATH/install"
56+
rm -rf $SCRIPTPATH/install/*
5757
fi
5858
if $SCRIPTPATH/src/ros2cs/build.sh $OPTIONS; then
5959
mkdir -p $SCRIPTPATH/install/asset && cp -R $SCRIPTPATH/src/Ros2ForUnity $SCRIPTPATH/install/asset/Ros2ForUnity

docker/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
ARG ROS2_DISTRO=foxy
2+
FROM ros:${ROS2_DISTRO}-ros-base
3+
4+
RUN apt update && apt install -y ros-foxy-test-msgs ros-foxy-fastrtps ros-foxy-rmw-fastrtps-cpp ros-foxy-cyclonedds ros-foxy-rmw-cyclonedds-cpp
5+
6+
RUN apt update && apt install -y curl wget git
7+
8+
RUN curl -s https://packagecloud.io/install/repositories/dirk-thomas/vcstool/script.deb.sh | sudo bash
9+
RUN apt update && apt install -y python3-vcstool
10+
11+
RUN wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
12+
RUN dpkg -i packages-microsoft-prod.deb
13+
RUN apt update && apt install -y apt-transport-https dotnet-sdk-3.1
14+
15+
ADD entrypoint.sh /entrypoint.sh
16+
RUN chmod +x /entrypoint.sh
17+
18+
RUN mkdir -p /workdir/ros2-for-unity
19+
RUN chmod -R 777 /workdir
20+
RUN chmod -R 777 /home
21+
22+
ENTRYPOINT [ "/entrypoint.sh" ]

docker/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Ros2 For Unity Docker
2+
===============
3+
4+
Currently only building asset on Ubuntu is supported. Build windows version is not supported.
5+
6+
## Build docker image
7+
8+
1. Source ROS2 (foxy or galactic):
9+
10+
```bash
11+
. /opt/ros/<ROS_DISTRO>/setup.bash
12+
```
13+
14+
2. Build image - image will be based on sourced ROS2 version:
15+
16+
```bash
17+
./build_image.sh
18+
```
19+
20+
## Using docker container
21+
22+
1. Run docker container. Container will fetch `master` version of `ros2-for-unity`:
23+
24+
```bash
25+
./run_container.sh
26+
```
27+
28+
2. Build asset. `./run_container.sh` script mounts `install` host directory inside docker, so you can find install results on host machine:
29+
30+
```bash
31+
./build.sh --with-tests
32+
```
33+
34+
## Adding custom messages
35+
36+
You can add custom messages by putting them inside `docker/custom_messages` folder or just simply `git clone` them inside docker containers `/workdir/ros2-for-unity/src/ros2cs/src/custom_messages`

docker/build_image.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
if [ -z "$ROS_DISTRO" ]; then
4+
echo "Source your ros2 distro first."
5+
exit 1
6+
fi
7+
8+
docker build . --build-arg ROS2_DISTRO=$ROS_DISTRO --tag ros2-for-unity

docker/custom_messages/INSERT_CUSTOM_MESSAGES_HERE

Whitespace-only changes.

docker/entrypoint.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
source "/opt/ros/$ROS_DISTRO/setup.bash"
4+
5+
echo "######################################################################"
6+
echo ""
7+
echo "Cloning recent version of 'ros2-for-unity'"
8+
echo ""
9+
echo "######################################################################"
10+
echo ""
11+
12+
git clone https://github.com/RobotecAI/ros2-for-unity.git /workdir/.ros2-for-unity
13+
14+
shopt -s dotglob
15+
mkdir -p /workdir/ros2-for-unity
16+
mv /workdir/.ros2-for-unity/* /workdir/ros2-for-unity
17+
cd /workdir/ros2-for-unity/ && ./pull_repositories.sh
18+
shopt -u dotglob
19+
20+
ln -s /workdir/custom_messages /workdir/ros2-for-unity/src/ros2cs/src/custom_messages
21+
22+
echo ""
23+
echo "######################################################################"
24+
echo ""
25+
echo "Welcome to 'ros2-for-unity' docker container. Your ROS2 distro is $ROS_DISTRO."
26+
echo ""
27+
echo "Type './build.sh' to build 'ros2-for-unity'. You will find installed libs on your host machine inside 'install' directory"
28+
echo ""
29+
echo "######################################################################"
30+
echo ""
31+
32+
exec bash

docker/run_container.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
SCRIPT=$(readlink -f $0)
3+
SCRIPTPATH=`dirname $SCRIPT`
4+
5+
mkdir -p $SCRIPTPATH/../install
6+
docker run \
7+
--rm \
8+
-it \
9+
--name ros2-for-unity \
10+
--user $(id -u):$(id -g) \
11+
-v /etc/passwd:/etc/passwd:ro \
12+
-v /etc/group:/etc/group:ro \
13+
-v /etc/shadow:/etc/shadow:ro \
14+
-v $(pwd)/../install:/workdir/ros2-for-unity/install:rw \
15+
-v $(pwd)/custom_messages:/workdir/custom_messages \
16+
ros2-for-unity \
17+
bash

0 commit comments

Comments
 (0)