Giter Site home page Giter Site logo

dockbuild

Compiling environments in Docker images.

image

Features

  • 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:

What is the difference between dockcross and dockbuild ?

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.

Compiling environments

dockbuild/centos7-devtoolset4-gcc5:latest, dockbuild/centos7:latest

centos7-devtoolset4-gcc5-latest Centos7 based image including the devtools-4.

dockbuild/centos7-devtoolset7-gcc7:latest

centos7-devtoolset7-gcc7-latest Centos7 based image including the devtools-7.

dockbuild/ubuntu1804-gcc7:latest, dockbuild/ubuntu1804:latest

ubuntu1804-gcc7-latest Ubuntu 18.04 based image.

dockbuild/ubuntu2004-gcc9:latest, dockbuild/ubuntu2004:latest

ubuntu2004-gcc9-latest Ubuntu 20.04 based image.

dockbuild/ubuntu2104-gcc11:latest, dockbuild/ubuntu2104:latest

ubuntu2104-gcc11-latest Ubuntu 21.04 based image.

Deprecated build environments

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-devtoolset2-gcc4-latest Centos5 based image including the devtools-2.

dockbuild/centos6-devtoolset2-gcc4:latest, dockbuild/centos6:latest

centos6-devtoolset2-gcc4-latest Centos6 based image including the devtools-2.

dockbuild/ubuntu1004-gcc4:latest, dockbuild/ubuntu1004:latest

ubuntu1004-gcc4-latest Ubuntu 10.04 based image.

dockbuild/ubuntu1604-gcc5:latest, dockbuild/ubuntu1604:latest

ubuntu1604-gcc5-latest Ubuntu 16.04 based image.

dockbuild/ubuntu1904-gcc8:latest, dockbuild/ubuntu1904:latest

ubuntu1904-gcc8-latest Ubuntu 19.04 based image.

dockbuild/ubuntu2010-gcc10:latest, dockbuild/ubuntu2010:latest

ubuntu2010-gcc10-latest Ubuntu 20.10 based image.

Installation

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.

Usage

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.

Built-in update commands

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.

Download all images

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

Install all dockbuild scripts

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

Dockbuild configuration

TBD

Per-project dockbuild configuration

TBD

How to extend Dockbuild images

TBD

maintainers

Updating CMake version

  1. Set CMake version X.Y.Z corresponding to an existing tag. For example:
CMAKE_VERSION=3.22.1
  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
  1. 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

Articles

---

Credits go to sdt/docker-raspberry-pi-cross-compiler, who invented the base of the dockcross script.

dockbuild's Projects

cmake icon cmake

Mirror of CMake upstream repository

ninja-jobserver icon ninja-jobserver

a small build system with a focus on speed [with GNU make jobserver client support]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.