Add docker build (#1375)

* Add docker build
This commit is contained in:
Hussein Galal 2021-06-23 17:01:36 +02:00 committed by GitHub
parent 0d1fc25a25
commit 28569b91cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 0 deletions

3
.gitignore vendored
View File

@ -21,6 +21,9 @@
# Build dir #
######################
src/build
docker/build/
*.dapper
# Old releases
releases

19
docker/Dockerfile Normal file
View File

@ -0,0 +1,19 @@
FROM ubuntu:20.04 AS dapper
ARG DAPPER_HOST_ARCH
ENV DAPPER_ENV TARGET
ENV ARCH $DAPPER_HOST_ARCH
ENV DAPPER_OUTPUT ./docker/build
ENV DAPPER_DOCKER_SOCKET true
ENV DAPPER_TARGET dapper
RUN apt update && apt install -y build-essential wget git python3 python
ENV GCC_URL="https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2"
RUN mkdir ./gcc
RUN wget --no-check-certificate -O - ${GCC_URL} | tar --strip-components=1 -jx -C ./gcc
RUN mkdir ./cmake && \
CMAKE_URL="https://cmake.org/files/v3.20/cmake-3.20.0-linux-x86_64.tar.gz" && \
wget --no-check-certificate -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C ./cmake
RUN mkdir -p /source/gcc && mkdir -p /source/cmake && cp -r ./gcc /source/gcc && cp -r ./cmake /source/cmake
WORKDIR /source
ENTRYPOINT ["./docker/build.sh"]

12
docker/Makefile Normal file
View File

@ -0,0 +1,12 @@
.PHONY: default
default: in-docker-build
./.dapper:
@echo Downloading dapper
@curl -sL https://releases.rancher.com/dapper/v0.5.0/dapper-$$(uname -s)-$$(uname -m) > .dapper.tmp
@@chmod +x .dapper.tmp
@./.dapper.tmp -v
@mv .dapper.tmp .dapper
in-docker-build: .dapper
./.dapper -C ../ -f docker/Dockerfile --target dapper make

15
docker/build.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
set -e -x
cd $(dirname $0)/..
export PATH=/source/gcc/gcc/bin:/source/cmake/cmake/bin:$PATH
git submodule update --init --depth=1
git -C src/micropython/ submodule update --init --depth=1
# Build the firmware.
make -j$(nproc) -C src/micropython/mpy-cross
make -j$(nproc) TARGET=$TARGET -C src
mkdir -p ./docker/build/$TARGET
cp -r src/build/bin/* ./docker/build/$TARGET

View File

@ -64,6 +64,18 @@ This will setup the `openmv` and `micropython` repos so `origin` points to your
Finally, after pushing your changes you can then use Github to automatically generate a Pull Request to the official OpenMV Github repo to get your changes upstreamed into the official OpenMV Cam Firmware.
### Docker Build
To build the firmware using docker, follow the following steps:
```
git clone https://github.com/openmv/openmv.git --depth=50
cd openmv/docker
make TARGET=<TARGET NAME>
```
After building you should see the target build output under `docker/build/<TARGET_NAME>`.
### Committing Etiquette
If you would like to send a Pull Request to get your changes integrated into the official source tree please try to keep one commit to one Pull Request. Additionally, please create example scripts (in `../scripts/examples`) for any new features you are committing.