Docker container documentation : Adapt the --user documentation according to the new behavior.

This commit is contained in:
Jean-François Milants 2022-05-23 19:39:10 +02:00 committed by JF
parent 1ffca52715
commit 9b216bb16f

View file

@ -2,12 +2,13 @@
A [Docker image (Dockerfile)](../docker) containing all the build environment is available for X86_64 and AMD64 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. A [Docker image (Dockerfile)](../docker) containing all the build environment is available for X86_64 and AMD64 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 18.04 with the following build dependencies: Based on Ubuntu 22.04 with the following build dependencies:
* ARM GCC Toolchain * ARM GCC Toolchain
* nRF SDK * nRF SDK
* MCUBoot * MCUBoot
* adafruit-nrfutil * adafruit-nrfutil
* lv_font_conv
## Run a container to build the project ## Run a container to build the project
@ -19,27 +20,15 @@ This example will build the firmware, generate the MCUBoot image and generate th
```bash ```bash
cd <project_root> # e.g. cd ./work/Pinetime cd <project_root> # e.g. cd ./work/Pinetime
docker run --rm -it -v $(pwd):/sources infinitime-build docker run --rm -it -v $(pwd):/sources --user $(id -u):$(id -g) infinitime-build
``` ```
By default, the container runs as `root`, which is not convenient as all the file generated by the build will also belong to `root`. The parameter `--user` overrides that default behavior. The command above will run as your current user.
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`: 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`:
```bash ```bash
docker run --rm -it -v $(pwd):/sources infinitime-build /opt/build.sh pinetime-app docker run --rm -it -v $(pwd):/sources --user $(id -u):$(id -g) infinitime-build /opt/build.sh pinetime-app
```
The image is built using 1000:1000 for the user id and group id. If this is different to your user or group ids (run `id -u` and `id -g` to find out what your id values are if you are unsure), you will need to override them via the `--user` parameter in order to prevent permission errors with the output files (and the cmake build cache).
Running with this image is the same as above, you just specify the ids to `docker run`:
```bash
docker run --rm -it -v $(pwd):/sources --user $(id -u):$(id -g) infinitime-build
```
Or you can specify your user id and group id (by number, not by name) directly:
```bash
docker run --rm -it -v $(pwd):/sources --user 1234:1234 infinitime-build
``` ```
## Using the image from Docker Hub ## Using the image from Docker Hub
@ -52,6 +41,12 @@ It can be pulled (downloaded) using the following command:
docker pull infinitime/infinitime-build docker pull infinitime/infinitime-build
``` ```
The command line to build the project is the same as above. You just need to change the image name to `infinitime/infinitime-build`:
```
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: 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 AMD64 (x86_64) systems: `docker pull --platform linux/amd64 infinitime/infinitime-build`
@ -66,10 +61,4 @@ The following commands must be run from the root of the project. This operation
```bash ```bash
docker image build -t infinitime-build ./docker docker image build -t infinitime-build ./docker
``` ```
The `PUID` and `PGID` build arguments are used to set the user and group ids used in the container, meaning you will not need to specify it later unless they change for some reason. Specifying them is not mandatory, as this can be over-ridden at build time via the `--user` flag, but doing so will make the command you need to run later a bit shorter. In the below examples, they are set to your current user id and group id automatically. You can specify them manually, but they must be specified by number, not by name.
```bash
docker image build -t infinitime-build --build-arg PUID=$(id -u) --build-arg PGID=$(id -g) ./docker
```