Skip to content

Commit 32edd3d

Browse files
authored
Merge branch 'main' into firmware_validation_redesign
2 parents 0f1343c + 957ba59 commit 32edd3d

2 files changed

Lines changed: 44 additions & 30 deletions

File tree

‎doc/buildWithDocker.md‎

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,37 @@ Based on Ubuntu 22.04 with the following build dependencies:
1515

1616
Before building, local repository must be fully initialized.
1717

18-
```
18+
```sh
1919
git clone https://github.com/InfiniTimeOrg/InfiniTime.git
2020
cd InfiniTime
2121
git submodule update --init
2222
```
2323

24-
## Run a container to build the project
25-
26-
The `infinitime-build` image contains all the dependencies you need.
27-
The default `CMD` will compile sources found in `/sources`, so you need only mount your code.
24+
## Provision the image
2825

29-
Before continuing, make sure you first build the image as indicated in the [Build the image](#build-the-image) section, or check the [Using the image from Docker Hub](#using-the-image-from-docker-hub) section if you prefer to use a pre-made image.
26+
Before continuing, the build image needs to be either build locally or pulled
27+
from Docker Hub, as described in the two sections below:
3028

31-
This example will build the firmware, generate the MCUBoot image and generate the DFU file.
32-
For cloning the repo, see [these instructions](../doc/buildAndProgram.md#clone-the-repo). Outputs will be written to **<project_root>/build/output**:
33-
34-
```bash
35-
cd <project_root> # e.g. cd ./work/Pinetime
36-
docker run --rm -it -v ${PWD}:/sources --user $(id -u):$(id -g) infinitime-build
37-
```
29+
### Build the image
3830

39-
By default, the container runs as `root`, which is not convenient as all the files generated by the build will also belong to `root`.
40-
The parameter `--user` overrides that default behavior.
41-
The command above will run as your current user.
31+
You can build the image yourself if you like!
4232

43-
If you only want to build a single CMake target, you can pass it in as the first parameter to the build script.
44-
This means calling the script explicitly as it will override the `CMD`.
45-
Here's an example for `pinetime-app`:
33+
The following commands must be run from the root of the project. This operation
34+
will take some time but, when done, a new image named `infinitime-build` is
35+
available.
4636

47-
```bash
48-
docker run --rm -it -v ${PWD}:/sources --user $(id -u):$(id -g) infinitime-build /opt/build.sh pinetime-app
37+
```sh
38+
docker build -t infinitime-build ./docker
4939
```
5040

51-
## Using the image from Docker Hub
41+
### Pull the image from Docker Hub
5242

53-
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).
43+
The image is available via Docker Hub for both the amd64 and arm64v8 architectures at
44+
[infinitime/infinitime-build](https://hub.docker.com/repository/docker/infinitime/infinitime-build).
5445

5546
You can run it using the following command:
5647

57-
```bash
48+
```sh
5849
docker run --rm -it -v ${PWD}:/sources --user $(id -u):$(id -g) infinitime/infinitime-build
5950
```
6051

@@ -64,12 +55,35 @@ The default `latest` tag *should* automatically identify the correct image archi
6455

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

67-
## Build the image
58+
## Run a container to build the project
6859

69-
You can build the image yourself if you like!
60+
The `infinitime-build` image contains all the dependencies you need.
61+
The default `CMD` will compile sources found in `/sources`, so you need only mount your code.
7062

71-
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.
63+
This example will build the firmware, generate the MCUBoot image and generate the DFU file.
64+
Outputs will be written to **<project_root>/build/output**:
7265

73-
```bash
74-
docker build -t infinitime-build ./docker
66+
```sh
67+
cd <project_root> # e.g. cd ./work/Pinetime
68+
docker run --rm -it -v ${PWD}:/sources infinitime-build
69+
```
70+
71+
If the docker service is running as `root`, the build process inside the
72+
container also runs as `root`, which is not convenient as all the files
73+
generated by the build will also belong to `root`. The parameter `--user`
74+
overrides this behaviour. The command below ensures that all files are created
75+
as your current user:
76+
77+
78+
```sh
79+
cd <project_root> # e.g. cd ./work/Pinetime
80+
docker run --rm -it -v ${PWD}:/sources --user $(id -u):$(id -g) infinitime-build
81+
```
82+
83+
If you only want to build a single CMake target, you can pass it in as the first parameter to the build script.
84+
This means calling the script explicitly as it will override the `CMD`.
85+
Here's an example for `pinetime-app`:
86+
87+
```sh
88+
docker run --rm -it -v ${PWD}:/sources --user $(id -u):$(id -g) infinitime-build /opt/build.sh pinetime-app
7589
```

‎docker/Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,5 @@ RUN adduser infinitime
6868
# Configure Git to accept the /sources directory as safe
6969
RUN git config --global --add safe.directory /sources
7070

71-
ENV SOURCES_DIR /sources
71+
ENV SOURCES_DIR=/sources
7272
CMD ["/opt/build.sh"]

0 commit comments

Comments
 (0)