Docker-based environment for building all target platforms (#710)

* added a dockerized build environment

* addressed review comments

* added a dockerized build environment

* addressed review comments

* started work on a complete build docker image

* updated docker-based build process to be able to build all platforms

* removed unneeded dockerfile lines
This commit is contained in:
Michael Kamprath
2023-03-07 00:27:56 -08:00
committed by GitHub
parent 48e13f09fd
commit ade7fedc18
4 changed files with 100 additions and 27 deletions

27
docker/Dockerfile Normal file
View File

@ -0,0 +1,27 @@
FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive
ARG USERNAME=devuser
RUN dpkg --add-architecture i386 \
&& apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y \
wget git python3 python-is-python3 python3-pip \
libc6-i386 make \
build-essential
RUN pip3 install pycryptodomex configobj toml fdt
RUN useradd -m -s /bin/bash ${USERNAME}
COPY build_target_platforms.sh /build_target_platforms.sh
RUN chmod 775 /build_target_platforms.sh
ENV OPENBK7231T_APP_NAME="OpenBK7231T_App"
RUN mkdir -p /${OpenBK7231T_App} && chown ${USERNAME} /${OpenBK7231T_App}
USER ${USERNAME}
CMD ["/build_target_platforms.sh"]

View File

@ -1,12 +0,0 @@
FROM ubuntu:20.04
ARG DEBIAN_FRONTEND=noninteractive
ARG USERNAME=devuser
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y \
wget git python3 python-is-python3 libc6-i386 \
make npm
RUN useradd -m -s /bin/bash ${USERNAME}

View File

@ -1,23 +1,31 @@
# Docker Files for OpenBK7231T_App
## Build Environment for BK7231T and BK7231N
The `Dockerfile.BK7231x_build_env` file can be used to create a consistent Linux-based environment for building OpenBK7231T_App for the `BK7231T` and `BK7231N` platforms. This allows you to build OpenBK7231T_App on any flavor of Linux and MacOS. This should also work on Windows, but is untested.
To build the image, run from within this directory:
```sh
docker build -t openbk7231x_build --build-arg USERNAME=$USER -f Dockerfile.BK7231x_build_env .
```
The `cd` to the root of the `OpenBK7231T` or `OpenBK7231N` SDK repo that has been set up [as described in the build instructions](https://github.com/michaelkamprath/OpenBK7231T_App/blob/main/BUILDING.md), and then start a shell prompt in the built Docker image, that binds the SDK repo as a volume in the Docker image:
This docker will build all or some of the platforms that OpenBeken supports. To use, first build the docker image:
```sh
docker run -it -v "$(pwd)/":/home/$USER/OpenBK7231T --user $USER openbk7231x_build /bin/bash
docker build -t openbk_build --build-arg USERNAME=$USER .
```
Change the `OpenBK7231T` directory name in the volume mount to `OpenBK7231N` if you are building for the `OpenBK7231N` platform.
Finally, at the Docker image's shell prompt, execute the following to build:
Note that the current user name is passed through to the docker image build. This is to preserve local file permissions when OpenBeken is built.
Once the docker image is build, you can use it to build the SDKs as follows (assumed you are in the current `docker` directory):
```sh
cd ~/OpenBK7231T/
./b.sh
docker run -it -v "$(pwd)/..":/OpenBK7231T_App openbk_build
```
Again, change the `OpenBK7231T` directory name to `OpenBK7231N` if you are building for that platform. Also, the last command may be changed to the advanced build's `build_app.sh` command as described in [the build instructions](https://github.com/michaelkamprath/OpenBK7231T_App/blob/main/BUILDING.md#building-for-bk7231t). The build results will be placed into the host computer's file system as described in the build instructions. To exit the Docker image's shell prompt when the build is done, use the `exit` command.
When complete, all target platform builds with be present in the repository's `output` directory.
When running the docker image, you may pass the following environment variables with the `--env` option:
* `APP_VERSION` - The version identifier for the build. If not provided, a default version will be used based on the time of the build.
* `TARGET_SDKS` - A comma-separated list of platforms (with no spaces) that should be built. If not present, all platforms will be built. The supported platform identifiers are:
* `OpenBK7231T`
* `OpenBK7231N`
* `OpenXR809`
* `OpenBL602`
* `OpenW800`
* `OpenW600`
For example, to build `OpenBK7231T` and `OpenXR809`, the options should be `-env TARGET_SDKS="OpenBK7231T,OpenXR809"`
* `MAKEFLAGS` - This is the standard `make` environment variable for setting default `make` flags. It is recommended to use this to configure `make` to use multiple cores. for exmaple, to use 8 cores: `--env MAKEFLAGS="-j 8"`

View File

@ -0,0 +1,50 @@
#!/bin/bash
$(shell date +%Y%m%d_%H%M%S)
app_ver=${APP_VERSION:-"dev_$(date +%Y%m%d_%H%M%S)"}
if [ ! -v TARGET_SDKS ]; then
declare -a target_platforms=(
"OpenBK7231T"
"OpenBK7231N"
"OpenXR809"
"OpenBL602"
"OpenW800"
"OpenW600"
)
else
target_platforms=(${TARGET_SDKS//,/ })
fi
echo "****************************************"
echo "****************************************"
echo ""
echo "Building OpenBeken for the following platforms: ${target_platforms[*]}"
echo "Building OpenBeken with version \"${app_ver}\""
echo ""
cd /OpenBK7231T_App
# silence any git ownership warnings beause this is being
# done through a docker. Better solution would be to
# pass through the git config of the host system
git config --global --add safe.directory /OpenBK7231T_App
# build the targeted SDKs
for sdk in ${target_platforms[@]}; do
echo ""
echo "****************************************"
echo "Building platform: ${sdk}"
echo "****************************************"
echo ""
# need to make clean before each build otherwise the one SDKs
# build process will be confused by the prior SDKs build of the
# shared app code.
make clean
make APP_VERSION=${app_ver} APP_NAME=${sdk} ${sdk}
done
echo "****************************************"
echo ""
echo "Done building OpenBeken for the following platforms: ${target_platforms[*]}"
echo "Find outputs in: ../output/${app_ver}"
echo ""