aboutsummaryrefslogtreecommitdiffstats
path: root/doc/buildWithDocker.md
blob: db9bfcfc9853a3cb1fa14ecbb9eb4d06298e8588 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Build the project using Docker

A [Docker image (Dockerfile)](../docker) containing all the build environment is available for X86_64 and ARM64 architectures.
These images make the build of the firmware and the generation of the DFU file for OTA quite easy, as well as preventing clashes with any other toolchains or development environments you may have installed.

Based on Ubuntu 22.04 with the following build dependencies:

- ARM GCC Toolchain
- nRF SDK
- MCUBoot
- adafruit-nrfutil
- lv_font_conv

## Clone the repository

Before building, local repository must be fully initialized.

```sh
git clone https://github.com/InfiniTimeOrg/InfiniTime.git
cd InfiniTime
git submodule update --init
```

## Provision the image

Before continuing, the build image needs to be either build locally or pulled
from Docker Hub, as described in the two sections below:

### Build the image

You can build the image yourself if you like!

The following commands must be run from the root of the project. This operation
will take some time but, when done, a new image named `infinitime-build` is
available.

```sh
docker build -t infinitime-build ./docker
```

### Pull the image from Docker Hub

The image is available via Docker Hub for both the amd64 and arm64v8 architectures at
[infinitime/infinitime-build](https://hub.docker.com/repository/docker/infinitime/infinitime-build).

You can run it using the following command:

```sh
docker run --rm -it -v ${PWD}:/sources --user $(id -u):$(id -g) infinitime/infinitime-build
```

The default `latest` tag *should* automatically identify the correct image architecture, but if for some reason Docker does not, you can specify it manually:

- For AMD64 (x86_64) systems: `docker pull --platform linux/amd64 infinitime/infinitime-build`

- For ARM64v8 (ARM64/aarch64) systems: `docker pull --platform linux/arm64 infinitime/infinitime-build`

## Run a container to build the project

The `infinitime-build` image contains all the dependencies you need.
The default `CMD` will compile sources found in `/sources`, so you need only mount your code.

This example will build the firmware, generate the MCUBoot image and generate the DFU file.
Outputs will be written to **<project_root>/build/output**:

```sh
cd <project_root> # e.g. cd ./work/Pinetime
docker run --rm -it -v ${PWD}:/sources infinitime-build
```

If the docker service is running as `root`, the build process inside the
container also runs as `root`, which is not convenient as all the files
generated by the build will also belong to `root`. The parameter `--user`
overrides this behaviour. The command below ensures that all files are created
as your current user:


```sh
cd <project_root> # e.g. cd ./work/Pinetime
docker run --rm -it -v ${PWD}:/sources --user $(id -u):$(id -g) infinitime-build
```

If you only want to build a single CMake target, you can pass it in as the first parameter to the build script.
This means calling the script explicitly as it will override the `CMD`.
Here's an example for `pinetime-app`:

```sh
docker run --rm -it -v ${PWD}:/sources --user $(id -u):$(id -g) infinitime-build /opt/build.sh pinetime-app
```