Skip to content

Commit

Permalink
final steps of the ros image build
Browse files Browse the repository at this point in the history
  • Loading branch information
KalanaRatnayake committed Aug 3, 2024
1 parent 3c8689f commit a45e032
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 83 deletions.
46 changes: 14 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,25 @@ docker buildx create --use --driver-opt network=host --name MultiPlatform --plat

## Docker container list

<details>
<summary> <h3> foxy-base </h3> </summary>

This image is an modified [nvcr.io/nvidia/l4t-base:r32.7.1](https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-base/tags). The image has been modified by upgrading core Ubuntu 18.04 to Ubuntu 20.04.

[dusty-nv/jetson-containers](https://github.com/dusty-nv/jetson-containers) allows building image for Jetson nano but they are based on offical [nvcr.io/nvidia/l4t-base:r32.7.1](https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-base/tags) which is based on Ubuntu 18.04 and is limited by Python 3.6.9.
### 1. Jetson-base

Due to this, being inspired from [Qengineering/Jetson-Nano-Ubuntu-20-image](https://github.com/Qengineering/Jetson-Nano-Ubuntu-20-image) and based on [gpshead/Dockerfile](https://gist.github.com/gpshead/0c3a9e0a7b3e180d108b6f4aef59bc19), this image provides an Ubuntu 20.04 version of [nvcr.io/nvidia/l4t-base:r32.7.1](https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-base/tags)
#### jetson-base:r32.7.1

> Ubuntu 22.04 was also attempted, but later abandoned due to lack of support for gcc-8, g++8 and clang-8 required by CUDA 10.2 in r32.7.1
### Pull or Build

Pull the docker container
```bash
docker pull ghcr.io/kalanaratnayake/foxy-base:r32.7.1
```docker
FROM ghcr.io/kalanaratnayake/jetson-base:r32.7.1
```

or
[Installation and local build instructions for jetson-base:r32.7.1 ](base-images/r3721.md)

Build the docker container
```bash
docker buildx build --load --platform linux/arm64 -f base-images/foxy.Dockerfile -t foxy-base:r32.7.1 .
```
### 2. Jetson-minimal

### Start
#### jetson-minimal:r32.7.1

Start the docker container
```bash
docker run --rm -it --runtime nvidia --network host --gpus all -e DISPLAY ghcr.io/kalanaratnayake/foxy-base:r32.7.1 bash
```
<br>

</details>

<details>
<summary> <h3> Jetson Ubuntu Foxy Minimal Image </h3> </summary>
```docker
FROM ghcr.io/kalanaratnayake/jetson-minimal:r32.7.1
```

- GCC-8, G++-8 for building CUDA 10.2 related applications
- build-essential package (g++-9, gcc-9, make, dpkg-dev, libc6-dev)
Expand Down Expand Up @@ -172,10 +154,10 @@ or build with cache locally and push when image compilation can be slow on githu
```bash
docker buildx build --push \
--platform linux/arm64 \
--cache-from=type=registry,ref=ghcr.io/kalanaratnayake/foxy-ros:humble-ros-base-buildcache \
--cache-to=type=registry,ref=ghcr.io/kalanaratnayake/foxy-ros:humble-ros-base-buildcache,mode=max \
-f ros-images/humble_base.Dockerfile \
-t ghcr.io/kalanaratnayake/foxy-ros:humble-base-r32.7.1 .
--cache-from=type=registry,ref=ghcr.io/kalanaratnayake/jetson-ros:humble-ros-base-r32.7.1-buildcache \
--cache-to=type=registry,ref=ghcr.io/kalanaratnayake/jetson-ros:humble-ros-base-r32.7.1-buildcache,mode=max \
-f ros-images/r3271.humble_base.Dockerfile \
-t ghcr.io/kalanaratnayake/jetson-ros:humble-base-r32.7.1 .
```

### Start
Expand Down
34 changes: 34 additions & 0 deletions base-images/r3721.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## jetson-base:r32.7.1

This image is an modified [nvcr.io/nvidia/l4t-base:r32.7.1](https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-base/tags). The image has been modified by upgrading core Ubuntu 18.04 to Ubuntu 20.04.

[dusty-nv/jetson-containers](https://github.com/dusty-nv/jetson-containers) allows building image for Jetson nano but they are based on offical [nvcr.io/nvidia/l4t-base:r32.7.1](https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-base/tags) which is based on Ubuntu 18.04 and is limited by Python 3.6.9.

Due to this, being inspired from [Qengineering/Jetson-Nano-Ubuntu-20-image](https://github.com/Qengineering/Jetson-Nano-Ubuntu-20-image) and based on [gpshead/Dockerfile](https://gist.github.com/gpshead/0c3a9e0a7b3e180d108b6f4aef59bc19), this image provides an Ubuntu 20.04 version of [nvcr.io/nvidia/l4t-base:r32.7.1](https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-base/tags)

> Ubuntu 22.04 was also attempted, but later abandoned due to lack of support for gcc-8, g++8 and clang-8 required by CUDA 10.2 in r32.7.1
<br>

### Pull or Build

Pull the docker container
```bash
docker pull ghcr.io/kalanaratnayake/jetson-base:r32.7.1
```

or

Build the docker container
```bash
docker buildx build --load --platform linux/arm64 -f base-images/r3271.Dockerfile -t jetson-base:r32.7.1 .
```

<br>

### Start

Start the docker container
```bash
docker run --rm -it --runtime nvidia --network host --gpus all -e DISPLAY ghcr.io/kalanaratnayake/jetson-base:r32.7.1 bash
```
50 changes: 25 additions & 25 deletions ros-images/r3271.humble_base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,48 +105,48 @@ RUN rosdep install -y \
--rosdistro ${ROS_DISTRO} \
--skip-keys "fastcdr rti-connext-dds-6.0.1 urdfdom_headers"

#-------------------------------
# RUN colcon build \
# --merge-install \
# --cmake-args -DCMAKE_BUILD_TYPE=Release

# WORKDIR /
RUN colcon build \
--merge-install \
--cmake-args -DCMAKE_BUILD_TYPE=Release

WORKDIR /

# # remove ros source and build files.

# RUN rm -rf ${ROS_ROOT}/src
# RUN rm -rf ${ROS_ROOT}/log
# RUN rm -rf ${ROS_ROOT}/build
RUN rm -rf ${ROS_ROOT}/src
RUN rm -rf ${ROS_ROOT}/log
RUN rm -rf ${ROS_ROOT}/build

# RUN apt-get clean
RUN apt-get clean

#############################################################################################################################
#####
##### Remove dev packages to reduce size
#####
#############################################################################################################################

# RUN apt-get update -y
RUN apt-get update -y

# RUN apt-get autoremove -y
RUN apt-get autoremove -y

# RUN rm -rf /var/lib/apt/lists/*
# RUN rm -rf /tmp/*
# RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/*
RUN rm -rf /tmp/*
RUN apt-get clean

#---------------------------------------------------------------------------------------------------------------------------
#----
#---- Start final release image
#----
#---------------------------------------------------------------------------------------------------------------------------

# FROM scratch AS final
FROM scratch AS final

# COPY --from=base / /
COPY --from=base / /

# COPY ros-images/ros_entrypoint.sh /ros_entrypoint.sh
COPY ros-images/ros_entrypoint.sh /ros_entrypoint.sh

# RUN chmod +x /ros_entrypoint.sh
RUN chmod +x /ros_entrypoint.sh

#############################################################################################################################
#####
Expand All @@ -155,16 +155,16 @@ RUN rosdep install -y \
#####
#############################################################################################################################

# ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp

# ENV OPENBLAS_CORETYPE=ARMV8
ENV OPENBLAS_CORETYPE=ARMV8

# ARG ROS_VERSION=humble
ARG ROS_VERSION=humble

# ENV ROS_DISTRO=${ROS_VERSION}
ENV ROS_DISTRO=${ROS_VERSION}

# ENV ROS_ROOT=/opt/ros/${ROS_DISTRO}
ENV ROS_ROOT=/opt/ros/${ROS_DISTRO}

# WORKDIR /
WORKDIR /

# ENTRYPOINT ["/ros_entrypoint.sh"]
ENTRYPOINT ["/ros_entrypoint.sh"]
50 changes: 24 additions & 26 deletions ros-images/r3271.humble_core.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,49 +105,47 @@ RUN rosdep install -y \
--rosdistro ${ROS_DISTRO} \
--skip-keys "fastcdr rti-connext-dds-6.0.1 urdfdom_headers"

#-------------------------------
RUN colcon build \
--merge-install \
--cmake-args -DCMAKE_BUILD_TYPE=Release

# RUN colcon build \
# --merge-install \
# --cmake-args -DCMAKE_BUILD_TYPE=Release

# WORKDIR /
WORKDIR /

# remove ros source and build files.

# RUN rm -rf ${ROS_ROOT}/src
# RUN rm -rf ${ROS_ROOT}/log
# RUN rm -rf ${ROS_ROOT}/build
RUN rm -rf ${ROS_ROOT}/src
RUN rm -rf ${ROS_ROOT}/log
RUN rm -rf ${ROS_ROOT}/build

# RUN apt-get clean
RUN apt-get clean

#############################################################################################################################
#####
##### Remove dev packages to reduce size
#####
#############################################################################################################################

# RUN apt-get update -y
RUN apt-get update -y

# RUN apt-get autoremove -y
RUN apt-get autoremove -y

# RUN rm -rf /var/lib/apt/lists/*
# RUN rm -rf /tmp/*
# RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/*
RUN rm -rf /tmp/*
RUN apt-get clean

#---------------------------------------------------------------------------------------------------------------------------
#----
#---- Start final release image
#----
#---------------------------------------------------------------------------------------------------------------------------

# FROM scratch AS final
FROM scratch AS final

# COPY --from=base / /
COPY --from=base / /

# COPY ros-images/ros_entrypoint.sh /ros_entrypoint.sh
COPY ros-images/ros_entrypoint.sh /ros_entrypoint.sh

# RUN chmod +x /ros_entrypoint.sh
RUN chmod +x /ros_entrypoint.sh

#############################################################################################################################
#####
Expand All @@ -156,16 +154,16 @@ RUN rosdep install -y \
#####
#############################################################################################################################

# ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp

# ENV OPENBLAS_CORETYPE=ARMV8
ENV OPENBLAS_CORETYPE=ARMV8

# ARG ROS_VERSION=humble
ARG ROS_VERSION=humble

# ENV ROS_DISTRO=${ROS_VERSION}
ENV ROS_DISTRO=${ROS_VERSION}

# ENV ROS_ROOT=/opt/ros/${ROS_DISTRO}
ENV ROS_ROOT=/opt/ros/${ROS_DISTRO}

# WORKDIR /
WORKDIR /

# ENTRYPOINT ["/ros_entrypoint.sh"]
ENTRYPOINT ["/ros_entrypoint.sh"]

0 comments on commit a45e032

Please sign in to comment.