jetson-containers
jetson-containers copied to clipboard
Help needed with custom docker image based on dustynv/ros:humble-ros-base-l4t-r32.7.1
I am working on building a custom docker image deployable to a Jetson nano. At the moment I am simply copying the src folder of the ros workspace and hope to build (including colcon build) it before pushing to the docker hub, so that i can simply pull on jetson nano side. Please help me to figure out what I am doing wrong. At the moment, ros_entrypoint.sh is as follows,
#!/bin/bash
set -e
ros_env_setup="/opt/ros/$ROS_DISTRO/setup.bash"
catkin_env_setup="$WORKSPACE/install/setup.bash"
echo "sourcing $ros_env_setup"
source "$ros_env_setup"
echo "sourcing $catkin_env_setup"
source "$catkin_env_setup"
echo "ROS_ROOT $ROS_ROOT"
echo "ROS_DISTRO $ROS_DISTRO"
exec "$@"
When i use the following dockerfile,
FROM dustynv/ros:humble-ros-base-l4t-r32.7.1
ENV WORKSPACE=/home/workspace
ENV ROS_VERSION=humble
ENV ROS_ROOT=/opt/ros/${ROS_DISTRO}
WORKDIR /
RUN mkdir -p ${WORKSPACE}/src
COPY ./src ${WORKSPACE}/src
RUN cd ${WORKSPACE} && colcon build
# setup entrypoint
COPY ./ros_entrypoint.sh /ros_entrypoint.sh
RUN echo 'source /opt/ros/${ROS_DISTRO}/setup.bash' >> .bashrc
ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["bash"]
I get following error,
=> ERROR [4/7] RUN cd /home/workspace && colcon build 8.1s
------
> [4/7] RUN cd /home/workspace && colcon build:
3.063 Starting >>> test
7.872 --- stderr: test
7.872 CMake Error at CMakeLists.txt:9 (find_package):
7.872 By not providing "Findament_cmake.cmake" in CMAKE_MODULE_PATH this project
7.872 has asked CMake to find a package configuration file provided by
7.872 "ament_cmake", but CMake did not find one.
7.872
7.872 Could not find a package configuration file provided by "ament_cmake" with
7.872 any of the following names:
7.872
7.872 ament_cmakeConfig.cmake
7.872 ament_cmake-config.cmake
7.872
7.872 Add the installation prefix of "ament_cmake" to CMAKE_PREFIX_PATH or set
7.872 "ament_cmake_DIR" to a directory containing one of the above files. If
7.872 "ament_cmake" provides a separate development package or SDK, be sure it
7.872 has been installed.
7.872
7.872
7.872 ---
7.873 Failed <<< test [4.81s, exited with code 1]
7.971
7.971 Summary: 0 packages finished [5.42s]
7.971 1 package failed: test
7.971 1 package had stderr output: test
------
jetsonnano-humble-darkent-ros.Dockerfile:13
--------------------
11 | COPY ./src ${WORKSPACE}/src
12 |
13 | >>> RUN cd ${WORKSPACE} && colcon build
14 |
15 | # setup entrypoint
--------------------
ERROR: failed to solve: process "/dev/.buildkit_qemu_emulator /bin/bash -c cd ${WORKSPACE} && colcon build" did not complete successfully: exit code: 1
If i change the dockerfile to following,
FROM dustynv/ros:humble-ros-base-l4t-r32.7.1
ENV WORKSPACE=/home/workspace
ENV ROS_VERSION=humble
ENV ROS_ROOT=/opt/ros/${ROS_DISTRO}
WORKDIR /
RUN mkdir -p ${WORKSPACE}/src
COPY ./src ${WORKSPACE}/src
RUN . ${ROS_ROOT}/setup.bash \
&& cd ${WORKSPACE} \
&& colcon build
# setup entrypoint
COPY ./ros_entrypoint.sh /ros_entrypoint.sh
RUN echo 'source /opt/ros/${ROS_DISTRO}/setup.bash' >> .bashrc
ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["bash"]
The error changes to following
=> ERROR [4/7] RUN . /opt/ros/humble/setup.bash && cd /home/workspace && colcon build 0.2s
------
> [4/7] RUN . /opt/ros/humble/setup.bash && cd /home/workspace && colcon build:
0.124 /bin/bash: /opt/ros/humble/setup.bash: No such file or directory
------
jetsonnano-humble-darkent-ros.Dockerfile:13
--------------------
12 |
13 | >>> RUN . ${ROS_ROOT}/setup.bash \
14 | >>> && cd ${WORKSPACE} \
15 | >>> && colcon build
16 |
--------------------
ERROR: failed to solve: process "/dev/.buildkit_qemu_emulator /bin/bash -c . ${ROS_ROOT}/setup.bash && cd ${WORKSPACE} && colcon build" did not complete successfully: exit code: 1
If I change the ros_entrypoint.sh to
#!/bin/bash
set -e
ros_env_setup="/opt/ros/$ROS_DISTRO/setup.bash"
catkin_env_setup="$WORKSPACE/install/setup.bash"
echo "sourcing $ros_env_setup"
source "$ros_env_setup"
colcon build
echo "sourcing $catkin_env_setup"
source "$catkin_env_setup"
echo "ROS_ROOT $ROS_ROOT"
echo "ROS_DISTRO $ROS_DISTRO"
exec "$@"
and Dockerfile to
#!/bin/bash
set -e
ros_env_setup="/opt/ros/$ROS_DISTRO/setup.bash"
catkin_env_setup="$WORKSPACE/install/setup.bash"
echo "sourcing $ros_env_setup"
source "$ros_env_setup"
colcon build
echo "sourcing $catkin_env_setup"
source "$catkin_env_setup"
echo "ROS_ROOT $ROS_ROOT"
echo "ROS_DISTRO $ROS_DISTRO"
exec "$@"
It succeeds with following output.
=> [internal] load build definition from jetsonnano-humble-darkent-ros.Dockerfile 0.0s
=> => transferring dockerfile: 448B 0.0s
=> [internal] load metadata for docker.io/dustynv/ros:humble-ros-base-l4t-r32.7.1 0.9s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [1/6] FROM docker.io/dustynv/ros:humble-ros-base-l4t-r32.7.1@sha256:110e55a4671fd90ad47dc1ab19fd67a98c780307e38ba4a4acc3c5efe317adc1 0.0s
=> => resolve docker.io/dustynv/ros:humble-ros-base-l4t-r32.7.1@sha256:110e55a4671fd90ad47dc1ab19fd67a98c780307e38ba4a4acc3c5efe317adc1 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 652B 0.0s
=> CACHED [2/6] RUN mkdir -p /home/workspace/src 0.0s
=> CACHED [3/6] COPY ./src /home/workspace/src 0.0s
=> [4/6] COPY ./ros_entrypoint.sh /ros_entrypoint.sh 0.0s
=> [5/6] RUN echo 'source /opt/ros/${ROS_DISTRO}/setup.bash' >> .bashrc 0.1s
=> exporting to image 8.5s
=> => exporting layers 0.0s
=> => exporting manifest sha256:7c2b6b4c3519bf218bebe90d78431ee4561606dbe4f31f2076d7cf6653d7f279 0.0s
=> => exporting config sha256:306a3fa19427e95c789174f1b5e76f8028addb7227f079ad03f676c120f0d8e1 0.0s
=> => exporting attestation manifest sha256:ce82492198fa30e913e0b6d2f0d67cd95aa187a75e88feaa76701479bbbdcb68 0.0s
=> => exporting manifest list sha256:f20a55374e479ff163ba897d5bfba7fa835067e516632adeded31f061b6b1bdb 0.0s
=> => pushing layers 5.9s
=> => pushing manifest for docker.io/kalanarat/darknet:ros-humble-jetson-nano@sha256:f20a55374e479ff163ba897d5bfba7fa835067e516632adeded31f061b6b1bdb 2.5s
=> [auth] kalanarat/darknet:pull,push token for registry-1.docker.io
But it defeats the purpose of offloading the compiling from the jetson nano i guess. I am attempting to build this via buildx on a amd64 machine.
Is there a way to build this and push to docker hub as i need or, is the last approach only viable?