Compiling environments in Docker images.
- Commands in the container are run as the calling user, so that any created files have the expected ownership, (i.e. not root).
- Make variables (CC, CXX etc) are set to point to the appropriate tools in the container.
- Recent CMake and ninja are precompiled.
- Conan.io can be used as a package manager.
- Current directory is mounted as the container's workdir,
/work
. - Works with the Docker for Mac and Docker for Windows.
- Support using alternative container executor by setting OCI_EXE environment variable. By default, it searches for docker and podman executable.
In addition to the devtools, all images include:
- cmake 3.22.1
- curl with TLS 1.2 support
- git 2.34.1 (with
git config --global advice.detachedHead false
) - python 3.9.10
- ninja 1.1.10 with GNU make jobserver client and Fortran support
The key difference is that dockbuild images use the same method to conveniently isolate the build environment as dockcross but they do NOT provide a toolchain file.
- dockbuild/centos7-devtoolset4-gcc5:latest, dockbuild/centos7:latest
- Centos7 based image including the devtools-4.
- dockbuild/centos7-devtoolset7-gcc7:latest
- Centos7 based image including the devtools-7.
Deprecated build environments are not built/tested/deployed using continuous integration and corresponding Dockerfile have been removed.
- dockbuild/centos5-devtoolset2-gcc4:latest, dockbuild/centos5:latest
- Centos5 based image including the devtools-2.
- dockbuild/centos6-devtoolset2-gcc4:latest, dockbuild/centos6:latest
- Centos6 based image including the devtools-2.
This image does not need to be run manually. Instead, there is a helper script to execute build commands on source code existing on the local host filesystem. This script is bundled with the image.
To install the helper script, run one of the images with no arguments, and redirect the output to a file:
docker run --rm IMAGE_NAME > ./dockbuild chmod x ./dockbuild mv ./dockbuild ~/bin/
Where IMAGE_NAME is the name of the compiling environment Docker instance, e.g. dockbuild/centos5-devtoolset2-gcc4.
Only 64-bit images are provided; a 64-bit host system is required.
For the impatient, here's how to compile a hello world on centos5-devtoolset2-gcc4:
cd ~/src/dockbuild docker run --rm dockbuild/centos5-devtoolset2-gcc4 > ./dockbuild-centos5-devtoolset2-gcc4 chmod x ./dockbuild-centos5-devtoolset2-gcc4 ./dockbuild-centos5-devtoolset2-gcc4 bash -c '$CC test/C/hello.c -o hello_centos5'
Note how invoking any build command (make, gcc, etc.) is just a matter of prepending the dockbuild script on the commandline:
./dockbuild-centos5-devtoolset2-gcc4 [command] [args...]
The dockbuild script will execute the given command-line inside the container, along with all arguments passed after the command. Commands that evaluate environmental variables in the image, like $CC above, should be executed in bash -c. The present working directory is mounted within the image, which can be used to make source code available in the Docker container.
A special update command can be executed that will update the source cross-compiler Docker image or the dockbuild script itself.
dockbuild [--] command [args...]
: Forces a command to run inside the container (in case of a name clash with a built-in command), use--
before the command.dockbuild update-image
: Fetch the latest version of the docker image.dockbuild update-script
: Update the installed dockbuild script with the one bundled in the image.dockbuild update
: Update both the docker image, and the dockbuild script.
To easily download all images, the convenience target display_images
could be used:
curl https://raw.githubusercontent.com/dockbuild/dockbuild/master/Makefile -o dockbuild-Makefile for image in $(make -f dockbuild-Makefile display_images); do echo "Pulling dockbuild/$image" docker pull dockbuild/$image done
To automatically install in ~/bin
the dockbuild scripts for each images already downloaded, the
convenience target display_images
could be used:
curl https://raw.githubusercontent.com/dockbuild/dockbuild/master/Makefile -o dockbuild-Makefile for image in $(make -f dockbuild-Makefile display_images); do if [[ $(docker images -q dockbuild/$image) == "" ]]; then echo "~/bin/dockbuild-$image skipping: image not found locally" continue fi echo "~/bin/dockbuild-$image ok" docker run dockbuild/$image > ~/bin/dockbuild-$image && \ chmod u x ~/bin/dockbuild-$image done
TBD
TBD
TBD
- Set CMake version
X.Y.Z
corresponding to an existing tag. For example:
CMAKE_VERSION=3.22.1
- Update CMake version, and create a Pull Request
# Get current version git clone [email protected]:dockbuilb/dockbuild && \ cd $_ && \ PREVIOUS_CMAKE_VERSION=$(cat README.rst | grep "^\* cmake" | cut -d" " -f3) && \ echo "PREVIOUS_CMAKE_VERSION [${PREVIOUS_CMAKE_VERSION}]" # Update version git checkout -b update-cmake-from-v${PREVIOUS_CMAKE_VERSION}-to-v${CMAKE_VERSION} && \ \ for file in $(find . -name Dockerfile) README.rst; do sed -i "s/${PREVIOUS_CMAKE_VERSION}/${CMAKE_VERSION}/g" $file done && \ \ git add $(find . -name Dockerfile) README.rst && \ \ git commit -m "Update CMake from v${PREVIOUS_CMAKE_VERSION} to v${CMAKE_VERSION}" # Inspect changes git diff HEAD^ # Publish branch git push origin update-cmake-from-v${PREVIOUS_CMAKE_VERSION}-to-v${CMAKE_VERSION} git pull-request
- Check CircleCI and merge Pull Request if tests pass.
Note
- Command
sed -i
may not be available on all unix systems. - Command
git pull-request
is available after install hub
---
Credits go to sdt/docker-raspberry-pi-cross-compiler, who invented the base of the dockcross script.