Skip to content

Commit 04f36d6

Browse files
authored
Update Dockerfile (#127)
1 parent 3b8efc3 commit 04f36d6

File tree

1 file changed

+18
-96
lines changed

1 file changed

+18
-96
lines changed

Dockerfile

Lines changed: 18 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,25 @@
1-
# This dockerfile can be configured via --build-arg
2-
# Build context must be the /ros2_rust root folder for COPY.
3-
# Example build command:
4-
# export OVERLAY_MIXINS="debug ccache coverage"
5-
# export RUN_TESTS="true"
6-
# docker build -t nav2:latest \
7-
# --build-arg OVERLAY_MIXINS \
8-
# --build-arg RUN_TESTS
9-
# --pull ./
10-
#
11-
# If you prefer to use Rolling, just add the following build args:
12-
# --build-arg FROM_IMAGE=ros:rolling
13-
# --build-arg REPOS_FILE=ros2_rust_rolling.repos
14-
15-
ARG FROM_IMAGE=ros:foxy
16-
ARG OVERLAY_WS=/opt/overlay_ws
17-
ARG REPOS_FILE=ros2_rust_foxy.repos
18-
19-
# multi-stage for caching
20-
FROM $FROM_IMAGE AS cacher
21-
22-
# clone overlay source
23-
ARG OVERLAY_WS
24-
ARG REPOS_FILE
25-
WORKDIR $OVERLAY_WS/src
26-
COPY ./${REPOS_FILE} ../
27-
RUN vcs import ./ < ../${REPOS_FILE} && \
28-
find ./ -name ".git" | xargs rm -rf
29-
COPY ./ ./ros2-rust/ros2_rust
30-
31-
# copy manifests for caching
32-
WORKDIR /opt
33-
RUN mkdir -p /tmp/opt && \
34-
find ./ -name "package.xml" | \
35-
xargs cp --parents -t /tmp/opt && \
36-
find ./ -name "COLCON_IGNORE" | \
37-
xargs cp --parents -t /tmp/opt || true
38-
39-
# multi-stage for building
40-
FROM $FROM_IMAGE AS builder
1+
FROM ros:foxy as base
412
ARG DEBIAN_FRONTEND=noninteractive
423

43-
# install CI dependencies
44-
RUN apt-get update && apt-get install -q -y \
45-
ccache \
46-
clang \
47-
lcov \
48-
libclang-dev \
49-
llvm-dev \
50-
wget \
4+
# Install dependencies
5+
RUN apt-get update && apt-get install -y \
6+
clang \
7+
curl \
8+
git \
9+
libclang-dev \
10+
tmux \
11+
python3-pip \
5112
&& rm -rf /var/lib/apt/lists/*
5213

53-
# install rust dependencies
54-
ENV RUSTUP_HOME=/usr/local/rustup \
55-
CARGO_HOME=/usr/local/cargo \
56-
PATH=/usr/local/cargo/bin:$PATH \
57-
RUST_VERSION=1.58.0
58-
RUN set -eux; \
59-
wget -O rustup-init "https://sh.rustup.rs"; \
60-
chmod +x rustup-init; \
61-
./rustup-init -y \
62-
--no-modify-path \
63-
--default-toolchain $RUST_VERSION; \
64-
rm rustup-init; \
65-
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
66-
rustup --version; \
67-
cargo --version; \
68-
rustc --version;
69-
70-
# install overlay dependencies
71-
ARG OVERLAY_WS
72-
WORKDIR $OVERLAY_WS
73-
COPY --from=cacher /tmp/$OVERLAY_WS ./
74-
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
75-
apt-get update && rosdep install -q -y \
76-
--from-paths src \
77-
--ignore-src \
78-
&& rm -rf /var/lib/apt/lists/*
14+
# Install Rust and the cargo-ament-build plugin
15+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain 1.59.0 -y
16+
ENV PATH=/root/.cargo/bin:$PATH
17+
RUN cargo install cargo-ament-build
7918

80-
# build overlay source
81-
COPY --from=cacher $OVERLAY_WS ./
82-
ARG OVERLAY_MIXINS="release ccache"
83-
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
84-
colcon build \
85-
--symlink-install \
86-
--mixin $OVERLAY_MIXINS \
87-
|| ([ -z "$FAIL_ON_BUILD_FAILURE" ] || exit 1)
19+
RUN pip install --upgrade pytest
8820

89-
# source overlay from entrypoint
90-
ENV OVERLAY_WS $OVERLAY_WS
91-
RUN sed --in-place \
92-
's|^source .*|source "$OVERLAY_WS/install/setup.bash"|' \
93-
/ros_entrypoint.sh
21+
# Install the colcon-cargo and colcon-ros-cargo plugins
22+
RUN pip install git+https://github.com/colcon/colcon-cargo.git git+https://github.com/colcon/colcon-ros-cargo.git
9423

95-
# test overlay build
96-
ARG RUN_TESTS
97-
ARG FAIL_ON_TEST_FAILURE=True
98-
RUN if [ -n "$RUN_TESTS" ]; then \
99-
. install/setup.sh && \
100-
colcon test && \
101-
colcon test-result \
102-
|| ([ -z "$FAIL_ON_TEST_FAILURE" ] || exit 1) \
103-
fi
24+
RUN mkdir -p /workspace && echo "Did you forget to mount the repository into the Docker container?" > /workspace/HELLO.txt
25+
WORKDIR /workspace

0 commit comments

Comments
 (0)