Merge pull request #137 from pfeerick/docker
Add docker hub image, and other tweaks to docker image and documentation
This commit is contained in:
commit
7c8fb9a468
3 changed files with 102 additions and 29 deletions
|
@ -1,33 +1,69 @@
|
|||
# Build the project using Docker
|
||||
A [Docker image (Dockerfile)](../docker) containing all the build environment is available for X86_64 and AMD64 architectures. This image makes the build of the firmware and the generation of the DFU file for OTA.
|
||||
There are [Docker images (Dockerfile)](../docker) containing the build environment for AMD64 (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.
|
||||
|
||||
## Build the image
|
||||
The image is not (yet) available on DockerHub, you need to build it yourself, which is quite easy. The following commands must be run from the root of the project.
|
||||
## Using the image from Docker Hub
|
||||
|
||||
The image is avaiable via Docker Hub for both the amd64 and arm64v8 architectures at [pfeerick/infinitime-build](https://hub.docker.com/repository/docker/pfeerick/infinitime-build).
|
||||
|
||||
It can be pulled (downloaded) using the following command:
|
||||
|
||||
If you are running on a x86_64 computer :
|
||||
```
|
||||
docker image build -t infinitime-build --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) docker/x86_64/
|
||||
docker pull pfeerick/infinitime-build
|
||||
```
|
||||
|
||||
And if your are running on an ARM64 device (tested on RaspberryPi4 and Pine64 PineBookPro):
|
||||
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 pfeerick/infinitime-build:amd64`
|
||||
|
||||
* For ARM64v8 (ARM64/aarch64) systems: `docker pull pfeerick/infinitime-build:arm64v8`
|
||||
|
||||
The Docker Hub images are 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 during and after compilation.
|
||||
|
||||
The below example will run the container, setting the user and group ids automatically:
|
||||
|
||||
```
|
||||
docker image build -t infinitime-build --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) docker/arm64/
|
||||
docker run --rm -v <project_root>:/sources --user $(id -u):$(id -g) pfeerick/infinitime-build
|
||||
```
|
||||
|
||||
This operation will take some time. It builds a Docker image based on Ubuntu, install some packages, download the ARM toolchain, the NRF SDK, MCUBoot and adafruit-nrfutil.
|
||||
Or you can specify your user id and group id (by number, not by name) directly:
|
||||
|
||||
```
|
||||
docker run --rm -v <project_root>:/sources --user uid_num:gid_num pfeerick/infinitime-build
|
||||
```
|
||||
|
||||
## Build the image yourself
|
||||
Building the docker images yourself is quite easy. The following commands must be run from the root of the project.
|
||||
|
||||
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.
|
||||
|
||||
If you are running on a AMD64 (x86_64) computer:
|
||||
```
|
||||
docker image build -t infinitime-build --build-arg PUID=$(id -u) --build-arg PGID=$(id -g) docker/amd64/
|
||||
```
|
||||
|
||||
If you are running on an ARM64 computer (tested on Raspberry Pi 4 and Pine64 Pinebook Pro):
|
||||
```
|
||||
docker image build -t infinitime-build --build-arg PUID=$(id -u) --build-arg PGID=$(id -g) docker/arm64v8/
|
||||
```
|
||||
|
||||
This operation will take some time, as it builds a Docker image based on Ubuntu, installs some required packages, downloads the ARM toolchain, the NRF SDK, MCUBoot and adafruit-nrfutil.
|
||||
|
||||
When this is done, a new image named *infinitime-build* is available.
|
||||
|
||||
## Run a container to build the project:
|
||||
|
||||
The command to run the container is essentially the same, regardless of whether you built it yourself from the dockerfiles, or are using the Docker Hub images (use `pfeerick/infinitime-build` instead of `infinitime-build` for the later):
|
||||
|
||||
```
|
||||
docker run --rm -v <project_root>:/sources infinitime-build
|
||||
```
|
||||
|
||||
This will start a container (removing it when finished), build the firmware and generate the MCUBoot image and DFU file. The output of the build is stored in `<project_root>/built/output`.
|
||||
|
||||
Replace *<project_root>* by the path of the root of the project on your computer. For example:
|
||||
|
||||
```
|
||||
docker run --rm -v /home/jf/git/PineTime:/sources infinitime-build
|
||||
```
|
||||
|
||||
This will start a container, build the firmware and generate the MCUBoot image and the DFU file. The output of the build is stored in **<project_root>/built/output**.
|
||||
If you encounter permission errors (due to being logged in as a different user, changed user id, running the docker hub image, etc.), see the `--user` parameter mentioned above in the Docker Hub image section to see if this resolves the issue for you.
|
||||
|
|
|
@ -1,17 +1,34 @@
|
|||
FROM ubuntu:18.04
|
||||
FROM amd64/ubuntu:18.04
|
||||
|
||||
ARG USER_ID
|
||||
ARG GROUP_ID
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get update -qq \
|
||||
&& apt-get install -y \
|
||||
build-essential \
|
||||
cmake \
|
||||
git \
|
||||
make \
|
||||
python3 \
|
||||
python3-pip \
|
||||
tar \
|
||||
unzip \
|
||||
wget \
|
||||
&& rm -rf /var/cache/apt/* /var/lib/apt/lists/*
|
||||
|
||||
RUN addgroup --gid $GROUP_ID user
|
||||
RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID user
|
||||
RUN wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2020q2/gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz \
|
||||
&& tar -xjf gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz -C /opt \
|
||||
&& rm gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz
|
||||
|
||||
RUN apt-get update -qq && apt-get install -y wget unzip cmake make build-essential git python3 python3-pip
|
||||
RUN wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2020q2/gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz -O - | tar -xj -C /opt/
|
||||
RUN wget -q https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_15.3.0_59ac345.zip && unzip -q nRF5_SDK_15.3.0_59ac345.zip -d /opt/ && rm nRF5_SDK_15.3.0_59ac345.zip
|
||||
RUN wget -q https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_15.3.0_59ac345.zip \
|
||||
&& unzip -q nRF5_SDK_15.3.0_59ac345.zip -d /opt/ && rm nRF5_SDK_15.3.0_59ac345.zip
|
||||
|
||||
RUN git clone https://github.com/JuulLabs-OSS/mcuboot.git /opt/mcuboot \
|
||||
&& pip3 install -r /opt/mcuboot/scripts/requirements.txt
|
||||
|
||||
RUN git clone https://github.com/JuulLabs-OSS/mcuboot.git /opt/mcuboot && pip3 install -r /opt/mcuboot/scripts/requirements.txt
|
||||
RUN pip3 install adafruit-nrfutil
|
||||
|
||||
USER user
|
||||
CMD ["/sources/docker/build.sh"]
|
||||
ARG PUID=1000
|
||||
ARG PGID=1000
|
||||
RUN groupadd --system --gid $PGID infinitime && useradd --system --uid $PUID --gid $PGID infinitime
|
||||
|
||||
USER infinitime:infinitime
|
||||
CMD ["/sources/docker/build.sh"]
|
||||
|
|
|
@ -1,17 +1,37 @@
|
|||
FROM ubuntu:18.04
|
||||
FROM arm64v8/ubuntu:18.04
|
||||
|
||||
ARG USER_ID
|
||||
ARG GROUP_ID
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get update -qq \
|
||||
&& apt-get install -y \
|
||||
build-essential \
|
||||
cmake \
|
||||
git \
|
||||
libffi-dev \
|
||||
libssl-dev \
|
||||
make \
|
||||
python3 \
|
||||
python3-dev \
|
||||
python3-pip \
|
||||
tar \
|
||||
unzip \
|
||||
wget \
|
||||
&& rm -rf /var/cache/apt/* /var/lib/apt/lists/*
|
||||
|
||||
RUN addgroup --gid $GROUP_ID user
|
||||
RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID user
|
||||
RUN wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2020q2/gcc-arm-none-eabi-9-2020-q2-update-aarch64-linux.tar.bz2 \
|
||||
&& tar -xjf gcc-arm-none-eabi-9-2020-q2-update-aarch64-linux.tar.bz2 -C /opt \
|
||||
&& rm gcc-arm-none-eabi-9-2020-q2-update-aarch64-linux.tar.bz2
|
||||
|
||||
RUN apt-get update -qq && apt-get install -y wget unzip cmake make build-essential git python3 python3-pip libffi-dev libssl-dev python3-dev
|
||||
RUN wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2020q2/gcc-arm-none-eabi-9-2020-q2-update-aarch64-linux.tar.bz2 -O - | tar -xj -C /opt/
|
||||
RUN wget -q https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_15.3.0_59ac345.zip && unzip -q nRF5_SDK_15.3.0_59ac345.zip -d /opt/ && rm nRF5_SDK_15.3.0_59ac345.zip
|
||||
RUN wget -q https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_15.3.0_59ac345.zip \
|
||||
&& unzip -q nRF5_SDK_15.3.0_59ac345.zip -d /opt/ \
|
||||
&& rm nRF5_SDK_15.3.0_59ac345.zip
|
||||
|
||||
RUN git clone https://github.com/JuulLabs-OSS/mcuboot.git /opt/mcuboot && pip3 install -r /opt/mcuboot/scripts/requirements.txt
|
||||
|
||||
RUN pip3 install adafruit-nrfutil
|
||||
|
||||
USER user
|
||||
ARG PUID=1000
|
||||
ARG PGID=1000
|
||||
RUN groupadd --system --gid $PGID infinitime && useradd --system --uid $PUID --gid $PGID infinitime
|
||||
|
||||
USER infinitime:infinitime
|
||||
CMD ["/sources/docker/build.sh"]
|
||||
|
|
Loading…
Reference in a new issue