Files
documentation/docs/Developer-Guide_Building-with-Docker.md

83 lines
3.2 KiB
Markdown
Raw Normal View History

# Building with Docker
## Officially supported and tested method for building with Docker
2018-04-21 13:47:06 +03:00
This method works for building u-boot and kernel packages as well as building full OS images.
Note!
To write fresh-builded image directly to sdcard or other block device you have to enable
Docker run in `privileged` mode.
Uncomment line `DOCKER_FLAGS+=(--privileged)` in file `userpatches\config-docker.conf` or your own docker-config file.
2018-04-21 13:54:02 +03:00
2018-04-21 13:47:06 +03:00
Building additional packages (`EXTERNAL_NEW`) is not supported.
### Requirements
2018-04-21 13:47:06 +03:00
- x86/x64/aarch64/armhf Linux host that supports running a recent Docker daemon. Refer to [Docker documentation](https://docs.docker.com/) for details.
- Docker version 17.06 CE or newer.
- Enough free disk space on the storage used for Docker containers and named volumes. Named volumes path can be changed using standard Docker utilites,
refer to Docker documentation for details.
Installation (https://docs.docker.com/engine/install/)
2018-04-21 13:47:06 +03:00
### Details
2018-04-21 13:47:06 +03:00
There are 3 options to start build process:
2018-04-21 13:54:02 +03:00
1. By passing configuration file name (`config-<conf_name>.conf`), stored in `userpatches` directory, as an argument:
2020-08-02 10:24:08 +02:00
```
./compile.sh docker <conf_name>
```
2. By passing addtional line arguments to `compile.sh` after `docker`:
2020-08-02 10:24:08 +02:00
```
./compile.sh docker KERNEL_ONLY=yes BOARD=cubietruck BRANCH=current KERNEL_CONFIGURE=yes
```
3. Interactively run inside docker container
```
./compile.sh docker-shell BOARD=rockpi-4a BRANCH=edge RELEASE=focal
```
2020-08-02 10:24:08 +02:00
The process creates and runs a named Docker container `armbian` with two named volumes `armbian-cache` and `armbian-ccache`,
and mount local directories `output` and `userpatches`.
2018-04-21 13:47:06 +03:00
1 and 2 docker modes uses same as no docker, but runs in separated builder environment, with minimal intervention to base system.
2018-04-21 13:47:06 +03:00
Dockerfile of container placed in `userpatches` directory, all container-related tunes can be changed
in `userpatches/config-docker.conf` file. Templates of both files located in `config/templates` directory.
2018-04-21 13:47:06 +03:00
### docker-shell interactive mode
Interactive mode of a docker usable when you need more than "just make an image". You may look to u-boot or
kernel sources before and after applying patches, investigate compilation errors, and so on.
And you can manual run separate steps of build process.
First, start docker-shell on a build system itself:
2020-08-02 10:24:08 +02:00
```
@droid:~/armbian$ ./compile.sh docker-shell RELEASE=buster BOARD=rockpi-4a BRANCH=edge
2020-08-02 10:24:08 +02:00
```
There `RELEASE=buster BOARD=rockpi-4a BRANCH=edge` just passed into shell and will be set into
envirounment variables.
Then, we can simply start build image:
2020-08-02 10:24:08 +02:00
```
root@75ec76203b65:~/armbian# ./compile.sh
2020-08-02 10:24:08 +02:00
```
Or, you can run any function defined in the compile.sh script.
For example, to compile the U-Boot, prepare the environment first with:
2020-08-02 10:24:08 +02:00
```
./compile.sh default prepare_host compile_sunxi_tools install_rkbin_tools
2020-08-02 10:24:08 +02:00
```
Then build U-Boot for example:
2020-08-02 10:24:08 +02:00
```
./compile.sh default compile_uboot
2020-08-02 10:24:08 +02:00
```
To compile only the source code as it is without patching, run:
2020-08-02 10:24:08 +02:00
```
./compile.sh default COMPILE_ONLY=yes compile_uboot
2020-08-02 10:24:08 +02:00
```
Note that you must enter docker-shell after a docker build, which will
download all the required toolchains and sourcecodes first.
you can set `KERNEL_ONLY=yes` to build atf&u-boot&kernel only.