Skip to content

Commit 2cad8db

Browse files
committed
feat: update docker build pipeline
1 parent 50496d9 commit 2cad8db

29 files changed

+1376
-773
lines changed

.flake8

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
max-line-length = 88
3+
extend-ignore = E203, W503
4+
exclude = .git,__pycache__,build,dist

.github/workflows/lint-format.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ jobs:
6060
if: github.event_name == 'pull_request'
6161
run: |
6262
echo "Running apollo_lint.sh in diff mode for PR..."
63-
${{ github.workspace }}/scripts/ci/apollo_ci.sh --all --diff origin/${{ github.base_ref }}
63+
${{ github.workspace }}/scripts/ci/apollo_lint.sh --all --diff origin/${{ github.base_ref }}
6464
env:
6565
GITHUB_BASE_REF: ${{ github.base_ref }}
6666

6767
- name: Run Lint and Format Checks (Push Full Mode)
6868
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
6969
run: |
7070
echo "Running apollo_lint.sh in full mode for push to main branch..."
71-
${{ github.workspace }}/scripts/ci/apollo_ci.sh --all
71+
${{ github.workspace }}/scripts/ci/apollo_lint.sh --all

README.md

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
# Welcome to Apollo's GitHub page!
22

3-
[Apollo-Lite](https://github.com/wheelos/apollo-lite) is a high-performance, flexible architecture accelerating the development, testing, and deployment of Autonomous Vehicles.
3+
[Apollo-Lite](https://github.com/wheelos/apollo-lite) is a high-performance,
4+
flexible architecture accelerating the development, testing, and deployment of
5+
Autonomous Vehicles.
46

57
---
6-
> We choose to go to the moon in this decade and do the other things,
7-
> not because they are easy, but because they are hard.
8+
9+
> We choose to go to the moon in this decade and do the other things, not
10+
> because they are easy, but because they are hard.
811
>
912
> -- John F. Kennedy, 1962
13+
1014
---
1115

1216
## Table of Contents
@@ -23,8 +27,12 @@
2327

2428
## Introduction
2529

26-
Apollo is packed with powerful modules and features designed for autonomous driving development. Before you take it for a spin, please ensure your environment is properly calibrated and configured by following the prerequisites and installation instructions below.
27-
For a deeper dive, check out Apollo's [architecture overview](http://apollo.auto/docs/architecture_overview.html) to understand its core technologies and platform design.
30+
Apollo is packed with powerful modules and features designed for autonomous
31+
driving development. Before you take it for a spin, please ensure your
32+
environment is properly calibrated and configured by following the prerequisites
33+
and installation instructions below. For a deeper dive, check out Apollo's
34+
[architecture overview](http://apollo.auto/docs/architecture_overview.html) to
35+
understand its core technologies and platform design.
2836

2937
---
3038

@@ -45,9 +53,13 @@ For a deeper dive, check out Apollo's [architecture overview](http://apollo.auto
4553
## Quick Start
4654

4755
### 1. Setup Host Environment
48-
Run the following scripts in order to prepare your host machine, which will perform the following steps sequentially:
56+
57+
Run the following scripts in order to prepare your host machine, which will
58+
perform the following steps sequentially:
59+
4960
1. Install Docker (checks if already installed, then proceeds)
50-
2. Install NVIDIA Container Toolkit (checks if already installed, depends on Docker)
61+
2. Install NVIDIA Container Toolkit (checks if already installed, depends on
62+
Docker)
5163
3. Perform host system configurations
5264

5365
```bash
@@ -56,11 +68,12 @@ bash docker/setup_host/setup_host.sh
5668
```
5769

5870
### 2. Start Docker Container
71+
5972
Download and start the Apollo container image (only needs to be done once):
6073

6174
```bash
62-
# docker pull & start
63-
bash docker/scripts/dev_start.sh
75+
# docker pull & start testing
76+
bash docker/scripts/dev_start.sh -d testing
6477
```
6578

6679
Enter the running container environment in subsequent sessions with:
@@ -70,17 +83,13 @@ Enter the running container environment in subsequent sessions with:
7083
bash docker/scripts/dev_into.sh
7184
```
7285

73-
### 3. Build Apollo
74-
75-
Inside the container, install build dependencies:
86+
Setting Environment Variables
7687

7788
```bash
78-
# update bazel & gcc
79-
sudo bash docker/build/installers/install_bazel.sh
80-
sudo bash docker/build/installers/install_gcc.sh
89+
source cyber/setup.bash
8190
```
8291

83-
> **Note:** Current container image does not have the latest Bazel and GCC. You need to manually install/upgrade them. Future container versions will include these by default.
92+
### 3. Build Apollo
8493

8594
Build the entire Apollo project with:
8695

@@ -100,16 +109,19 @@ To build a single module, use:
100109

101110
## Copyright and License
102111

103-
Apollo is licensed under the [Apache License 2.0](LICENSE). Please adhere to the licensing terms when using or contributing to this project.
112+
Apollo is licensed under the [Apache License 2.0](LICENSE). Please adhere to the
113+
licensing terms when using or contributing to this project.
104114

105115
---
106116

107117
## Connect with us
108118

109119
- ⭐ Star and Fork to support the project!
110-
- 💬 Join our [community discussion group](http://apollo.auto/community) to chat with developers.
120+
- 💬 Join our [community discussion group](http://apollo.auto/community) to chat
121+
with developers.
111122
- 📧 For collaboration or business inquiries, contact: [email protected]
112123

113124
---
114125

115-
Thank you for being part of Apollo's journey towards autonomous driving innovation!
126+
Thank you for being part of Apollo's journey towards autonomous driving
127+
innovation!

docker/build/README.md

Lines changed: 92 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,152 +1,140 @@
1-
# Apollo Docker Image Build Process
1+
# Apollo Docker Image Build Guide
22

3-
## Introduction
3+
## Overview
44

5-
As you may already know, Apollo runs inside Docker container. There are
6-
basically two types of Apollo Docker images: CyberRT and Dev. CyberRT images
7-
were for developers who want to play with the CyberRT framework only, while Dev
8-
images were used to build and run the whole Apollo project.
5+
Apollo runs within Docker containers, with images tailored for development and
6+
deployment. We currently support `x86_64` and `aarch64` architectures.
97

10-
Currently, two CPU architectures are supported: `x86_64` and `aarch64`.
8+
**Image Types:**
119

12-
**Note**
10+
- **Cyber (Base/Cyber)**: Core CyberRT framework, ideal for CyberRT-focused
11+
development.
12+
- **Dev**: Full Apollo project with development toolchain, for building and
13+
running the entire Apollo stack.
14+
- **Runtime**: Optimized, minimal image for production deployment.
1315

14-
> `dev.aarch64` image was still WIP as of today. It is expected to be ready in
15-
> the next few months.
16+
## Quick Start
1617

17-
In the section below, I will describe briefly the steps to build these Docker
18-
images.
18+
Use the `./build_docker.sh` script to build images.
1919

20-
## Build CyberRT Image
20+
### 1. Build CyberRT Image
2121

22-
Type `./build_docker.sh -h` for help message:
22+
Builds the base development environment including CUDA/CuDNN/TensorRT and the
23+
CyberRT framework.
2324

24-
```
25-
Usage:
26-
build_docker.sh -f <Dockerfile> [Options]
27-
Available options:
28-
-c,--clean Use "--no-cache=true" for docker build
29-
-m,--mode "build" for build everything from source if possible, "download" for using prebuilt ones
30-
-g,--geo Enable geo-specific mirrors to speed up build. Currently "cn" and "us" are supported.
31-
-d,--dist Whether to build stable("stable") or experimental("testing") Docker images
32-
-t,--timestamp Specify Cyber image timestamp to build Dev image from it. Format: yyyymmdd_hhmm (e.g 20210205_1520)
33-
--dry Dry run (for testing purpose)
34-
-h,--help Show this message and exit
35-
E.g.,
36-
build_docker.sh -f cyber.x86_64.dockerfile -m build -g cn
37-
build_docker.sh -f dev.aarch64.dockerfile -m download -d testing
38-
```
25+
```bash
26+
cd docker/build
3927

40-
Here, the `-g/--geo` option is used to enable geo-location based settings (APT &
41-
PYPI mirrors, etc.). Two codes (`us` & `cn`) are supported now, and the default
42-
is `us`.
28+
# Build x86_64 CyberRT image (default: download pre-built dependencies)
29+
./build_docker.sh -f cyber.x86_64.dockerfile
4330

44-
To build the latest CyberRT image, simply run:
31+
# For users in mainland China (accelerated mirrors)
32+
./build_docker.sh -f cyber.x86_64.dockerfile -g cn
4533

46-
```
47-
./build_docker.sh -f cyber.<TARGET_ARCH>.dockerfile
34+
# Build all dependencies from source (takes longer)
35+
./build_docker.sh -f dev.x86_64.cpu.dockerfile -m build
4836
```
4937

50-
Users of mainland China can specify `-g cn` to speed up build process:
38+
### 2. Build Apollo Dev Image
5139

52-
```
53-
./build_docker.sh -f cyber.<TARGET_ARCH>.dockerfile -g cn
54-
```
55-
56-
## Build Apollo Dev Image
40+
Builds the full Apollo development image, based on a CyberRT image.
5741

58-
Run the following command to build Apollo Dev image:
42+
```bash
43+
# Build x86_64 Dev image
44+
./build_docker.sh -f dev.x86_64.dockerfile
5945

60-
```
61-
build_docker.sh -f dev.<TARGET_ARCH>.dockerfile
46+
# Build aarch64 Dev image (ensure qemu-user-static is configured for cross-arch builds)
47+
./build_docker.sh -f dev.aarch64.dockerfile -m download
6248
```
6349

64-
On success, output messages like the following will be shown at the bottom of
65-
your screen.
50+
### 3. Build Apollo Runtime Image
6651

67-
```
68-
Successfully built baca71e567e6
69-
Successfully tagged apolloauto/apollo:dev-x86_64-18.04-20200824_0339
70-
Built new image apolloauto/apollo:dev-x86_64-18.04-20200824_0339
71-
```
52+
Used for lightweight production deployments. Requires a prior Apollo Release
53+
Build.
7254

73-
## Build Apollo Runtime Docker Image
74-
75-
Apollo Runtime Docker was used in combination with Release Build output for easy
76-
deployment. You can run the following commands to build Apollo Runtime Docker
77-
image on your own.
78-
79-
```
80-
# Generate required APT packages
55+
```bash
56+
# 1. Generate required APT packages from Apollo Release Build
8157
./apollo.sh release -c -r
8258

59+
# 2. Navigate to the Docker build directory and copy package list
8360
cd docker/build
84-
# Copy the generated package list for docker build
8561
cp /apollo/output/syspkgs.txt .
8662

87-
cp runtime.x86_64.dockerfile.sample runtime.x86_64.dockerfile
63+
# 3. Build the Runtime image (x86_64 only currently)
64+
# cp runtime.x86_64.dockerfile.sample runtime.x86_64.dockerfile # if file doesn't exist
8865
bash build_docker.sh -f runtime.x86_64.dockerfile
8966
```
9067

91-
> Note: Apollo Runtime Docker supports x86_64 only as Release Build was not
92-
> ready for Aarch64 yet.
68+
---
9369

94-
## Tips
70+
## Script Arguments
9571

96-
### Build Log
72+
Run `./build_docker.sh --help` for full options:
9773

98-
The build log for CyberRT and Dev Docker images was located at
99-
`/opt/apollo/build.log`, which contains download links and checksums of
100-
dependent packages during Docker build.
101-
102-
### Enable Local HTTP Cache to Speed Up Build
74+
```
75+
Usage:
76+
build_docker.sh -f <Dockerfile> [Options]
10377
104-
You can enable local HTTP cache to speed up package downloading by performing
105-
the following steps on your **host** running Docker:
78+
Options:
79+
-f, --dockerfile Path to the Dockerfile (e.g., 'cyber.x86_64.dockerfile').
80+
-c, --clean Disable Docker build cache (--no-cache=true).
81+
-m, --mode Installation mode: 'download' (default, use pre-built), 'build' (build from source).
82+
-g, --geo Enable geo-specific mirrors ('cn' or 'us', default 'us').
83+
-t, --timestamp Timestamp of the previous stage image (YYYYMMDD_HHMM).
84+
--dry Dry run (print commands without execution).
85+
-h, --help Show help message and exit.
86+
```
10687

107-
1. Download all prerequisite packages to a directory (say, `$HOME/archive`) with
108-
URLs listed in the build log. Pay attention to their checksum.
109-
2. Change to that archive directory and start your local HTTP cache server at
110-
port **8388**.
88+
---
11189

112-
```
113-
cd $HOME/archive
114-
nohup python3 -m http.server 8388 &
115-
```
90+
## Advanced Tips
11691

117-
> Note: Another advantage with the local HTTP cache mechanism is, it has little
118-
> influence on the final image size. Even if the cached package was missing or
119-
> broken, it can still be downloaded from the original URL.
92+
### Cross-Architecture Builds
12093

121-
3. Rerun `build_docker.sh`.
94+
For cross-architecture builds (e.g., building `aarch64` on `x86_64`), ensure
95+
`qemu-user-static` is configured:
12296

123-
## Add New Installer
97+
```bash
98+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
99+
```
124100

125-
The best practice of a new installer would be:
101+
**Recommendation:** Utilize `docker buildx` for a more robust and efficient
102+
multi-platform build experience.
126103

127-
1. Well tested.
104+
### Optimize Build Speed
128105

129-
Of course. Make it work, and don't break other installers, such as
130-
incompatible versions of libraries.
106+
- **Local HTTP Cache:** Setting up a local HTTP server to cache downloaded
107+
packages can significantly speed up repeated builds without affecting final
108+
image size.
131109

132-
1. Standalone.
110+
**Steps:**
133111

134-
Have minimum assumption about the basement, which means, you can depend on
135-
the base image and `installers/installer_base.sh`. Other than that, you
136-
should install all the dependencies in your own installer.
112+
1. **Download prerequisites:** Identify and download all necessary
113+
prerequisite packages to a local directory (e.g., `$HOME/apollo_cache`).
114+
URLs are typically listed in the build log (`/opt/apollo/build.log`). Pay
115+
attention to checksums for integrity.
116+
2. **Start local HTTP server:** Navigate to your cache directory and start a
117+
simple HTTP server on port **8388**:
118+
```bash
119+
mkdir -p "$HOME/apollo_cache" && cd "$_"
120+
nohup python3 -m http.server 8388 &
121+
```
122+
3. **Rerun build:** Execute `build_docker.sh` as usual. The Docker build
123+
process will attempt to fetch packages from
124+
`http://host.docker.internal:8388` (or directly from
125+
`http://<your_host_ip>:8388` if `host.docker.internal` is not available),
126+
greatly reducing download times.
137127

138-
1. Thin.
128+
- **Benefit:** Even if a cached package is missing or broken, the build
129+
process will fall back to downloading from the original URL.
139130

140-
It will generate a new layer in the final image, so please keep it as thin as
141-
possible. For example, clean up all intermediate files:
131+
- **Avoid `--no-cache` (`-c`):** Only use when strictly necessary, as it forces
132+
re-downloading and re-building all layers, significantly increasing build
133+
time.
142134

143-
```bash
144-
wget xxx.zip
145-
# Unzip, make, make install
146-
rm -fr xxx.zip xxx
147-
```
135+
### Debugging Builds
148136

149-
1. Cross-architecture.
137+
Build logs are located at `/opt/apollo/build.log` inside the container,
138+
providing detailed information on downloads and installation steps.
150139

151-
It would be awesome to work perfectly for different architectures such as
152-
`x86_64` and `aarch64`.
140+
---

0 commit comments

Comments
 (0)