Skip to content

Use Docker to distribute the build system

Jeremy Soller requested to merge batonius:docker into master

Created by: batonius

Problem: Redox's build system is hard to setup and maintain, and changes regularly.

Solution: Use Docker to build self-contained images with all the tools needed and then use them on a local checkout of Redox to build disk images.

Changes introduced by this pull request:

  • Dockerfile and entrypoint.sh has been added.

How to use:

  1. To build an image, run docker build -t redox . in the docker directory. This will create a new image called redox in the local image repository. You can rebuild this image every time you need to update the toolchain.
  2. Instead of make all call docker run --cap-add MKNOD --cap-add SYS_ADMIN --device /dev/fuse -e LOCAL_USER_ID=`id -u` -v `pwd`:/src --rm redox make all . To clarify, --cap-add MKNOD --cap-add SYS_ADMIN --device /dev/fuse is required to use fuse inside the container, -e LOCAL_USER_ID=`id -u` sets the LOCAL_USER_ID variable to the current uid so entrypoint.sh can setup a non-root user inside the container to run commands as, -v `pwd`:/src binds the currend directory as /src inside the container, --rm removes the container after it's finished, redox is the name of the image to run and make all is the command to run inside the container.
  3. The container can be run with an interactive shell instead with docker run --cap-add MKNOD --cap-add SYS_ADMIN --device /dev/fuse -e LOCAL_USER_ID=`id -u` -v `pwd`:/src --rm -it redox bash .

How I propose we use it:

  • The best way to use it is to setup the official dockerhub repository, redox-os/toolchain for example, so a user can skip step 1 above and just call docker run --cap-add MKNOD --cap-add SYS_ADMIN --device /dev/fuse -e LOCAL_USER_ID=`id -u` -v `pwd`:/src --rm redox-os/toolchain make all, which would automatically downlad the image and run it as described above. The image will be saved in the local repository until it's updated in the hub.
  • Dockerhub can be configured to automatically rebuild images from a Dockerfile in a github repository on each push: https://docs.docker.com/docker-hub/builds/ .
  • After it's done we can change the Makefile to hide that scary long line behind something like make all docker=1.
  • This setup will allow the maintainer to change the configuration of the build system whenever and however he likes without breaking users's build setups.

TODO:

  • I have no idea if it works on *BSD and macOS, options I've used to run fuse inside a container might not work.

Merge request reports