Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 40 additions & 14 deletions docker/build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,66 @@
Apollo runs within Docker containers, with images tailored for development and
deployment. We currently support `x86_64` and `aarch64` architectures.

Build orchestration is now standardized on `docker buildx bake`.

- `x86_64`: based on `nvidia/cuda` official images.
- `aarch64` (Jetson): based on `nvcr.io/nvidia/l4t-jetpack` (L4T).

**Image Types:**

- **Cyber (Base/Cyber)**: Core CyberRT framework, ideal for CyberRT-focused
development.
- **Base**: Foundational CUDA/ML runtime layer for Apollo docker builds.
- **Dev**: Full Apollo project with development toolchain, for building and
running the entire Apollo stack.
- **Runtime**: Optimized, minimal image for production deployment.

## Quick Start

Use the `./build_docker.sh` script to build images.
Use `docker buildx bake` directly, or keep using `./build_docker.sh` as a
compatibility wrapper around bake.

### 0. Prepare Buildx Builder

```bash
docker buildx create --name apollo-builder --use --bootstrap || docker buildx use apollo-builder
```

### 1. Build CyberRT Image
### 1. Build Base Image

Builds the base development environment including CUDA/CuDNN/TensorRT and the
CyberRT framework.
Builds the foundational environment including CUDA/CuDNN/TensorRT and core
system dependencies.

```bash
cd docker/build

# Build x86_64 CyberRT image (default: download pre-built dependencies)
./build_docker.sh -f cyber.x86_64.dockerfile
# Build x86_64 Base image
./build_docker.sh -f base.x86_64.cuda.dockerfile

# Equivalent direct bake command
docker buildx bake -f docker-bake.hcl base-x86_64-cuda

# For users in mainland China (accelerated mirrors)
./build_docker.sh -f cyber.x86_64.dockerfile -g cn
./build_docker.sh -f base.x86_64.cuda.dockerfile -g cn

# Build all dependencies from source (takes longer)
./build_docker.sh -f dev.x86_64.cpu.dockerfile -m build
./build_docker.sh -f dev.x86_64.cuda.dockerfile -m build
```

### 2. Build Apollo Dev Image

Builds the full Apollo development image, based on a CyberRT image.
Builds the full Apollo development image, based on a Base image.

```bash
# Build x86_64 Dev image
./build_docker.sh -f dev.x86_64.dockerfile
./build_docker.sh -f dev.x86_64.cuda.dockerfile

# Build aarch64 Dev image (ensure qemu-user-static is configured for cross-arch builds)
./build_docker.sh -f dev.aarch64.dockerfile -m download
./build_docker.sh -f dev.aarch64.cuda.dockerfile -m download

# Build all base images in one shot
docker buildx bake -f docker-bake.hcl base

# Build all dev images in one shot
docker buildx bake -f docker-bake.hcl dev
```

### 3. Build Apollo Runtime Image
Expand Down Expand Up @@ -76,13 +96,19 @@ Usage:
build_docker.sh -f <Dockerfile> [Options]

Options:
-f, --dockerfile Path to the Dockerfile (e.g., 'cyber.x86_64.dockerfile').
-f, --dockerfile Path to the Dockerfile (e.g., 'base.x86_64.cuda.dockerfile').
-c, --clean Disable Docker build cache (--no-cache=true).
-m, --mode Installation mode: 'download' (default, use pre-built), 'build' (build from source).
-g, --geo Enable geo-specific mirrors ('cn' or 'us', default 'us').
-t, --timestamp Timestamp of the previous stage image (YYYYMMDD_HHMM).
--dry Dry run (print commands without execution).
-h, --help Show help message and exit.

Additional wrapper options:

--l4t-tag L4T tag for Jetson base (default: r36.4.0)
--push Push images to registry
--no-load Do not load images into local docker daemon
```

---
Expand Down
63 changes: 14 additions & 49 deletions docker/build/base.aarch64.cuda.dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#ARG BASE_IMAGE=nvcr.io/nvidia/l4t-jetpack:r35.4.1
ARG BASE_IMAGE=nvidia/cuda:11.4.3-cudnn8-devel-ubuntu20.04
ARG BASE_IMAGE=nvcr.io/nvidia/l4t-jetpack:r36.4.0
FROM ${BASE_IMAGE}

ARG TENSORRT_VERSION="8.5.2"
ARG PATCH_SUFFIX="-1+cuda11.4"
ARG CUDA_TOOLKIT_VERSION="12.6.68"
ARG CUDNN_VERSION="9.3.0.75"
ARG TENSORRT_VERSION="10.3.0.30"
ARG VPI_VERSION="3.2.4"
ARG VULKAN_VERSION="1.3.204"
ARG GEOLOC
ARG DEBIAN_FRONTEND=noninteractive

Expand All @@ -14,58 +16,21 @@ RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -qq -y --no-install-recommends \
ca-certificates \
gnupg2 && \
gnupg2 \
curl \
libvulkan1 \
vulkan-tools && \
rm -rf /var/lib/apt/lists/* && apt-get clean

# consistent with the host system, for jetson orin, if not, please modify it manually
ADD https://repo.download.nvidia.com/jetson/jetson-ota-public.asc /etc/apt/trusted.gpg.d/jetson-ota-public.asc
RUN chmod +r /etc/apt/trusted.gpg.d/jetson-ota-public.asc
COPY rcfiles/nvidia-jetson-common-r35.4-main.list /etc/apt/sources.list.d/nvidia-jetson-common-r35.4-main.list

# change source list for cn
COPY rcfiles/sources.list.tsinghua.aarch64.ubuntu.20.04 /etc/apt/sources.list

# Add NVIDIA Tegra library paths
RUN echo "/usr/lib/aarch64-linux-gnu/tegra" >> /etc/ld.so.conf.d/nvidia-tegra.conf && \
echo "/usr/lib/aarch64-linux-gnu/tegra-egl" >> /etc/ld.so.conf.d/nvidia-tegra.conf

#
# Install nvidia-cuda-dev for CUDA developer packages
# Use nvidia-cuda if need CUDA runtime only
#
# RUN --mount=type=bind,source=rcfiles/sources.list.local.aarch64.ubuntu.20.04,target=/etc/apt/sources.list \
# --mount=type=bind,source=rcfiles/wheelos.cn.public.gpg,target=/opt/apollo/rcfiles/wheelos.cn.public.gpg \
RUN apt-get update && \
apt-get install -y --no-install-recommends \
nvidia-cuda-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

#
# Install nvidia-cudnn8-dev for CuDNN developer packages
# Use nvidia-cudnn8 if need CuDNN runtime only
#
# RUN --mount=type=bind,source=rcfiles/sources.list.local.aarch64.ubuntu.20.04,target=/etc/apt/sources.list \
# --mount=type=bind,source=rcfiles/wheelos.cn.public.gpg,target=/opt/apollo/rcfiles/wheelos.cn.public.gpg \
RUN apt-get update && \
apt-get install -y --no-install-recommends \
nvidia-cudnn8-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

#
# Install nvidia-tensorrt-dev for TensorRT developer packages
# Use nvidia-tensorrt if need TensorRT runtime only
#
# RUN --mount=type=bind,source=rcfiles/sources.list.local.aarch64.ubuntu.20.04,target=/etc/apt/sources.list \
# --mount=type=bind,source=rcfiles/wheelos.cn.public.gpg,target=/opt/apollo/rcfiles/wheelos.cn.public.gpg \
RUN apt-get update && \
apt-get install -y --no-install-recommends \
nvidia-tensorrt-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES all

ENV CUDA_TOOLKIT_VERSION=${CUDA_TOOLKIT_VERSION}
ENV CUDNN_VERSION=${CUDNN_VERSION}
ENV TENSORRT_VERSION=${TENSORRT_VERSION}
ENV VPI_VERSION=${VPI_VERSION}
ENV VULKAN_VERSION=${VULKAN_VERSION}
39 changes: 22 additions & 17 deletions docker/build/base.x86_64.cuda.dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
ARG BASE_IMAGE=nvidia/cuda:11.8.0-cudnn8-devel-ubuntu20.04
ARG BASE_IMAGE=nvidia/cuda:12.6.3-cudnn-devel-ubuntu22.04
FROM ${BASE_IMAGE}

ARG TENSORRT_VERSION="8.6.1.6"
ARG PATCH_SUFFIX="-1+cuda11.8"
ARG CUDA_TOOLKIT_VERSION="12.6.68"
ARG CUDNN_VERSION="9.3.0.75"
ARG TENSORRT_VERSION="10.3.0.30"
ARG VPI_VERSION="3.2.4"
ARG VULKAN_VERSION="1.3.204"

LABEL maintainer="WheelOS <developer@wheelos.cn>"

COPY rcfiles/sources.list.tsinghua.x86_64.ubuntu.20.04 /etc/apt/sources.list

ENV DEBIAN_FRONTEND=noninteractive

# Note:
Expand All @@ -17,19 +18,23 @@ ENV DEBIAN_FRONTEND=noninteractive
# --mount=type=bind,source=rcfiles/wheelos.cn.public.gpg,target=/opt/apollo/rcfiles/wheelos.cn.public.gpg \
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libnvinfer8="${TENSORRT_VERSION}${PATCH_SUFFIX}" \
libnvinfer-plugin8="${TENSORRT_VERSION}${PATCH_SUFFIX}" \
libnvinfer-vc-plugin8="${TENSORRT_VERSION}${PATCH_SUFFIX}" \
libnvinfer-dev="${TENSORRT_VERSION}${PATCH_SUFFIX}" \
libnvinfer-headers-dev="${TENSORRT_VERSION}${PATCH_SUFFIX}" \
libnvinfer-headers-plugin-dev="${TENSORRT_VERSION}${PATCH_SUFFIX}" \
libnvinfer-plugin-dev="${TENSORRT_VERSION}${PATCH_SUFFIX}" \
libnvonnxparsers8="${TENSORRT_VERSION}${PATCH_SUFFIX}" \
libnvonnxparsers-dev="${TENSORRT_VERSION}${PATCH_SUFFIX}" \
libnvparsers8="${TENSORRT_VERSION}${PATCH_SUFFIX}" \
libnvparsers-dev="${TENSORRT_VERSION}${PATCH_SUFFIX}" \
python3-libnvinfer="${TENSORRT_VERSION}${PATCH_SUFFIX}" && \
ca-certificates \
curl \
gnupg2 \
libvulkan1 \
vulkan-tools && \
(apt-get install -y --no-install-recommends nvidia-tensorrt-dev \
|| apt-get install -y --no-install-recommends tensorrt-dev \
|| apt-get install -y --no-install-recommends \
libnvinfer-dev \
libnvinfer-plugin-dev \
libnvonnxparsers-dev \
libnvparsers-dev) && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

ENV CUDA_TOOLKIT_VERSION=${CUDA_TOOLKIT_VERSION}
ENV CUDNN_VERSION=${CUDNN_VERSION}
ENV TENSORRT_VERSION=${TENSORRT_VERSION}
ENV VPI_VERSION=${VPI_VERSION}
ENV VULKAN_VERSION=${VULKAN_VERSION}
Loading