-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathDockerfile
86 lines (70 loc) · 2.98 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
FROM ros:humble-ros-base-jammy
# we want the familiar bash for everything, not sh.
# this makes source-ing work
SHELL ["/bin/bash", "-c"]
# this allows the containers to connect to the host ros2
# use --network=host --ipc=host --pid=host with run
# and export ROS_DOMAIN_ID=42 on the host
ENV ROS_DOMAIN_ID 42
ENV ROS_LOCALHOST_ONLY 0
ENV RMW_IMPLEMENTATION=rmw_fastrtps_cpp
# update things
RUN apt update && apt upgrade -y \
# package managers and such...
&& apt install -y python3-pip apt-utils ros-dev-tools unzip \
# this version of setuptools doesn't have the annoying warnings...
&& pip install --no-input setuptools==58.2.0
# create a non-root user for most things, including ros2
# use --build-arg UID=${id -u} etc to transfer host ids/name into the container!
ARG UID=1000
ARG GID=1000
ARG USERNAME=smarc2user
RUN adduser --quiet --disabled-password --gecos '' --uid ${UID:=1000} --uid ${GID:=1000} ${USERNAME}
WORKDIR /home/${USERNAME}
# clone the base smarc2 dir and make the colcon ws while at it
RUN mkdir -p colcon_ws/src/smarc2
# copy everything in the smarc2 folder, _except the unity sim projects_, into the container
# the "except" part is defined in the .dockerignore file!
COPY . colcon_ws/src/smarc2/
# make colcon behave by adding this defaults file
RUN mkdir .colcon/ \
&& echo "{ \
"build": { \
"symlink-install": true, \
"build-base": "/home/${USERNAME}/colcon_ws/build", \
"install-base": "/home/${USERNAME}/colcon_ws/install", \
"log-base": "/home/${USERNAME}/colcon_ws/log", \
"base-paths": ["/home/${USERNAME}/colcon_ws/src"] \
}, \
"test": { \
"build-base": "/home/${USERNAME}/colcon_ws/build", \
"install-base": "/home/${USERNAME}/colcon_ws/install", \
"log-base": "/home/${USERNAME}/colcon_ws/log", \
"event-handlers": ["console_direct+"], \
"base-paths": ["/home/${USERNAME}/colcon_ws/src"], \
} \
}" > .colcon/defaults.yaml
WORKDIR /home/${USERNAME}/colcon_ws/src/smarc2
# get the submodules needed for core
RUN scripts/get-submodules.sh external_packages
# get the latest compiled binary of the unity sim
# RUN mkdir -p simulation/binaries \
# && cd simulation/binaries \
# && ../../scripts/get_latest_unity_standard.sh
# Disabled until we actually have tests that use this stuff
# install deps
WORKDIR /home/${USERNAME}/colcon_ws
RUN rosdep update \
&& ./src/smarc2/scripts/rosdep_install_from_src.sh \
# no bashrc in dockerfiles, so we source and build in the same run
&& source /opt/ros/humble/setup.bash \
&& colcon build \
# add the source directives into the users bashrc
&& echo "source /opt/ros/humble/setup.bash" >> /home/${USERNAME}/.bashrc \
&& echo "source /home/${USERNAME}/colcon_ws/install/setup.bash" >> /home/${USERNAME}/.bashrc \
# make everything we installed into the user's home directory
# actually owned by the user...
&& chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}
# finally switch to the user we created for normal use
USER ${USERNAME}
ENTRYPOINT ["/bin/bash"]