hc
2023-05-26 a23f51ed7a39e452c1037343a84d7db1ca2c5bd7
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# This file describes an image that has everything necessary installed to build a target ROS workspace
# It uses QEmu user-mode emulation to perform dependency installation and build
# Assumptions: qemu-user-static directory is present in docker build context
 
ARG BASE_IMAGE
FROM ${BASE_IMAGE}
 
ARG ROS_VERSION
ARG ROS_DISTRO
 
SHELL ["/bin/bash", "-c"]
 
# Set timezone
RUN echo 'Etc/UTC' > /etc/timezone && \
    ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime
 
RUN apt-get update && apt-get install --no-install-recommends -y \
        tzdata \
        locales \
        vim \
    && rm -rf /var/lib/apt/lists/*
 
# Set locale
RUN echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen && \
    locale-gen && \
    update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LC_ALL C.UTF-8
 
# Add the ros apt repo
RUN apt-get update && apt-get install --no-install-recommends -y \
        ca-certificates \
        curl wget git \
        dirmngr \
        gnupg2 \
        lsb-release \
    && rm -rf /var/lib/apt/lists/*
RUN if [[ "${ROS_VERSION}" == "ros2" ]]; then \
      curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg; \
      echo "deb [signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/${ROS_VERSION}/ubuntu `lsb_release -cs` main" | \
          tee /etc/apt/sources.list.d/ros2.list > /dev/null; \
    else \
      curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add - ; \
      echo "deb http://packages.ros.org/${ROS_VERSION}/ubuntu `lsb_release -cs` main" \
          > /etc/apt/sources.list.d/${ROS_VERSION}-latest.list; \
    fi
 
# ROS dependencies
RUN apt-get update && apt-get install --no-install-recommends -y \
      build-essential \
      cmake libpcre2-dev \
      python3-colcon-common-extensions \
      python3-colcon-mixin \
      python3-dev \
      python3-pip \
      python3-lark-parser \
    && rm -rf /var/lib/apt/lists/*
 
RUN python3 -m pip install -U \
    setuptools
 
# Install some pip packages needed for testing ROS 2
RUN if [[ "${ROS_VERSION}" == "ros2" ]]; then \
    python3 -m pip install -U \
    flake8 \
    flake8-blind-except \
    flake8-builtins \
    flake8-class-newline \
    flake8-comprehensions \
    flake8-deprecated \
    flake8-docstrings \
    flake8-import-order \
    flake8-quotes \
    pytest-repeat \
    pytest-rerunfailures \
    pytest \
    pytest-cov \
    pytest-runner \
  ; fi
 
# Install Fast-RTPS dependencies for ROS 2
RUN if [[ "${ROS_VERSION}" == "ros2" ]]; then \
    apt-get update && apt-get install --no-install-recommends -y \
        libasio-dev \
        libtinyxml2-dev \
    && rm -rf /var/lib/apt/lists/* \
  ; fi
 
RUN python3 -m pip install -U vcstool colcon-common-extensions numpy
 
# Run arbitrary user setup (copy data and run script)
# COPY user-custom-data/ custom-data/
# COPY user-custom-setup .
# RUN chmod +x ./user-custom-setup && \
#    ./user-custom-setup && \
#    rm -rf /var/lib/apt/lists/*
 
# mixins defines building environments
COPY mixins /root
RUN mkdir -p /buildroot /opt/ros/${ROS_DISTRO}/src
 
WORKDIR /opt/ros/${ROS_DISTRO}
 
# Disable packages
#  - rviz, X11/desktop required, if you want rviz, trying arm Ubuntu 18.04
#  - turtlesim, QT5 required
RUN wget https://raw.githubusercontent.com/ros2/ros2/${ROS_DISTRO}/ros2.repos && \
    vcs-import src < ros2.repos
 
RUN git clone https://github.com/ros2/cross_compile.git -b 0.9.0 /tmp/cross_compile && \
    cp /tmp/cross_compile/ros_cross_compile/qemu/qemu-aarch64-static /usr/bin && \
    cp /tmp/cross_compile/ros_cross_compile/qemu/qemu-arm-static /usr/bin && \
    rm -rf /tmp/cross_compile
 
RUN if [[ -e src/ros-visualization ]]; then \
    touch src/ros-visualization/COLCON_IGNORE ; \
    echo "IGNORE ros-visualization"; \
    fi
RUN if [[ -e src/ros2/rviz ]]; then \
    touch src/ros2/rviz/COLCON_IGNORE ; \
    echo "IGNORE ros2/rviz"; \
    fi
RUN if [[ -e src/ros/ros_tutorials/turtlesim ]]; then \
    touch src/ros/ros_tutorials/turtlesim/COLCON_IGNORE;  \
    echo "IGNORE ros_tutorials/turtlesim"; \
    fi
RUN if [[ -e src/eclipse-iceoryx ]]; then \
    touch src/eclipse-iceoryx/COLCON_IGNORE; \
    echo "IGNORE eclipse-iceoryx"; \
    fi
RUN if [[ -e src/eclipse-cyclonedds ]]; then \
    touch src/eclipse-cyclonedds/COLCON_IGNORE; \
    echo "IGNORE eclipse-cyclonedds"; \
    fi
 
COPY build_ros2.sh /opt/ros/${ROS_DISTRO}
RUN ln -s /opt/ros/${ROS_DISTRO}/build_ros2.sh /root
RUN sed -i "s/^ROS_DISTRO=.*$/ROS_DISTRO=${ROS_DISTRO}/" /root/build_ros2.sh
 
ENTRYPOINT ["/root/build_ros2.sh"]